]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/object/with-self-in-projection-output-bad.rs
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
[rust.git] / tests / ui / traits / object / with-self-in-projection-output-bad.rs
1 // Regression test for #56288. Checks that if a supertrait defines an associated type
2 // projection that references `Self`, then that associated type must still be explicitly
3 // specified in the `dyn Trait` variant, since we don't know what `Self` is anymore.
4
5 trait Base {
6     type Output;
7 }
8
9 trait Helper: Base<Output=<Self as Helper>::Target> {
10     type Target;
11 }
12
13 impl Base for u32
14 {
15     type Output = i32;
16 }
17
18 impl Helper for u32
19 {
20     type Target = i32;
21 }
22
23 trait ConstI32 {
24     type Out;
25 }
26
27 impl<T: ?Sized> ConstI32 for T {
28     type Out = i32;
29 }
30
31 // Test that you still need to manually give a projection type if the Output type
32 // is normalizable.
33 trait NormalizableHelper:
34     Base<Output=<Self as ConstI32>::Out>
35 {
36     type Target;
37 }
38
39 impl NormalizableHelper for u32
40 {
41     type Target = i32;
42 }
43
44 fn main() {
45     let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32);
46     //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
47
48     let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
49     //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
50 }