Skip to content

Commit 4e4beb7

Browse files
committed
Use more minimized test.
1 parent a7f6095 commit 4e4beb7

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

tests/ui/impl-trait/in-trait/late-bound-in-object-assocty.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Test for issue #132429
22
//@compile-flags: -Zunstable-options --edition=2024
3+
//@check-pass
34

4-
trait ThreeCellFragment {
5-
fn ext_cells<'a>(
6-
&'a self,
7-
) -> dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a {
8-
//~^ ERROR mismatched types
9-
//~| ERROR return type cannot have an unboxed trait object
5+
use std::future::Future;
6+
7+
trait Test {
8+
fn foo<'a>(&'a self) -> Box<dyn Future<Output = impl IntoIterator<Item = u32>>> {
9+
Box::new(async { [] })
1010
}
1111
}
1212

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +0,0 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/late-bound-in-object-assocty.rs:7:80
3-
|
4-
LL | ) -> dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a {
5-
| ________________________________________________________________________________^
6-
LL | |
7-
LL | |
8-
LL | | }
9-
| |_____^ expected `dyn Future`, found `()`
10-
|
11-
= note: expected trait object `(dyn Future<Output = _> + 'a)`
12-
found unit type `()`
13-
14-
error[E0746]: return type cannot have an unboxed trait object
15-
--> $DIR/late-bound-in-object-assocty.rs:7:10
16-
|
17-
LL | ) -> dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a {
18-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
19-
|
20-
help: consider returning an `impl Trait` instead of a `dyn Trait`
21-
|
22-
LL | ) -> impl core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a {
23-
| ~~~~
24-
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
25-
|
26-
LL | ) -> Box<dyn core::future::Future<Output = impl IntoIterator<Item = u32>> + 'a> {
27-
| ++++ +
28-
29-
error: aborting due to 2 previous errors
30-
31-
Some errors have detailed explanations: E0308, E0746.
32-
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)