-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a previously unreachable UI test reachable
- Loading branch information
Showing
4 changed files
with
44 additions
and
36 deletions.
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
This file was deleted.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
tests/ui/issues/auxiliary/issue-111011.rs → ...dont-suggest-boxing-async-closure-body.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
//@ edition:2021 | ||
// issue: https://github.com/rust-lang/rust/issues/111011 | ||
|
||
fn foo<X>(x: impl FnOnce() -> Box<X>) {} | ||
// just to make sure async closures can still be suggested for boxing. | ||
fn bar<X>(x: Box<dyn FnOnce() -> X>) {} | ||
|
||
fn main() { | ||
foo(async move || {}); //~ ERROR mismatched types | ||
foo(async move || {}); | ||
//~^ ERROR expected `{async [email protected]:9:9}` to be a closure that returns `Box<_>` | ||
bar(async move || {}); //~ ERROR mismatched types | ||
} |
41 changes: 41 additions & 0 deletions
41
tests/ui/suggestions/dont-suggest-boxing-async-closure-body.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,41 @@ | ||
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}` | ||
--> $DIR/dont-suggest-boxing-async-closure-body.rs:9:9 | ||
| | ||
LL | foo(async move || {}); | ||
| --- ^^^^^^^^^^^^^^^^ expected `Box<_>`, found `async` closure body | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= note: expected struct `Box<_>` | ||
found `async` closure body `{async closure body@$DIR/dont-suggest-boxing-async-closure-body.rs:9:23: 9:25}` | ||
note: required by a bound in `foo` | ||
--> $DIR/dont-suggest-boxing-async-closure-body.rs:4:31 | ||
| | ||
LL | fn foo<X>(x: impl FnOnce() -> Box<X>) {} | ||
| ^^^^^^ required by this bound in `foo` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 | ||
| | ||
LL | bar(async move || {}); | ||
| --- ^^^^^^^^^^^^^^^^ expected `Box<dyn FnOnce() -> _>`, found `{async [email protected]:11:9}` | ||
| | | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected struct `Box<(dyn FnOnce() -> _ + 'static)>` | ||
found closure `{async closure@$DIR/dont-suggest-boxing-async-closure-body.rs:11:9: 11:22}` | ||
= 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 | ||
note: function defined here | ||
--> $DIR/dont-suggest-boxing-async-closure-body.rs:6:4 | ||
| | ||
LL | fn bar<X>(x: Box<dyn FnOnce() -> X>) {} | ||
| ^^^ ------------------------- | ||
help: store this in the heap by calling `Box::new` | ||
| | ||
LL | bar(Box::new(async move || {})); | ||
| +++++++++ + | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0271, E0308. | ||
For more information about an error, try `rustc --explain E0271`. |