forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#117389 - oli-obk:gen_fn, r=compiler-errors
Some diagnostics improvements of `gen` blocks These are leftovers from rust-lang#116447
- Loading branch information
Showing
9 changed files
with
48 additions
and
10 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
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,25 @@ | ||
//compile-flags: --edition 2024 -Zunstable-options | ||
// run-pass | ||
#![feature(gen_blocks)] | ||
|
||
fn main() { | ||
let mut iter = gen { | ||
yield 42; | ||
panic!("foo"); | ||
yield 69; //~ WARN: unreachable statement | ||
}; | ||
assert_eq!(iter.next(), Some(42)); | ||
let mut tmp = std::panic::AssertUnwindSafe(&mut iter); | ||
match std::panic::catch_unwind(move || tmp.next()) { | ||
Ok(_) => unreachable!(), | ||
Err(err) => assert_eq!(*err.downcast::<&'static str>().unwrap(), "foo"), | ||
} | ||
|
||
match std::panic::catch_unwind(move || iter.next()) { | ||
Ok(_) => unreachable!(), | ||
Err(err) => assert_eq!( | ||
*err.downcast::<&'static str>().unwrap(), | ||
"`gen fn` should just keep returning `None` after panicking", | ||
), | ||
} | ||
} |
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,12 @@ | ||
warning: unreachable statement | ||
--> $DIR/gen_block_panic.rs:9:9 | ||
| | ||
LL | panic!("foo"); | ||
| ------------- any code following this expression is unreachable | ||
LL | yield 69; | ||
| ^^^^^^^^^ unreachable statement | ||
| | ||
= note: `#[warn(unreachable_code)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,10 @@ | ||
error: `gen` blocks are not yet implemented | ||
error: `gen` functions are not yet implemented | ||
--> $DIR/gen_fn.rs:4:1 | ||
| | ||
LL | gen fn foo() {} | ||
| ^^^ | ||
| | ||
= help: only the keyword is reserved for now | ||
= help: for now you can use `gen {}` blocks and return `impl Iterator` instead | ||
|
||
error: aborting due to previous error | ||
|
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