forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#123834 - compiler-errors:async-closure-with-tainted-body, r=oli-obk Don't do coroutine-closure-specific upvar analysis if tainted by errors See the comment Fixes rust-lang#123821 Fixes rust-lang#123818
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 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 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
23 changes: 23 additions & 0 deletions
23
tests/ui/async-await/async-closures/dont-ice-when-body-tainted-by-errors.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,23 @@ | ||
//@ edition: 2021 | ||
|
||
#![feature(async_closure)] | ||
|
||
struct DropMe; | ||
|
||
trait Impossible {} | ||
fn trait_error<T: Impossible>() {} | ||
|
||
pub fn main() { | ||
let b = DropMe; | ||
let async_closure = async move || { | ||
// Type error here taints the environment. This causes us to fallback all | ||
// variables to `Error`. This means that when we compute the upvars for the | ||
// *outer* coroutine-closure, we don't actually see any upvars since `MemCategorization` | ||
// and `ExprUseVisitor`` will bail early when it sees error. This means | ||
// that our underlying assumption that the parent and child captures are | ||
// compatible ends up being broken, previously leading to an ICE. | ||
trait_error::<()>(); | ||
//~^ ERROR the trait bound `(): Impossible` is not satisfied | ||
let _b = b; | ||
}; | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/ui/async-await/async-closures/dont-ice-when-body-tainted-by-errors.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,20 @@ | ||
error[E0277]: the trait bound `(): Impossible` is not satisfied | ||
--> $DIR/dont-ice-when-body-tainted-by-errors.rs:19:23 | ||
| | ||
LL | trait_error::<()>(); | ||
| ^^ the trait `Impossible` is not implemented for `()` | ||
| | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/dont-ice-when-body-tainted-by-errors.rs:7:1 | ||
| | ||
LL | trait Impossible {} | ||
| ^^^^^^^^^^^^^^^^ | ||
note: required by a bound in `trait_error` | ||
--> $DIR/dont-ice-when-body-tainted-by-errors.rs:8:19 | ||
| | ||
LL | fn trait_error<T: Impossible>() {} | ||
| ^^^^^^^^^^ required by this bound in `trait_error` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |