File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ // check-pass
2+
3+ // mir borrowck previously incorrectly set `tainted_by_errors`
4+ // when buffering lints, which resulted in ICE later on,
5+ // see #94502.
6+
7+ struct Repro ;
8+ impl Repro {
9+ fn get ( & self ) -> & i32 {
10+ & 3
11+ }
12+
13+ fn insert ( & mut self , _: i32 ) { }
14+ }
15+
16+ fn main ( ) {
17+ let x = & 0 ;
18+ let mut conflict = Repro ;
19+ let prev = conflict. get ( ) ;
20+ conflict. insert ( * prev + * x) ;
21+ //~^ WARN cannot borrow `conflict` as mutable because it is also borrowed as immutable
22+ //~| WARN this borrowing pattern was not meant to be accepted
23+ }
Original file line number Diff line number Diff line change 1+ warning: cannot borrow `conflict` as mutable because it is also borrowed as immutable
2+ --> $DIR/lint-no-err.rs:20:5
3+ |
4+ LL | let prev = conflict.get();
5+ | -------------- immutable borrow occurs here
6+ LL | conflict.insert(*prev + *x);
7+ | ^^^^^^^^^^^^^^^^-----^^^^^^
8+ | | |
9+ | | immutable borrow later used here
10+ | mutable borrow occurs here
11+ |
12+ = note: `#[warn(mutable_borrow_reservation_conflict)]` on by default
13+ = warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
14+ = note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
15+
16+ warning: 1 warning emitted
17+
You can’t perform that action at this time.
0 commit comments