]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/bound-normalization-fail.rs
Rollup merge of #106799 - scottmcm:remove-unused-generics, r=cuviper
[rust.git] / tests / ui / impl-trait / bound-normalization-fail.rs
1 // edition:2018
2
3 // See issue 60414
4
5 // Reduction to `impl Trait`
6
7 struct Foo<T>(T);
8
9 trait FooLike {
10     type Output;
11 }
12
13 impl<T> FooLike for Foo<T> {
14     type Output = T;
15 }
16
17 mod impl_trait {
18     use super::*;
19
20     trait Trait {
21         type Assoc;
22     }
23
24     /// `T::Assoc` can't be normalized any further here.
25     fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> {
26         //~^ ERROR: type mismatch
27         Foo(())
28     }
29 }
30
31 // Same with lifetimes in the trait
32
33 mod lifetimes {
34     use super::*;
35
36     trait Trait<'a> {
37         type Assoc;
38     }
39
40     /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further.
41     fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
42         //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
43         //~| ERROR: type mismatch
44         Foo(())
45     }
46 }
47
48 fn main() {}