]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/nested-return-type2-tait3.rs
Auto merge of #95604 - nbdd0121:used2, r=petrochenkov
[rust.git] / src / test / ui / impl-trait / nested-return-type2-tait3.rs
1 #![feature(type_alias_impl_trait)]
2
3 trait Duh {}
4
5 impl Duh for i32 {}
6
7 trait Trait {
8     type Assoc: Duh;
9 }
10
11 // the fact that `R` is the `::Output` projection on `F` causes
12 // an intermediate inference var to be generated which is then later
13 // compared against the actually found `Assoc` type.
14 impl<R: Duh, F: FnMut() -> R> Trait for F {
15     type Assoc = R;
16 }
17
18 type Traitable = impl Trait<Assoc = impl Send>;
19
20 // The `impl Send` here is then later compared against the inference var
21 // created, causing the inference var to be set to `impl Send` instead of
22 // the hidden type. We already have obligations registered on the inference
23 // var to make it uphold the `: Duh` bound on `Trait::Assoc`. The opaque
24 // type does not implement `Duh`, even if its hidden type does. So we error out.
25 fn foo() -> Traitable {
26     || 42
27     //~^ ERROR `impl Send: Duh` is not satisfied
28 }
29
30 fn main() {
31 }