]> git.lizzy.rs Git - rust.git/blob - src/test/ui/parser/stmt_expr_attrs_placement.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / parser / stmt_expr_attrs_placement.rs
1 #![feature(stmt_expr_attributes)]
2
3 // Test that various placements of the inner attribute are parsed correctly,
4 // or not.
5
6 fn main() {
7     let a = #![allow(warnings)] (1, 2);
8     //~^ ERROR an inner attribute is not permitted in this context
9
10     let b = (#![allow(warnings)] 1, 2);
11     //~^ ERROR an inner attribute is not permitted in this context
12
13     let c = {
14         #![allow(warnings)]
15         (#![allow(warnings)] 1, 2)
16         //~^ ERROR an inner attribute is not permitted in this context
17     };
18
19     let d = {
20         #![allow(warnings)]
21         let e = (#![allow(warnings)] 1, 2);
22         //~^ ERROR an inner attribute is not permitted in this context
23         e
24     };
25
26     let e = [#![allow(warnings)] 1, 2];
27     //~^ ERROR an inner attribute is not permitted in this context
28
29     let f = [#![allow(warnings)] 1; 0];
30     //~^ ERROR an inner attribute is not permitted in this context
31
32     let g = match true { #![allow(warnings)] _ => {} };
33
34
35     struct MyStruct { field: u8 }
36     let h = MyStruct { #![allow(warnings)] field: 0 };
37     //~^ ERROR an inner attribute is not permitted in this context
38 }