Trying to break from a const block gives invalid help message · Issue #128604 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@cyrgani

Description

@cyrgani

Code

const _: () = const { break; };

Current output

error[E0268]: break outside of a loop or labeled block --> src/lib.rs:2:5 | 2 | break; | ^^^^^ cannot break outside of a loop or labeled block | help: consider labeling this block to be able to break within it | 1 ~ const _: () = const 'block: { 2 ~ break 'block; |

For more information about this error, try rustc --explain E0268.

Desired output

Help suggestion should be removed.

Rationale and extra context

The proposed syntax is invalid:

error: expected expression, found keyword const --> src/lib.rs:1:15 | 1 | const _: () = const 'block: { | ^^^^^ expected expression

Other cases

No response

Rust Version

rustc 1.80.0 (051478957 2024-07-21) binary: rustc commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9 commit-date: 2024-07-21 host: x86_64-unknown-linux-gnu release: 1.80.0 LLVM version: 18.1.7

Anything else?

No response