diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2025-05-07 17:39:58 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2025-07-31 15:53:09 +0200 |
| commit | 7224dffc65e7082d2366aa2ca3f7620f93f5439b (patch) | |
| tree | f5a3dabbcc97a98fc45ee5a1dce915b4f543fa55 /compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp | |
| parent | ff496ad34fc823bc063293edbf48f14261c6e28b (diff) | |
| download | rust-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
