Skip to content

Commit 69d1917

Browse files
Add test demonstrating no more ICE
1 parent 718a3b1 commit 69d1917

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct TestClient;
2+
3+
impl TestClient {
4+
fn get_inner_ref(&self) -> &Vec<usize> {
5+
todo!()
6+
}
7+
}
8+
9+
fn main() {
10+
let client = TestClient;
11+
let inner = client.get_inner_ref();
12+
//~^ HELP consider changing this to be a mutable reference
13+
inner.clear();
14+
//~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596]
15+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference
2+
--> $DIR/issue-91206.rs:13:5
3+
|
4+
LL | let inner = client.get_inner_ref();
5+
| ----- help: consider changing this to be a mutable reference: `&mut Vec<usize>`
6+
LL |
7+
LL | inner.clear();
8+
| ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0596`.

0 commit comments

Comments
 (0)