Skip to content

Commit

Permalink
Updated the messages for E0017
Browse files Browse the repository at this point in the history
- Fix note message, fix tests.
  • Loading branch information
pcn committed Aug 7, 2016
1 parent 4c02363 commit ec1ef79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/test/compile-fail/E0017.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit ec1ef79

Please sign in to comment.