Skip to content

Commit dae1406

Browse files
committed
updated E0396 to new error format
1 parent 9376da6 commit dae1406

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/librustc_mir/transform/qualify_consts.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
490490
if let ty::TyRawPtr(_) = base_ty.sty {
491491
this.add(Qualif::NOT_CONST);
492492
if this.mode != Mode::Fn {
493-
span_err!(this.tcx.sess, this.span, E0396,
494-
"raw pointers cannot be dereferenced in {}s",
495-
this.mode);
493+
struct_span_err!(this.tcx.sess,
494+
this.span, E0396,
495+
"raw pointers cannot be dereferenced in {}s",
496+
this.mode)
497+
.span_label(this.span,
498+
&format!("dereference of raw pointer in constant"))
499+
.emit();
496500
}
497501
}
498502
}

src/test/compile-fail/E0396.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
1212

1313
const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396
14+
//~| NOTE dereference of raw pointer in constant
1415

1516
fn main() {
1617
}

src/test/compile-fail/const-deref-ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212

1313
fn main() {
1414
static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; //~ ERROR E0396
15+
//~| NOTE dereference of raw pointer in constant
1516
println!("{}", C);
1617
}

0 commit comments

Comments
 (0)