about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonathan Turner <jonathandturner@users.noreply.github.com>2016-08-20 07:09:35 -0700
committerGitHub <noreply@github.com>2016-08-20 07:09:35 -0700
commit69612f0039b87e1a31c3cc4c063c19d3536812a9 (patch)
tree9216a70ef07468925a912d69cdeb3fa16452bd81
parent7c843c466313a99485286637d6c8a0ad7c2ec6c0 (diff)
parentdae1406b822c1357f701047951e747dbca2b1446 (diff)
downloadrust-69612f0039b87e1a31c3cc4c063c19d3536812a9.tar.gz
rust-69612f0039b87e1a31c3cc4c063c19d3536812a9.zip
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
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs10
-rw-r--r--src/test/compile-fail/E0396.rs1
-rw-r--r--src/test/compile-fail/const-deref-ptr.rs1
3 files changed, 9 insertions, 3 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 0857ae79763..bcdc0d2ea3f 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -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();
                                 }
                             }
                         }
diff --git a/src/test/compile-fail/E0396.rs b/src/test/compile-fail/E0396.rs
index 7f34acdfb90..47080fb6e9e 100644
--- a/src/test/compile-fail/E0396.rs
+++ b/src/test/compile-fail/E0396.rs
@@ -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() {
 }
diff --git a/src/test/compile-fail/const-deref-ptr.rs b/src/test/compile-fail/const-deref-ptr.rs
index fa15f3e87c6..c626801d48c 100644
--- a/src/test/compile-fail/const-deref-ptr.rs
+++ b/src/test/compile-fail/const-deref-ptr.rs
@@ -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);
 }