From ec1ef79ad9561d1fb6384700c43a48bd3cfe7b7c Mon Sep 17 00:00:00 2001 From: "Peter C. Norton" Date: Sat, 6 Aug 2016 20:12:09 -0400 Subject: [PATCH] Updated the messages for E0017 - Fix note message, fix tests. --- src/librustc_mir/transform/qualify_consts.rs | 9 ++++++--- src/test/compile-fail/E0017.rs | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 1d00938fb25eb..a3081e489329f 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -616,9 +616,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if !allow { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - span_err!(self.tcx.sess, self.span, E0017, - "references in {}s may only refer \ - to immutable values", self.mode); + struct_span_err!(self.tcx.sess, self.span, E0017, + "references in {}s may only refer \ + to immutable values", self.mode) + .span_label(self.span, &format!("{}s require immutable values", + self.mode)) + .emit(); } } } else { diff --git a/src/test/compile-fail/E0017.rs b/src/test/compile-fail/E0017.rs index 13f2c23d8c4a9..1223a01cbcb6f 100644 --- a/src/test/compile-fail/E0017.rs +++ b/src/test/compile-fail/E0017.rs @@ -12,11 +12,16 @@ static X: i32 = 1; const C: i32 = 2; const CR: &'static mut i32 = &mut C; //~ ERROR E0017 + //~| NOTE constants require immutable values //~| ERROR E0017 + //~| NOTE constants require immutable values static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 + //~| NOTE statics require immutable values //~| ERROR E0017 + //~| NOTE statics require immutable values //~| ERROR E0388 static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 + //~| NOTE statics require immutable values //~| ERROR E0017 - + //~| NOTE statics require immutable values fn main() {}