`dropping_references` lint triggers even for mutable references
@tbu- is already working on this.
Since Jun 11, 2024.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
When I call std::mem::drop on a mutable reference, this is supposed to consume the reference and make it unavailable to following code. And indeed it does, because any following uses trigger a "use of moved value" error.
But when I do this, I get a warning from the compiler:
warning: calls to
std::mem::dropwith a reference instead of an owned value does nothing
--> foo.rs:1602:13
|
1602 | mem::drop(mutref);
| ^^^^^^^^^^-------------^
| |
| argument has type&mut Foo
|
= note: uselet _ = ...to ignore the expression or result
= note:#[warn(dropping_references)]on by default
Meta
rustc --version --verbose:
rustc 1.80.0-nightly (7c52d2db6 2024-06-03)
binary: rustc
commit-hash: 7c52d2db6348b038276198e88a835125849f322e
commit-date: 2024-06-03
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.