Skip to content

Commit 431eeb0

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35364 - kc1212:e0379, r=jonathandturner
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
2 parents 71b8958 + 764d5cf commit 431eeb0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,9 @@ fn check_trait_fn_not_const<'a,'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
847847
// good
848848
}
849849
hir::Constness::Const => {
850-
span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const");
850+
struct_span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const")
851+
.span_label(span, &format!("trait fns cannot be const"))
852+
.emit()
851853
}
852854
}
853855
}

src/test/compile-fail/const-fn-mismatch.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ trait Foo {
2020
}
2121

2222
impl Foo for u32 {
23-
const fn f() -> u32 { 22 } //~ ERROR E0379
23+
const fn f() -> u32 { 22 }
24+
//~^ ERROR E0379
25+
//~| NOTE trait fns cannot be const
2426
}
2527

2628
fn main() { }

0 commit comments

Comments
 (0)