File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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`.
You can’t perform that action at this time.
0 commit comments