Skip to content

Commit 5be9e79

Browse files
Update expr.rs
Revert spurious changes included in PR
1 parent b79fc92 commit 5be9e79

File tree

1 file changed

+8
-16
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+8
-16
lines changed

compiler/rustc_typeck/src/check/expr.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -865,22 +865,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
865865
),
866866
..
867867
}) => {
868-
// Check if our lhs is a child of the condition of a while loop
869-
let expr_is_ancestor = std::iter::successors(Some(lhs.hir_id), |id| {
870-
self.tcx.hir().find_parent_node(*id)
871-
})
872-
.take_while(|id| *id != parent)
873-
.any(|id| id == expr.hir_id);
874-
// if it is, then we have a situation like `while Some(0) = value.get(0) {`,
875-
// where `while let` was more likely intended.
876-
if expr_is_ancestor {
877-
err.span_suggestion_verbose(
878-
expr.span.shrink_to_lo(),
879-
"you might have meant to use pattern destructuring",
880-
"let ".to_string(),
881-
Applicability::MachineApplicable,
882-
);
883-
}
868+
// We have a situation like `while Some(0) = value.get(0) {`, where `while let`
869+
// was more likely intended.
870+
err.span_suggestion_verbose(
871+
expr.span.shrink_to_lo(),
872+
"you might have meant to use pattern destructuring",
873+
"let ".to_string(),
874+
Applicability::MachineApplicable,
875+
);
884876
break;
885877
}
886878
hir::Node::Item(_)

0 commit comments

Comments
 (0)