about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-01-20 17:10:37 +0100
committerGitHub <noreply@github.com>2022-01-20 17:10:37 +0100
commit5c10dbd85f962e4fc1ed16f4e157f00e5e7b6a8a (patch)
tree028faa77af90be6df66d96c3cba5b28c6638ef62 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent1839829f0a88a5835d3b85043d69b12d056ea191 (diff)
parent36a11417fafcbfae0500884df2d4b6dd2c5e5a0f (diff)
downloadrust-5c10dbd85f962e4fc1ed16f4e157f00e5e7b6a8a.tar.gz
rust-5c10dbd85f962e4fc1ed16f4e157f00e5e7b6a8a.zip
Rollup merge of #92704 - 5225225:std_mem_transmute_ref_t_mut_t, r=michaelwoerister
Change lint message to be stronger for &T -> &mut T transmute

The old message implied that it's only UB if you use the reference to mutate, which (as far as I know) is not true. As in, the following program has UB, and a &T -> &mut T transmute is effectively an `unreachable_unchecked`.

```rust
fn main() {
    #[allow(mutable_transmutes)]
    unsafe {
        let _ = std::mem::transmute::<&i32, &mut i32>(&0);
    }
}
```

In the future, it might be a good idea to use the edition system to make this a hard error, since I don't think it is *ever* defined behaviour? Unless we rule that `&UnsafeCell<i32> -> &mut i32` is fine. (That, and you always could just use `.get()`, so you're not losing anything)
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions