about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-19 07:10:06 +0200
committerGitHub <noreply@github.com>2019-10-19 07:10:06 +0200
commit27f8c7990e26900e72184f0fbe55da110782be72 (patch)
tree7ee2c3a3fc7da68c2baf5d681f3c37493e6821ce /src/libsyntax/parse/parser
parent99603e99cc1ab0260c5bdd4e752e876af7c390c0 (diff)
parentaf691de9c1d9923e8a6b7965d1eebf21e1d87ad2 (diff)
downloadrust-27f8c7990e26900e72184f0fbe55da110782be72.tar.gz
rust-27f8c7990e26900e72184f0fbe55da110782be72.zip
Rollup merge of #65485 - ecstatic-morse:const-validation-mismatch-ugliness, r=eddyb
Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut`

Resolves #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
Diffstat (limited to 'src/libsyntax/parse/parser')
0 files changed, 0 insertions, 0 deletions