Skip to content

Commit

Permalink
Rollup merge of rust-lang#35722 - knight42:update-error-msg, r=jonath…
Browse files Browse the repository at this point in the history
…andturner

Updated E0394 & E0422 to new format

Fixes rust-lang#35692 and rust-lang#35700, as part of rust-lang#35233.

r? @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 17, 2016
2 parents 75454f7 + 3caa451 commit 5fc58dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
} else {
"cannot refer to statics by value, use a constant instead"
};
span_err!(self.tcx.sess, self.span, E0394, "{}", msg);
struct_span_err!(self.tcx.sess, self.span, E0394, "{}", msg)
.span_label(self.span, &format!("referring to another static by value"))
.note(&format!("use the address-of operator or a constant instead"))
.emit();

// Replace STATIC with NOT_CONST to avoid further errors.
self.qualif = self.qualif - Qualif::STATIC;
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::DoesNotNameAStruct(name) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0422,
"`{}` does not name a structure",
name)
name);
err.span_label(span, &format!("not a structure"));
err
}
ResolutionError::StructVariantUsedAsFunction(path_name) => {
struct_span_err!(resolver.session,
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0394.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// except according to those terms.

static A: u32 = 0;
static B: u32 = A; //~ ERROR E0394
static B: u32 = A;
//~^ ERROR E0394
//~| NOTE referring to another static by value
//~| NOTE use the address-of operator or a constant instead

fn main() {
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0422.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
// except according to those terms.

fn main () {
let x = Foo { x: 1, y: 2 }; //~ ERROR E0422
let x = Foo { x: 1, y: 2 };
//~^ ERROR E0422
//~| NOTE not a structure
}

0 comments on commit 5fc58dc

Please sign in to comment.