Rollup merge of #35780 - clementmiao:E0396_new_err_format, r=jonathandturner

updated E0396 to new error format

Updated E0396 to new error format.
Part of #35233
Fixes #35779

Thanks again for letting me help!

r? @jonathandturner
This commit is contained in:
Jonathan Turner 2016-08-20 07:09:35 -07:00 committed by GitHub
commit 69612f0039
3 changed files with 9 additions and 3 deletions

View File

@ -493,9 +493,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
if let ty::TyRawPtr(_) = base_ty.sty {
this.add(Qualif::NOT_CONST);
if this.mode != Mode::Fn {
span_err!(this.tcx.sess, this.span, E0396,
"raw pointers cannot be dereferenced in {}s",
this.mode);
struct_span_err!(this.tcx.sess,
this.span, E0396,
"raw pointers cannot be dereferenced in {}s",
this.mode)
.span_label(this.span,
&format!("dereference of raw pointer in constant"))
.emit();
}
}
}

View File

@ -11,6 +11,7 @@
const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396
//~| NOTE dereference of raw pointer in constant
fn main() {
}

View File

@ -12,5 +12,6 @@
fn main() {
static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; //~ ERROR E0396
//~| NOTE dereference of raw pointer in constant
println!("{}", C);
}