Skip to content

ICE: const eval: expected type differs from actual type. () vs i32 #114529

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

fn main() {
    [(); {
        while true {
            break 2;
        }
        201
    }];
}

Meta

rustc --version --verbose:

9565b68b741fd0466b3af075139e819e7d73ee38

Error output

warning: denote infinite loops with `loop { ... }`
 --> ./847B579CB9D548BFF192F0D147D9628805BF639194C504BD0CB09AF68207F69F.rs:3:9
  |
3 |         while true {
  |         ^^^^^^^^^^ help: use `loop`
  |
  = note: `#[warn(while_true)]` on by default

error[E0571]: `break` with value from a `while` loop
 --> ./847B579CB9D548BFF192F0D147D9628805BF639194C504BD0CB09AF68207F69F.rs:4:13
  |
3 |         while true {
  |         ---------- you can't `break` with a value in a `while` loop
4 |             break 2;
  |             ^^^^^^^ can only break with a value inside `loop` or breakable block
  |
help: use `break` on its own without a value inside this `while` loop
  |
4 |             break;
  |             ~~~~~

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions