Skip to content

Commit 48825bc

Browse files
committed
Remove an unnecessary/incorrect match in the expression check function
1 parent 816c1b1 commit 48825bc

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/librustc/hir/check_attr.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
250250
self.emit_repr_error(
251251
attr.span,
252252
stmt.span,
253-
&format!("attribute should not be applied to statements"),
253+
&format!("attribute should not be applied a statement"),
254254
&format!("not a struct, enum or union"),
255255
);
256256
}
@@ -259,16 +259,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
259259
}
260260

261261
fn check_expr_attributes(&self, expr: &hir::Expr) {
262-
use hir::Expr_::*;
263-
match expr.node {
264-
// Assignments, Calls and Structs were handled by Items and Statements
265-
ExprCall(..) |
266-
ExprAssign(..) |
267-
ExprMethodCall(..) |
268-
ExprStruct(..) => return,
269-
_ => (),
270-
}
271-
272262
for attr in expr.attrs.iter() {
273263
if attr.check_name("inline") {
274264
self.check_inline(attr, &expr.span, Target::Expression);
@@ -278,7 +268,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
278268
attr.span,
279269
expr.span,
280270
&format!("attribute should not be applied to an expression"),
281-
&format!("not a struct, enum or union"),
271+
&format!("not defining a struct, enum or union"),
282272
);
283273
}
284274
}

src/test/compile-fail/issue-43988.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ fn main() {
2121

2222
#[repr(nothing)]
2323
let _x = 0;
24-
//~^^ ERROR attribute should not be applied to statements
25-
24+
//~^^ ERROR attribute should not be applied a statement
2625

2726
#[repr(something_not_real)]
2827
loop {
@@ -32,5 +31,12 @@ fn main() {
3231

3332
#[repr]
3433
let _y = "123";
35-
//~^^ ERROR attribute should not be applied to statements
34+
//~^^ ERROR attribute should not be applied a statement
35+
36+
37+
fn foo() {}
38+
39+
#[inline(ABC)]
40+
foo();
41+
//~^^ ERROR attribute should be applied to function
3642
}

0 commit comments

Comments
 (0)