]> git.proxmox.com Git - rustc.git/blame - src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / src / test / ui / traits / trait-object-with-self-in-projection-output-bad.rs
CommitLineData
69743fb6
XL
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
5trait Base {
6 type Output;
7}
8
9trait Helper: Base<Output=<Self as Helper>::Target> {
10 type Target;
11}
12
13impl Base for u32
14{
15 type Output = i32;
16}
17
18impl Helper for u32
19{
20 type Target = i32;
21}
22
23trait ConstI32 {
24 type Out;
25}
26
27impl<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.
33trait NormalizableHelper:
34 Base<Output=<Self as ConstI32>::Out>
35{
36 type Target;
37}
38
39impl NormalizableHelper for u32
40{
41 type Target = i32;
42}
43
44fn main() {
45 let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32);
dfeec247 46 //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
69743fb6
XL
47
48 let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
dfeec247 49 //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
69743fb6 50}