Closed
Description
Summary
See reproducer below
Lint Name
significant_drop_in_scrutinee
Reproducer
I tried this code:
fn main() {
let x = std::sync::Mutex::new(vec![1, 2, 3]);
let x_guard = x.lock().unwrap();
match x_guard[0] {
1 => println!("1!"),
x => println!("{x}"),
}
drop(x_guard); // Some "usage"
}
I saw this happen:
warning: temporary with significant drop in match scrutinee
--> src/main.rs:4:11
|
4 | match x_guard[0] {
| ^^^^^^^^^^
|
= note: `#[warn(clippy::significant_drop_in_scrutinee)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee
help: try moving the temporary above the match
|
4 ~ let value = x_guard[0];
5 ~ match value {
|
I expected to see this happen: No warning
Version
rustc 1.63.0-beta.2 (6c1f14289 2022-06-28)
binary: rustc
commit-hash: 6c1f1428998a08864495bb599840a5997ec175f4
commit-date: 2022-06-28
host: x86_64-unknown-linux-gnu
release: 1.63.0-beta.2
LLVM version: 14.0.5
Additional Labels
@rustbot label +I-false-positive