Skip to content

Commit

Permalink
Auto merge of #9140 - Jarcho:sig_drop, r=flip1995
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Jul 9, 2022
2 parents 526f02e + 95b7879 commit 3468294
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clippy_lints/src/matches/significant_drop_in_scrutinee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ fn has_significant_drop_in_scrutinee<'tcx, 'a>(
source: MatchSource,
) -> Option<(Vec<FoundSigDrop>, &'static str)> {
let mut helper = SigDropHelper::new(cx);
let scrutinee = match (source, &scrutinee.kind) {
(MatchSource::ForLoopDesugar, ExprKind::Call(_, [e])) => e,
_ => scrutinee,
};
helper.find_sig_drop(scrutinee).map(|drops| {
let message = if source == MatchSource::Normal {
"temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression"
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/significant_drop_in_scrutinee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,11 @@ fn should_trigger_lint_without_significant_drop_in_arm() {
};
}

fn should_not_trigger_on_significant_iterator_drop() {
let lines = std::io::stdin().lines();
for line in lines {
println!("foo: {}", line.unwrap());
}
}

fn main() {}

0 comments on commit 3468294

Please sign in to comment.