Code
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {}
}
fn foo(mut f: Foo) {
Drop::drop(&mut f);
}
Current output
error[E0040]: explicit use of destructor method
--> src/lib.rs:8:5
|
8 | Drop::drop(&mut f);
| ^^^^^^^^^^
| |
| explicit destructor calls not allowed
| help: consider using `drop` function: `drop`
Desired output
error[E0040]: explicit use of destructor method
--> src/lib.rs:8:7
|
8 | Drop::drop(&mut f);
| ^^^^^^^^^^
| |
| explicit destructor calls not allowed
|
help: consider using `drop` function
|
8 - Drop::drop(&mut f);
8 + drop(f);
|
Rationale and extra context
The existing fix results in drop(&mut f), which doesn't actually drop f, as it's behind a reference.
Other cases
error[E0040]: explicit use of destructor method
--> src/lib.rs:8:7
|
8 | f.drop();
| ^^^^ explicit destructor calls not allowed
|
help: consider using `drop` function
|
8 - f.drop();
8 + drop(f);
|
Rust Version
rustc 1.95.0 (59807616e 2026-04-14)
binary: rustc
commit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860
commit-date: 2026-04-14
host: x86_64-unknown-linux-gnu
release: 1.95.0
LLVM version: 22.1.2
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
The existing fix results in
drop(&mut f), which doesn't actually dropf, as it's behind a reference.Other cases
Rust Version
Anything else?
No response