From 48825bcb23e752c0072a66450ae38d9865ee718e Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 26 Mar 2018 19:41:19 -0700 Subject: [PATCH] Remove an unnecessary/incorrect match in the expression check function --- src/librustc/hir/check_attr.rs | 14 ++------------ src/test/compile-fail/issue-43988.rs | 12 +++++++++--- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 6e1b7dc86a29..ecf8960c237d 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -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"), ); } } diff --git a/src/test/compile-fail/issue-43988.rs b/src/test/compile-fail/issue-43988.rs index 78237e31ba06..c03cd67fef99 100644 --- a/src/test/compile-fail/issue-43988.rs +++ b/src/test/compile-fail/issue-43988.rs @@ -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 }