File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 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. So we error out.
21+ fn foo ( ) -> impl Trait < Assoc = impl Send > {
22+ //~^ ERROR `impl Send: Duh` is not satisfied
23+ //~| ERROR `impl Send: Duh` is not satisfied
24+ || 42
25+ }
26+
27+ fn main ( ) {
28+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: the trait bound `impl Send: Duh` is not satisfied
2+ --> $DIR/nested-return-type2.rs:21:13
3+ |
4+ LL | fn foo() -> impl Trait<Assoc = impl Send> {
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `impl Send`
6+ |
7+ note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:24:5: 24:10]`
8+ --> $DIR/nested-return-type2.rs:12:31
9+ |
10+ LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
11+ | ^^^^^ ^
12+
13+ error[E0277]: the trait bound `impl Send: Duh` is not satisfied
14+ --> $DIR/nested-return-type2.rs:21:43
15+ |
16+ LL | fn foo() -> impl Trait<Assoc = impl Send> {
17+ | ___________________________________________^
18+ LL | |
19+ LL | |
20+ LL | | || 42
21+ LL | | }
22+ | |_^ the trait `Duh` is not implemented for `impl Send`
23+ |
24+ note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:24:5: 24:10]`
25+ --> $DIR/nested-return-type2.rs:12:31
26+ |
27+ LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
28+ | ^^^^^ ^
29+
30+ error: aborting due to 2 previous errors
31+
32+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments