You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#65485 - ecstatic-morse:const-validation-mismatch-ugliness, r=eddyb
Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut`
Resolvesrust-lang#65394.
This hack disables the validator mismatch ICE in cases where a `MutBorrow` error has been emitted by both validators, but they don't agree on the number of `LiveDrop` errors.
The new validator is more conservative about whether a value is moved from in the presence of mutable borrows. For example, the new validator will emit a `LiveDrop` error on the following code.
```rust
const _: Vec<i32> = {
let mut x = Vec::new();
let px = &mut x as *mut _;
let y = x;
unsafe { ptr::write(px, Vec::new()); }
y
};
```
This code is not UB AFAIK (it passes MIRI at least). The current validator does not emit a `LiveDrop` error for `x` upon exit from the initializer. `x` is not actually dropped, so I think this is correct? A proper fix for this would require a new `MaybeInitializedLocals` dataflow analysis or maybe a relaxation of the existing `IndirectlyMutableLocals` one.
r? @RalfJung
0 commit comments