Closed
Description
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