Remove an unnecessary/incorrect match in the expression check function

This commit is contained in:
matthew 2018-03-26 19:41:19 -07:00
parent 816c1b191c
commit 48825bcb23
2 changed files with 11 additions and 15 deletions

View File

@ -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"),
);
}
@ -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);
@ -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"),
);
}
}

View File

@ -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 {
@ -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
}