]> git.proxmox.com Git - rustc.git/blob - src/test/ui/parser/assoc-static-semantic-fail.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / parser / assoc-static-semantic-fail.rs
1 // Semantically, we do not allow e.g., `static X: u8 = 0;` as an associated item.
2
3 #![feature(specialization)]
4 //~^ WARN the feature `specialization` is incomplete
5
6 fn main() {}
7
8 struct S;
9 impl S {
10 static IA: u8 = 0;
11 //~^ ERROR associated `static` items are not allowed
12 static IB: u8;
13 //~^ ERROR associated `static` items are not allowed
14 //~| ERROR associated constant in `impl` without body
15 default static IC: u8 = 0;
16 //~^ ERROR associated `static` items are not allowed
17 //~| ERROR a static item cannot be `default`
18 pub(crate) default static ID: u8;
19 //~^ ERROR associated `static` items are not allowed
20 //~| ERROR associated constant in `impl` without body
21 //~| ERROR a static item cannot be `default`
22 }
23
24 trait T {
25 static TA: u8 = 0;
26 //~^ ERROR associated `static` items are not allowed
27 static TB: u8;
28 //~^ ERROR associated `static` items are not allowed
29 default static TC: u8 = 0;
30 //~^ ERROR associated `static` items are not allowed
31 //~| ERROR a static item cannot be `default`
32 pub(crate) default static TD: u8;
33 //~^ ERROR associated `static` items are not allowed
34 //~| ERROR unnecessary visibility qualifier
35 //~| ERROR a static item cannot be `default`
36 }
37
38 impl T for S {
39 static TA: u8 = 0;
40 //~^ ERROR associated `static` items are not allowed
41 static TB: u8;
42 //~^ ERROR associated `static` items are not allowed
43 //~| ERROR associated constant in `impl` without body
44 default static TC: u8 = 0;
45 //~^ ERROR associated `static` items are not allowed
46 //~| ERROR a static item cannot be `default`
47 pub default static TD: u8;
48 //~^ ERROR associated `static` items are not allowed
49 //~| ERROR associated constant in `impl` without body
50 //~| ERROR unnecessary visibility qualifier
51 //~| ERROR a static item cannot be `default`
52 }