]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-project-from-hrtb-in-trait-method.fixed
Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum
[rust.git] / src / test / ui / associated-types / associated-types-project-from-hrtb-in-trait-method.fixed
1 #![allow(dead_code)]
2 // run-rustfix
3 // Check projection of an associated type out of a higher-ranked trait-bound
4 // in the context of a method definition in a trait.
5
6 pub trait Foo<T> {
7     type A;
8
9     fn get(&self, t: T) -> Self::A;
10 }
11
12 trait SomeTrait<I : for<'x> Foo<&'x isize>> {
13     fn some_method(&self, arg: <I as Foo<&isize>>::A);
14     //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
15 }
16
17 trait AnotherTrait<I : for<'x> Foo<&'x isize>> {
18     fn some_method(&self, arg: <I as Foo<&isize>>::A);
19 }
20
21 trait YetAnotherTrait<I : for<'x> Foo<&'x isize>> {
22     fn some_method<'a>(&self, arg: <I as Foo<&'a isize>>::A);
23 }
24
25 trait Banana<'a> {
26     type Assoc: Default;
27 }
28
29 struct Peach<X>(std::marker::PhantomData<X>);
30
31 impl<X: for<'a> Banana<'a>> Peach<X> {
32     fn mango(&self) -> <X as Banana<'_>>::Assoc {
33     //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
34         Default::default()
35     }
36 }
37
38 pub fn main() {}