]>
Commit | Line | Data |
---|---|---|
e74abb32 XL |
1 | // In the cases below, the type is missing from the `const` and `static` items. |
2 | // | |
3 | // Here, we test that we: | |
4 | // | |
5 | // a) Perform parser recovery. | |
6 | // | |
7 | // b) Emit a diagnostic with the actual inferred type to RHS of `=` as the suggestion. | |
8 | ||
9 | fn main() {} | |
10 | ||
11 | // These will not reach typeck: | |
12 | ||
13 | #[cfg(FALSE)] | |
14 | const C2 = 42; | |
15 | //~^ ERROR missing type for `const` item | |
16 | //~| HELP provide a type for the item | |
f2b60f7d | 17 | //~| SUGGESTION : <type> |
e74abb32 XL |
18 | |
19 | #[cfg(FALSE)] | |
20 | static S2 = "abc"; | |
21 | //~^ ERROR missing type for `static` item | |
22 | //~| HELP provide a type for the item | |
f2b60f7d | 23 | //~| SUGGESTION : <type> |
e74abb32 XL |
24 | |
25 | #[cfg(FALSE)] | |
26 | static mut SM2 = "abc"; | |
27 | //~^ ERROR missing type for `static mut` item | |
28 | //~| HELP provide a type for the item | |
f2b60f7d | 29 | //~| SUGGESTION : <type> |
e74abb32 XL |
30 | |
31 | // These will, so the diagnostics should be stolen by typeck: | |
32 | ||
33 | const C = 42; | |
34 | //~^ ERROR missing type for `const` item | |
136023e0 | 35 | //~| HELP provide a type for the constant |
f2b60f7d | 36 | //~| SUGGESTION : i32 |
e74abb32 | 37 | |
ba9703b0 XL |
38 | const D = &&42; |
39 | //~^ ERROR missing type for `const` item | |
136023e0 | 40 | //~| HELP provide a type for the constant |
f2b60f7d | 41 | //~| SUGGESTION : &&i32 |
ba9703b0 | 42 | |
e74abb32 XL |
43 | static S = Vec::<String>::new(); |
44 | //~^ ERROR missing type for `static` item | |
136023e0 | 45 | //~| HELP provide a type for the static variable |
f2b60f7d | 46 | //~| SUGGESTION : Vec<String> |
e74abb32 XL |
47 | |
48 | static mut SM = "abc"; | |
49 | //~^ ERROR missing type for `static mut` item | |
136023e0 | 50 | //~| HELP provide a type for the static variable |
f2b60f7d | 51 | //~| SUGGESTION : &str |