]> git.lizzy.rs Git - rust.git/blob - tests/ui/parser/assoc-static-syntactic-fail.rs
Rollup merge of #106978 - mejrs:mir_build3, r=davidtwco
[rust.git] / tests / ui / parser / assoc-static-syntactic-fail.rs
1 // Syntactically, we do allow e.g., `static X: u8 = 0;` as an associated item.
2
3 fn main() {}
4
5 #[cfg(FALSE)]
6 impl S {
7     static IA: u8 = 0; //~ ERROR associated `static` items are not allowed
8     static IB: u8; //~ ERROR associated `static` items are not allowed
9     default static IC: u8 = 0; //~ ERROR associated `static` items are not allowed
10     //~^ ERROR a static item cannot be `default`
11     pub(crate) default static ID: u8; //~ ERROR associated `static` items are not allowed
12     //~^ ERROR a static item cannot be `default`
13 }
14
15 #[cfg(FALSE)]
16 trait T {
17     static TA: u8 = 0; //~ ERROR associated `static` items are not allowed
18     static TB: u8; //~ ERROR associated `static` items are not allowed
19     default static TC: u8 = 0; //~ ERROR associated `static` items are not allowed
20     //~^ ERROR a static item cannot be `default`
21     pub(crate) default static TD: u8; //~ ERROR associated `static` items are not allowed
22     //~^ ERROR a static item cannot be `default`
23 }
24
25 #[cfg(FALSE)]
26 impl T for S {
27     static TA: u8 = 0; //~ ERROR associated `static` items are not allowed
28     static TB: u8; //~ ERROR associated `static` items are not allowed
29     default static TC: u8 = 0; //~ ERROR associated `static` items are not allowed
30     //~^ ERROR a static item cannot be `default`
31     pub default static TD: u8; //~ ERROR associated `static` items are not allowed
32     //~^ ERROR a static item cannot be `default`
33 }