-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out of the correct number of scopes in loops
We were incorrectly breaking out of one too many drop scopes when generating MIR for loops and breakable blocks, resulting in use after free and associated borrow checker warnings. This wasn't noticed because the scope that we're breaking out of twice is only used for temporaries that are created for adjustments applied to the loop. Since loops generally propagate coercions to the `break` expressions, the only case we see this is when the type of the loop is a smart pointer to a trait object.
- Loading branch information
1 parent
848e0a2
commit 1b7ffe5
Showing
5 changed files
with
52 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Regression test for #62312 | ||
|
||
// check-pass | ||
// edition:2018 | ||
|
||
#![feature(async_await)] | ||
|
||
async fn make_boxed_object() -> Box<dyn Send> { | ||
Box::new(()) as _ | ||
} | ||
|
||
async fn await_object() { | ||
let _ = make_boxed_object().await; | ||
} | ||
|
||
fn main() {} |
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,8 @@ | ||
// Regression test for #62312 | ||
// check-pass | ||
|
||
fn main() { | ||
let _ = loop { | ||
break Box::new(()) as Box<dyn Send>; | ||
}; | ||
} |