diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-02-22 15:38:58 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-03-28 17:02:08 +0000 |
| commit | 4f6e27d4cf783e4a10326b16596e444dc325cf3d (patch) | |
| tree | 7c63bb3d21d89a8a39173524b83440771a4b9b23 | |
| parent | 3cce66c54434d0e5ef960dd40500f1f45d9158e5 (diff) | |
| download | rust-4f6e27d4cf783e4a10326b16596e444dc325cf3d.tar.gz rust-4f6e27d4cf783e4a10326b16596e444dc325cf3d.zip | |
Add regression test
| -rw-r--r-- | src/test/ui/impl-trait/nested-return-type2.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/nested-return-type2.stderr | 32 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/nested-return-type2.rs b/src/test/ui/impl-trait/nested-return-type2.rs new file mode 100644 index 00000000000..77a395afba7 --- /dev/null +++ b/src/test/ui/impl-trait/nested-return-type2.rs @@ -0,0 +1,28 @@ +trait Duh {} + +impl Duh for i32 {} + +trait Trait { + type Assoc: Duh; +} + +// the fact that `R` is the `::Output` projection on `F` causes +// an intermediate inference var to be generated which is then later +// compared against the actually found `Assoc` type. +impl<R: Duh, F: FnMut() -> R> Trait for F { + type Assoc = R; +} + +// The `impl Send` here is then later compared against the inference var +// created, causing the inference var to be set to `impl Send` instead of +// the hidden type. We already have obligations registered on the inference +// var to make it uphold the `: Duh` bound on `Trait::Assoc`. The opaque +// type does not implement `Duh`, even if its hidden type does. So we error out. +fn foo() -> impl Trait<Assoc = impl Send> { + //~^ ERROR `impl Send: Duh` is not satisfied + //~| ERROR `impl Send: Duh` is not satisfied + || 42 +} + +fn main() { +} diff --git a/src/test/ui/impl-trait/nested-return-type2.stderr b/src/test/ui/impl-trait/nested-return-type2.stderr new file mode 100644 index 00000000000..be6c19795ae --- /dev/null +++ b/src/test/ui/impl-trait/nested-return-type2.stderr @@ -0,0 +1,32 @@ +error[E0277]: the trait bound `impl Send: Duh` is not satisfied + --> $DIR/nested-return-type2.rs:21:13 + | +LL | fn foo() -> impl Trait<Assoc = impl Send> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `impl Send` + | +note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:24:5: 24:10]` + --> $DIR/nested-return-type2.rs:12:31 + | +LL | impl<R: Duh, F: FnMut() -> R> Trait for F { + | ^^^^^ ^ + +error[E0277]: the trait bound `impl Send: Duh` is not satisfied + --> $DIR/nested-return-type2.rs:21:43 + | +LL | fn foo() -> impl Trait<Assoc = impl Send> { + | ___________________________________________^ +LL | | +LL | | +LL | | || 42 +LL | | } + | |_^ the trait `Duh` is not implemented for `impl Send` + | +note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:24:5: 24:10]` + --> $DIR/nested-return-type2.rs:12:31 + | +LL | impl<R: Duh, F: FnMut() -> R> Trait for F { + | ^^^^^ ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. |
