about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorTimo <30553356+y21@users.noreply.github.com>2025-04-17 12:42:46 +0000
committerGitHub <noreply@github.com>2025-04-17 12:42:46 +0000
commitac88357f83ddc9efb3b05032ed822d18d0fd38f9 (patch)
tree6dfc67fdc232ecee1d1f14edfc7be0f42b29d7f6 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent30e9cd5a260969786802b864380b642db6e7bf8a (diff)
parent05448bd9c7c256d45d9965989397331d52e4fd0d (diff)
downloadrust-ac88357f83ddc9efb3b05032ed822d18d0fd38f9.tar.gz
rust-ac88357f83ddc9efb3b05032ed822d18d0fd38f9.zip
New lint: `swap_with_temporary` (#14046)
This lint detects inefficient or useless `{std,core}::mem::swap()` calls
such as:

```rust
    // Should be `a = temp();`
    swap(&mut a, &mut temp());
    // Should be `*b = temp();`
    swap(b, &mut temp());
    // Should be `temp1(); temp2();` if we want to keep the side effects
    swap(&mut temp1(), &mut temp2());
```

It also takes care of using a form appropriate for a `()` context if
`swap()` is part of a larger expression (don't ask me why this wouldn't
happen, I have no idea), by suggesting `{ x = y; }` (statement in block)
or `{std,core}::mem::drop((temp1(), temp2())`.

changelog: [`swap_with_temporary`]: new lint

Close #1968
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions