Code
#![feature(try_blocks)]
fn main() {
try {
break;
None?;
};
}
Current output
error[E0268]: `break` outside of a loop or labeled block
--> thingy2.rs:5:9
|
5 | break;
| ^^^^^ cannot `break` outside of a loop or labeled block
|
help: consider labeling this block to be able to break within it
|
4 ~ try 'block: {
5 ~ break 'block;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0268`.
Desired output
help: consider labeling this block to be able to break within it
|
4 ~ 'block: try {
5 ~ break 'block;
|
If/When it's valid, OR
help: consider labeling this block to be able to break within it
|
4 ~ 'block: { try {
5 ~ break 'block;
6 | None?;
7 ~ } };
|
Rationale and extra context
rustc should not be suggesting invalid syntax. Also, I'm not sure labels can be placed on try blocks directly right now, and the label should probably be outside of the try keyword rather than the block itself (matching stuff like loop)
Other cases
Rust Version
rustc 1.99.0-nightly (3d6c19bb9 2026-08-11)
binary: rustc
commit-hash: 3d6c19bb9ab4798ecfb2ee943df01a811720fc27
commit-date: 2026-08-11
host: aarch64-apple-darwin
release: 1.99.0-nightly
LLVM version: 23.1.0
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
rustc should not be suggesting invalid syntax. Also, I'm not sure labels can be placed on try blocks directly right now, and the label should probably be outside of the try keyword rather than the block itself (matching stuff like
loop)Other cases
Rust Version
Anything else?
No response