Update expr.rs
Revert spurious changes included in PR
This commit is contained in:
parent
b79fc92db3
commit
5be9e79ae0
1 changed files with 8 additions and 16 deletions
|
@ -865,22 +865,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
),
|
),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
// Check if our lhs is a child of the condition of a while loop
|
// We have a situation like `while Some(0) = value.get(0) {`, where `while let`
|
||||||
let expr_is_ancestor = std::iter::successors(Some(lhs.hir_id), |id| {
|
// was more likely intended.
|
||||||
self.tcx.hir().find_parent_node(*id)
|
err.span_suggestion_verbose(
|
||||||
})
|
expr.span.shrink_to_lo(),
|
||||||
.take_while(|id| *id != parent)
|
"you might have meant to use pattern destructuring",
|
||||||
.any(|id| id == expr.hir_id);
|
"let ".to_string(),
|
||||||
// if it is, then we have a situation like `while Some(0) = value.get(0) {`,
|
Applicability::MachineApplicable,
|
||||||
// where `while let` was more likely intended.
|
);
|
||||||
if expr_is_ancestor {
|
|
||||||
err.span_suggestion_verbose(
|
|
||||||
expr.span.shrink_to_lo(),
|
|
||||||
"you might have meant to use pattern destructuring",
|
|
||||||
"let ".to_string(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hir::Node::Item(_)
|
hir::Node::Item(_)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue