-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #58902 - matthewjasper:generator-cleanup-blocks, r=davi…
…dtwco Fixes for the generator transform * Moves cleanup annotations in pretty printed MIR so that they can be tested * Correctly determines which drops are in cleanup blocks when elaborating generator drops * Use the correct state for poisoning a generator Closes #58892
- Loading branch information
Showing
13 changed files
with
129 additions
and
60 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
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,43 @@ | ||
#![feature(generators, generator_trait)] | ||
|
||
// Regression test for #58892, generator drop shims should not have blocks | ||
// spuriously marked as cleanup | ||
|
||
fn main() { | ||
let gen = || { | ||
yield; | ||
}; | ||
} | ||
|
||
// END RUST SOURCE | ||
|
||
// START rustc.main-{{closure}}.generator_drop.0.mir | ||
// bb0: { | ||
// switchInt(((*_1).0: u32)) -> [0u32: bb4, 3u32: bb7, otherwise: bb8]; | ||
// } | ||
// bb1: { | ||
// goto -> bb5; | ||
// } | ||
// bb2: { | ||
// return; | ||
// } | ||
// bb3: { | ||
// return; | ||
// } | ||
// bb4: { | ||
// goto -> bb6; | ||
// } | ||
// bb5: { | ||
// goto -> bb2; | ||
// } | ||
// bb6: { | ||
// goto -> bb3; | ||
// } | ||
// bb7: { | ||
// StorageLive(_3); | ||
// goto -> bb1; | ||
// } | ||
// bb8: { | ||
// return; | ||
// } | ||
// END rustc.main-{{closure}}.generator_drop.0.mir |
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
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,22 @@ | ||
// error-pattern:generator resumed after panicking | ||
|
||
// Test that we get the correct message for resuming a panicked generator. | ||
|
||
#![feature(generators, generator_trait)] | ||
|
||
use std::{ | ||
ops::Generator, | ||
pin::Pin, | ||
panic, | ||
}; | ||
|
||
fn main() { | ||
let mut g = || { | ||
panic!(); | ||
yield; | ||
}; | ||
panic::catch_unwind(panic::AssertUnwindSafe(|| { | ||
let x = Pin::new(&mut g).resume(); | ||
})); | ||
Pin::new(&mut g).resume(); | ||
} |