Skip to content

Commit

Permalink
E0516 Update error format rust-lang#36108
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinb authored and jakllsch committed Sep 8, 2016
1 parent 2e84fda commit a0f1251
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,21 @@ impl<'a> CheckAttrVisitor<'a> {

let mut conflicting_reprs = 0;
for word in words {

let name = match word.name() {
Some(word) => word,
None => continue,
};

let message = match &*name {
let word: &str = &word.name();
let (message, label) = match word {
"C" => {
conflicting_reprs += 1;
if target != Target::Struct &&
target != Target::Union &&
target != Target::Enum {
"attribute should be applied to struct, enum or union"
("attribute should be applied to struct, enum or union",
"a struct, enum or union")
} else {
continue
}
Expand All @@ -85,7 +88,8 @@ impl<'a> CheckAttrVisitor<'a> {
"simd" => {
conflicting_reprs += 1;
if target != Target::Struct {
"attribute should be applied to struct"
("attribute should be applied to struct",
"a struct")
} else {
continue
}
Expand All @@ -95,15 +99,17 @@ impl<'a> CheckAttrVisitor<'a> {
"isize" | "usize" => {
conflicting_reprs += 1;
if target != Target::Enum {
"attribute should be applied to enum"
("attribute should be applied to enum",
"an enum")
} else {
continue
}
}
_ => continue,
};

span_err!(self.sess, attr.span, E0517, "{}", message);
struct_span_err!(self.sess, attr.span, E0517, "{}", message)
.span_label(attr.span, &format!("requires {}", label))
.emit();
}
if conflicting_reprs > 1 {
span_warn!(self.sess, attr.span, E0566,
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
}
}
hir::TyTypeof(ref _e) => {
span_err!(tcx.sess, ast_ty.span, E0516,
"`typeof` is a reserved keyword but unimplemented");
struct_span_err!(tcx.sess, ast_ty.span, E0516,
"`typeof` is a reserved keyword but unimplemented")
.span_label(ast_ty.span, &format!("reserved keyword"))
.emit();

tcx.types.err
}
hir::TyInfer => {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/E0516.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

fn main() {
let x: typeof(92) = 92; //~ ERROR E0516
//~| reserved keyword
}

0 comments on commit a0f1251

Please sign in to comment.