]> git.proxmox.com Git - rustc.git/blame - src/test/ui/suggestions/const-no-type.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / test / ui / suggestions / const-no-type.rs
CommitLineData
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
9fn main() {}
10
11// These will not reach typeck:
12
13#[cfg(FALSE)]
14const C2 = 42;
15//~^ ERROR missing type for `const` item
16//~| HELP provide a type for the item
17//~| SUGGESTION C2: <type>
18
19#[cfg(FALSE)]
20static S2 = "abc";
21//~^ ERROR missing type for `static` item
22//~| HELP provide a type for the item
23//~| SUGGESTION S2: <type>
24
25#[cfg(FALSE)]
26static mut SM2 = "abc";
27//~^ ERROR missing type for `static mut` item
28//~| HELP provide a type for the item
29//~| SUGGESTION SM2: <type>
30
31// These will, so the diagnostics should be stolen by typeck:
32
33const C = 42;
34//~^ ERROR missing type for `const` item
35//~| HELP provide a type for the item
36//~| SUGGESTION C: i32
37
ba9703b0
XL
38const D = &&42;
39//~^ ERROR missing type for `const` item
40//~| HELP provide a type for the item
41//~| SUGGESTION D: &&i32
42
e74abb32
XL
43static S = Vec::<String>::new();
44//~^ ERROR missing type for `static` item
45//~| HELP provide a type for the item
46//~| SUGGESTION S: std::vec::Vec<std::string::String>
47
48static mut SM = "abc";
49//~^ ERROR missing type for `static mut` item
50//~| HELP provide a type for the item
ba9703b0 51//~| SUGGESTION &str