rust/tests/ui/parser/stmt_expr_attrs_placement.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
Rust
Raw Normal View History

2019-09-16 15:45:13 -05:00
#![feature(stmt_expr_attributes)]
// Test that various placements of the inner attribute are parsed correctly,
// or not.
fn main() {
let a = #![allow(warnings)] (1, 2);
//~^ ERROR an inner attribute is not permitted in this context
let b = (#![allow(warnings)] 1, 2);
//~^ ERROR an inner attribute is not permitted in this context
2019-09-16 15:45:13 -05:00
let c = {
#![allow(warnings)]
(#![allow(warnings)] 1, 2)
//~^ ERROR an inner attribute is not permitted in this context
2019-09-16 15:45:13 -05:00
};
let d = {
#![allow(warnings)]
let e = (#![allow(warnings)] 1, 2);
//~^ ERROR an inner attribute is not permitted in this context
2019-09-16 15:45:13 -05:00
e
};
let e = [#![allow(warnings)] 1, 2];
//~^ ERROR an inner attribute is not permitted in this context
let f = [#![allow(warnings)] 1; 0];
//~^ ERROR an inner attribute is not permitted in this context
let g = match true { #![allow(warnings)] _ => {} };
2021-05-11 14:21:54 -05:00
struct MyStruct { field: u8 }
let h = MyStruct { #![allow(warnings)] field: 0 };
//~^ ERROR an inner attribute is not permitted in this context
2019-09-16 15:45:13 -05:00
}