|
| 1 | +error[E0271]: expected `{async [email protected]:9:9}` to be a closure that returns `Box<_>`, but it returns `{async closure body@$DIR/dont-suggest-boxing-async-closure-body.rs:9:23: 9:25}` |
| 2 | + --> $DIR/dont-suggest-boxing-async-closure-body.rs:9:9 |
| 3 | + | |
| 4 | +LL | foo(async move || {}); |
| 5 | + | --- ^^^^^^^^^^^^^^^^ expected `Box<_>`, found `async` closure body |
| 6 | + | | |
| 7 | + | required by a bound introduced by this call |
| 8 | + | |
| 9 | + = note: expected struct `Box<_>` |
| 10 | + found `async` closure body `{async closure body@$DIR/dont-suggest-boxing-async-closure-body.rs:9:23: 9:25}` |
| 11 | +note: required by a bound in `foo` |
| 12 | + --> $DIR/dont-suggest-boxing-async-closure-body.rs:4:31 |
| 13 | + | |
| 14 | +LL | fn foo<X>(x: impl FnOnce() -> Box<X>) {} |
| 15 | + | ^^^^^^ required by this bound in `foo` |
| 16 | + |
| 17 | +error[E0308]: mismatched types |
| 18 | + --> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 |
| 19 | + | |
| 20 | +LL | bar(async move || {}); |
| 21 | + | --- ^^^^^^^^^^^^^^^^ expected `Box<dyn FnOnce() -> _>`, found `{async [email protected]:11:9}` |
| 22 | + | | |
| 23 | + | arguments to this function are incorrect |
| 24 | + | |
| 25 | + = note: expected struct `Box<(dyn FnOnce() -> _ + 'static)>` |
| 26 | + found closure `{async closure@$DIR/dont-suggest-boxing-async-closure-body.rs:11:9: 11:22}` |
| 27 | + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html |
| 28 | +note: function defined here |
| 29 | + --> $DIR/dont-suggest-boxing-async-closure-body.rs:6:4 |
| 30 | + | |
| 31 | +LL | fn bar<X>(x: Box<dyn FnOnce() -> X>) {} |
| 32 | + | ^^^ ------------------------- |
| 33 | +help: store this in the heap by calling `Box::new` |
| 34 | + | |
| 35 | +LL | bar(Box::new(async move || {})); |
| 36 | + | +++++++++ + |
| 37 | + |
| 38 | +error: aborting due to 2 previous errors |
| 39 | + |
| 40 | +Some errors have detailed explanations: E0271, E0308. |
| 41 | +For more information about an error, try `rustc --explain E0271`. |
0 commit comments