about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-05-07 17:39:58 +0200
committerSamuel Tardieu <sam@rfc1149.net>2025-07-31 15:53:09 +0200
commit7224dffc65e7082d2366aa2ca3f7620f93f5439b (patch)
treef5a3dabbcc97a98fc45ee5a1dce915b4f543fa55 /compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
parentff496ad34fc823bc063293edbf48f14261c6e28b (diff)
downloadrust-7224dffc65e7082d2366aa2ca3f7620f93f5439b.tar.gz
rust-7224dffc65e7082d2366aa2ca3f7620f93f5439b.zip
Do not lint data coming from macro
Suggesting to remove `*&` or `*&mut` in a macro may be incorrect, as it
would require tracking all possible macro usages. In some cases, it is
not possible to remove the dereference or the reference.

For example, in the following code, the `drmut!()` macro will be linted
against while called as `drmut!(d)`, and the suggestion would be to
remove the `*&mut`. That would make `drmut!(u.data).num = 1` invalid,
as a `ManuallyDrop` object coming through a union cannot be implicitely
dereferenced through `DerefMut`.

```rust
use std::mem::ManuallyDrop;

#[derive(Copy, Clone)]
struct Data {
    num: u64,
}

union Union {
    data: ManuallyDrop<Data>,
}

macro_rules! drmut {
    ($e:expr) => { *&mut $e };
}

fn f(mut u: Union, mut d: Data) {
    unsafe {
        drmut!(u.data).num = 1;
    }
    drmut!(d).num = 1;
}
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp')
0 files changed, 0 insertions, 0 deletions