diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2024-11-01 17:03:17 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2024-11-01 17:03:17 +0000 |
| commit | 45d44650280951c22ba625d0000d36216babb397 (patch) | |
| tree | 2224775bf9cd9040b413c055a08baa052fb5f405 /tests/ui/impl-trait | |
| parent | 145f9cf95de1fbde3fa11e98461310e0373253e6 (diff) | |
| download | rust-45d44650280951c22ba625d0000d36216babb397.tar.gz rust-45d44650280951c22ba625d0000d36216babb397.zip | |
Account for late-bound depth when capturing all opaque lifetimes.
Diffstat (limited to 'tests/ui/impl-trait')
| -rw-r--r-- | tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.rs | 13 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.stderr | 32 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.rs b/tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.rs new file mode 100644 index 00000000000..9d1bb22434c --- /dev/null +++ b/tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.rs @@ -0,0 +1,13 @@ +// Test for issue #132429 +//@compile-flags: -Zunstable-options --edition=2024 + +trait ThreeCellFragment { + fn ext_cells<'a>( + &'a self, + ) -> dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a { + //~^ ERROR mismatched types + //~| ERROR return type cannot have an unboxed trait object + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.stderr b/tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.stderr new file mode 100644 index 00000000000..f771b802af9 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/late-bound-in-object-assocty.rs:7:80 + | +LL | ) -> dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a { + | ________________________________________________________________________________^ +LL | | +LL | | +LL | | } + | |_____^ expected `dyn Future`, found `()` + | + = note: expected trait object `(dyn Future<Output = _> + 'a)` + found unit type `()` + +error[E0746]: return type cannot have an unboxed trait object + --> $DIR/late-bound-in-object-assocty.rs:7:10 + | +LL | ) -> dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | ) -> impl core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | ) -> Box<dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a> { + | ++++ + + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0746. +For more information about an error, try `rustc --explain E0308`. |
