Skip to content

Commit

Permalink
Rollup merge of rust-lang#35445 - pcn:update-E0017-to-new-format, r=a…
Browse files Browse the repository at this point in the history
…rielb1

Update e0017 to new format

Updated `span_err!` to use `struct_span_err!` and provide a `span_label` that describes the error in context.

Updated the test to look for the `span_label`s that are provided now.
  • Loading branch information
Jonathan Turner committed Aug 11, 2016
2 parents e24c326 + ec1ef79 commit d2e9573
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 @@ -617,9 +617,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 d2e9573

Please sign in to comment.