Add extra test for expressions and fix typo in message

This commit is contained in:
matthew 2018-03-27 08:39:15 -07:00
parent 48825bcb23
commit 4957a40d13
2 changed files with 9 additions and 3 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 a statement"),
&format!("attribute should not be applied to a statement"),
&format!("not a struct, enum or union"),
);
}

View File

@ -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]
@ -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 {
@ -31,7 +33,7 @@ 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() {}
@ -39,4 +41,8 @@ fn main() {
#[inline(ABC)]
foo();
//~^^ ERROR attribute should be applied to function
let _z = #[repr] 1;
//~^ ERROR attribute should not be applied to an expression
}