-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Labels
Description
Wrong Error when loop keyword used inside of closure but outside of loop - E0267
- You can view the same on
godbolt
I tried this code from E0267
:
// https://doc.rust-lang.org/error_codes/E0267.html
#![allow(unused)]
fn main() {
let w = || { break; }; // error: `break` inside of a closure
}
I expected to see this happen:
- Give error like rustc i.e.,
➜ mahad-testsuite rustc E0267.rs
error[E0267]: `break` inside of a closure
--> E0267.rs:4:14
|
4 | let w = || { break; }; // error: `break` inside of a closure
| -- ^^^^^ cannot `break` inside of a closure
| |
| enclosing closure
error: aborting due to previous error
For more information about this error, try `rustc --explain E0267`.
Instead, this happened:
- It gives different error i.e., Loop Keyword used outside of loop -
E0268
[E0268] break or continue used outside of loop #2453
➜ mahad-testsuite ../gccrs-build/gcc/crab1 E0267.rs
E0267.rs:4:14: error: ‘break’ outside of a loop or labeled block [E0268]
4 | let w = || { break; }; // error: `break` inside of a closure
| ^~~~~
E0267.rs:4:9: fatal error: unable to find lang item: ‘fn_once’
4 | let w = || { break; }; // error: `break` inside of a closure
| ^~
compilation terminated.
Meta
- What version of Rust GCC were you using, git sha b8268b6.
- gccrs (Compiler-Explorer-Build-gcc-866512cbc09bc883ef844b2b6cb70a72335756a7-binutils-2.40) 13.0.1 20230417 (experimental)