Skip to content

Commit 96a267e

Browse files
authored
Rollup merge of #92389 - chordtoll:test-92015, r=Mark-Simulacrum
Regression test for borrowck ICE #92015 This issue has come up a few times. Creating a regression test. Closes #92015.
2 parents fb87e7c + 57ac317 commit 96a267e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/test/ui/borrowck/issue-92015.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for #92105.
2+
// ICE when mutating immutable reference from last statement of a block.
3+
4+
fn main() {
5+
let foo = Some(&0).unwrap();
6+
*foo = 1; //~ ERROR cannot assign
7+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
2+
--> $DIR/issue-92015.rs:6:5
3+
|
4+
LL | let foo = Some(&0).unwrap();
5+
| --- help: consider changing this to be a mutable reference: `&mut i32`
6+
LL | *foo = 1;
7+
| ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0594`.

0 commit comments

Comments
 (0)