Skip to content

Commit

Permalink
Rollup merge of rust-lang#35364 - kc1212:e0379, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0379 to new format rust-lang#35338

Fixes rust-lang#35338, as part of rust-lang#35233.

But this does not include the bonus. From my understanding a Span is defined by a `hi` and a `lo` position within some context. A naive way would be to mutate the span so that `hi` is 5 positions from `lo` which corresponds to the `const` keyword. But this methods feels a bit rigid. Is there another way to do this?

r? @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 5, 2016
2 parents 71b8958 + 764d5cf commit 431eeb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,9 @@ fn check_trait_fn_not_const<'a,'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
// good
}
hir::Constness::Const => {
span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const");
struct_span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const")
.span_label(span, &format!("trait fns cannot be const"))
.emit()
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/const-fn-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ trait Foo {
}

impl Foo for u32 {
const fn f() -> u32 { 22 } //~ ERROR E0379
const fn f() -> u32 { 22 }
//~^ ERROR E0379
//~| NOTE trait fns cannot be const
}

fn main() { }

0 comments on commit 431eeb0

Please sign in to comment.