forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account for late-bound depth when capturing all opaque lifetimes.
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
32 changes: 32 additions & 0 deletions
32
tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |