]> git.proxmox.com Git - rustc.git/blob - src/test/ui/suggestions/unnamable-types.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / suggestions / unnamable-types.rs
1 // Test that we do not suggest to add type annotations for unnamable types.
2
3 #![crate_type="lib"]
4 #![feature(generators)]
5
6 const A = 5;
7 //~^ ERROR: missing type for `const` item
8 //~| HELP: provide a type for the constant
9
10 static B: _ = "abc";
11 //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for static variables
12 //~| NOTE: not allowed in type signatures
13 //~| HELP: replace with the correct type
14
15
16 // FIXME: this should also suggest a function pointer, as the closure is non-capturing
17 const C: _ = || 42;
18 //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for constants
19 //~| NOTE: not allowed in type signatures
20 //~| NOTE: however, the inferred type
21
22 struct S<T> { t: T }
23 const D = S { t: { let i = 0; move || -> i32 { i } } };
24 //~^ ERROR: missing type for `const` item
25 //~| NOTE: however, the inferred type
26
27
28 fn foo() -> i32 { 42 }
29 const E = foo;
30 //~^ ERROR: missing type for `const` item
31 //~| HELP: provide a type for the constant
32 const F = S { t: foo };
33 //~^ ERROR: missing type for `const` item
34 //~| HELP: provide a type for the constant
35
36
37 const G = || -> i32 { yield 0; return 1; };
38 //~^ ERROR: missing type for `const` item
39 //~| NOTE: however, the inferred type