Skip to content

Commit

Permalink
updated E0395 to new error format
Browse files Browse the repository at this point in the history
  • Loading branch information
clementmiao committed Aug 18, 2016
1 parent 9376da6 commit 0dc13ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {

self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
span_err!(self.tcx.sess, self.span, E0395,
"raw pointers cannot be compared in {}s",
self.mode);
struct_span_err!(
self.tcx.sess, self.span, E0395,
"raw pointers cannot be compared in {}s",
self.mode)
.span_label(
self.span,
&format!("comparing raw pointers in static"))
.emit();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0395.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ static FOO: i32 = 42;
static BAR: i32 = 42;

static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395

//~| NOTE comparing raw pointers in static
fn main() {
}
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-25826.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ fn id<T>(t: T) -> T { t }
fn main() {
const A: bool = id::<u8> as *const () < id::<u16> as *const ();
//~^ ERROR raw pointers cannot be compared in constants [E0395]
//~^^ NOTE comparing raw pointers in static
println!("{}", A);
}

0 comments on commit 0dc13ee

Please sign in to comment.