]> git.lizzy.rs Git - rust.git/blob - tests/ui/did_you_mean/bad-assoc-ty.rs
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
[rust.git] / tests / ui / did_you_mean / bad-assoc-ty.rs
1 type A = [u8; 4]::AssocTy;
2 //~^ ERROR missing angle brackets in associated item path
3 //~| ERROR ambiguous associated type
4
5 type B = [u8]::AssocTy;
6 //~^ ERROR missing angle brackets in associated item path
7 //~| ERROR ambiguous associated type
8
9 type C = (u8)::AssocTy;
10 //~^ ERROR missing angle brackets in associated item path
11 //~| ERROR ambiguous associated type
12
13 type D = (u8, u8)::AssocTy;
14 //~^ ERROR missing angle brackets in associated item path
15 //~| ERROR ambiguous associated type
16
17 type E = _::AssocTy;
18 //~^ ERROR missing angle brackets in associated item path
19 //~| ERROR the placeholder `_` is not allowed within types on item signatures for type aliases
20
21 type F = &'static (u8)::AssocTy;
22 //~^ ERROR missing angle brackets in associated item path
23 //~| ERROR ambiguous associated type
24
25 // Qualified paths cannot appear in bounds, so the recovery
26 // should apply to the whole sum and not `(Send)`.
27 type G = dyn 'static + (Send)::AssocTy;
28 //~^ ERROR missing angle brackets in associated item path
29 //~| ERROR ambiguous associated type
30
31 // This is actually a legal path with fn-like generic arguments in the middle!
32 // Recovery should not apply in this context.
33 type H = Fn(u8) -> (u8)::Output;
34 //~^ ERROR ambiguous associated type
35 //~| WARN trait objects without an explicit `dyn` are deprecated
36 //~| WARN this is accepted in the current edition
37
38 macro_rules! ty {
39     ($ty: ty) => ($ty::AssocTy);
40     //~^ ERROR missing angle brackets in associated item path
41     //~| ERROR ambiguous associated type
42     () => (u8);
43 }
44
45 type J = ty!(u8);
46 type I = ty!()::AssocTy;
47 //~^ ERROR missing angle brackets in associated item path
48 //~| ERROR ambiguous associated type
49
50 trait K<A, B> {}
51 fn foo<X: K<_, _>>(x: X) {}
52 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
53
54 fn bar<F>(_: F) where F: Fn() -> _ {}
55 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
56
57 fn baz<F: Fn() -> _>(_: F) {}
58 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
59
60 struct L<F>(F) where F: Fn() -> _;
61 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs
62 struct M<F> where F: Fn() -> _ {
63 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs
64     a: F,
65 }
66 enum N<F> where F: Fn() -> _ {
67 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for enums
68     Foo(F),
69 }
70
71 union O<F> where F: Fn() -> _ {
72 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for unions
73     foo: F,
74 }
75
76 trait P<F> where F: Fn() -> _ {
77 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for traits
78 }
79
80 trait Q {
81     fn foo<F>(_: F) where F: Fn() -> _ {}
82     //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
83 }
84
85 fn main() {}