Skip to content

Commit 3468294

Browse files
committed
Auto merge of #9140 - Jarcho:sig_drop, r=flip1995
Ignore `into_iter` in `significant_drop_in_scrutinee` fixes #9135 changelog: Ignore the `IntoIterator::into_iter` call from for loops in `significant_drop_in_scrutinee`
2 parents 526f02e + 95b7879 commit 3468294

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ fn has_significant_drop_in_scrutinee<'tcx, 'a>(
8989
source: MatchSource,
9090
) -> Option<(Vec<FoundSigDrop>, &'static str)> {
9191
let mut helper = SigDropHelper::new(cx);
92+
let scrutinee = match (source, &scrutinee.kind) {
93+
(MatchSource::ForLoopDesugar, ExprKind::Call(_, [e])) => e,
94+
_ => scrutinee,
95+
};
9296
helper.find_sig_drop(scrutinee).map(|drops| {
9397
let message = if source == MatchSource::Normal {
9498
"temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression"

tests/ui/significant_drop_in_scrutinee.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,4 +620,11 @@ fn should_trigger_lint_without_significant_drop_in_arm() {
620620
};
621621
}
622622

623+
fn should_not_trigger_on_significant_iterator_drop() {
624+
let lines = std::io::stdin().lines();
625+
for line in lines {
626+
println!("foo: {}", line.unwrap());
627+
}
628+
}
629+
623630
fn main() {}

0 commit comments

Comments
 (0)