Skip to content

Commit

Permalink
Add extra test for expressions and fix typo in message
Browse files Browse the repository at this point in the history
  • Loading branch information
tejom committed Mar 27, 2018
1 parent 48825bc commit 4957a40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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 a statement"),
&format!("attribute should not be applied to a statement"),
&format!("not a struct, enum or union"),
);
}
Expand Down
10 changes: 8 additions & 2 deletions src/test/compile-fail/issue-43988.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(stmt_expr_attributes)]

fn main() {

#[inline]
Expand All @@ -21,7 +23,7 @@ fn main() {

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

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

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


fn foo() {}

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

let _z = #[repr] 1;
//~^ ERROR attribute should not be applied to an expression

}

0 comments on commit 4957a40

Please sign in to comment.