Skip to content

Commit bf934f9

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35778 - clementmiao:E0395_new_error_format, r=jonathandturner
updated E0395 to new error format Updated E0395 to new error format. Part of rust-lang#35233 Fixes rust-lang#35693 Thanks again for letting me help! r? @jonathandturner
2 parents 4685704 + 0dc13ee commit bf934f9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
681681

682682
self.add(Qualif::NOT_CONST);
683683
if self.mode != Mode::Fn {
684-
span_err!(self.tcx.sess, self.span, E0395,
685-
"raw pointers cannot be compared in {}s",
686-
self.mode);
684+
struct_span_err!(
685+
self.tcx.sess, self.span, E0395,
686+
"raw pointers cannot be compared in {}s",
687+
self.mode)
688+
.span_label(
689+
self.span,
690+
&format!("comparing raw pointers in static"))
691+
.emit();
687692
}
688693
}
689694
}

src/test/compile-fail/E0395.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ static FOO: i32 = 42;
1212
static BAR: i32 = 42;
1313

1414
static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395
15-
15+
//~| NOTE comparing raw pointers in static
1616
fn main() {
1717
}

src/test/compile-fail/issue-25826.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ fn id<T>(t: T) -> T { t }
1212
fn main() {
1313
const A: bool = id::<u8> as *const () < id::<u16> as *const ();
1414
//~^ ERROR raw pointers cannot be compared in constants [E0395]
15+
//~^^ NOTE comparing raw pointers in static
1516
println!("{}", A);
1617
}

0 commit comments

Comments
 (0)