Skip to content

Commit

Permalink
Remove an unnecessary/incorrect match in the expression check function
Browse files Browse the repository at this point in the history
  • Loading branch information
tejom committed Mar 27, 2018
1 parent 816c1b1 commit 48825bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
14 changes: 2 additions & 12 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
self.emit_repr_error(
attr.span,
stmt.span,
&format!("attribute should not be applied to statements"),
&format!("attribute should not be applied a statement"),
&format!("not a struct, enum or union"),
);
}
Expand All @@ -259,16 +259,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
}

fn check_expr_attributes(&self, expr: &hir::Expr) {
use hir::Expr_::*;
match expr.node {
// Assignments, Calls and Structs were handled by Items and Statements
ExprCall(..) |
ExprAssign(..) |
ExprMethodCall(..) |
ExprStruct(..) => return,
_ => (),
}

for attr in expr.attrs.iter() {
if attr.check_name("inline") {
self.check_inline(attr, &expr.span, Target::Expression);
Expand All @@ -278,7 +268,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
attr.span,
expr.span,
&format!("attribute should not be applied to an expression"),
&format!("not a struct, enum or union"),
&format!("not defining a struct, enum or union"),
);
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/test/compile-fail/issue-43988.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ fn main() {

#[repr(nothing)]
let _x = 0;
//~^^ ERROR attribute should not be applied to statements

//~^^ ERROR attribute should not be applied a statement

#[repr(something_not_real)]
loop {
Expand All @@ -32,5 +31,12 @@ fn main() {

#[repr]
let _y = "123";
//~^^ ERROR attribute should not be applied to statements
//~^^ ERROR attribute should not be applied a statement


fn foo() {}

#[inline(ABC)]
foo();
//~^^ ERROR attribute should be applied to function
}

0 comments on commit 48825bc

Please sign in to comment.