Skip to content

MIR-borrowck: ICE during diagnostic search for assignment (unwrap of None) #45199

Closed
@pnkfelix

Description

@pnkfelix

PR #44806 added some code to search for the lexically first assignment in order to report an illegal assignment.

However, oddly enough, for some tests this search, which ends in an unwrap, is causing the compiler to ICE.

For example:

%  build/x86_64-apple-darwin/stage1/bin/rustc  -Z borrowck-mir \
     ../src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs
[...]
error[E0384]: re-assignment of immutable variable `val` (Mir)
  --> ../src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs:15:5
   |
15 |        for &x in &vector {
   |   _____^
   |  |_____|
   | ||
16 | ||         let cap = vector.capacity();
17 | ||         vector.extend(repeat(0));      //~ ERROR cannot borrow
18 | ||         vector[1] = 5;   //~ ERROR cannot borrow
19 | ||     }
   | ||     ^
   | ||_____|
   | |______re-assignment of immutable variable
   |        first assignment to `val`

error[E0384]: re-assignment of immutable variable `x` (Mir)
  --> ../src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs:15:10
   |
15 |     for &x in &vector {
   |          ^
   |          |
   |          re-assignment of immutable variable
   |          first assignment to `x`

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.22.0-dev running on x86_64-apple-darwin

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /Users/fklock/Dev/Mozilla/rust.git/src/libcore/option.rs:335:20

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsI-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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions