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