]> git.lizzy.rs Git - rust.git/commitdiff
Update expr.rs
authorMichael Goulet <michael@errs.io>
Sat, 12 Feb 2022 01:48:06 +0000 (17:48 -0800)
committerGitHub <noreply@github.com>
Sat, 12 Feb 2022 01:48:06 +0000 (17:48 -0800)
Revert spurious changes included in PR

compiler/rustc_typeck/src/check/expr.rs

index 82cda5a2f2e738fdee2b2c9c3571127c76b31e90..0e1dbc53806ffe511bf4ae2e7d45cad784d5e72e 100644 (file)
@@ -865,22 +865,14 @@ pub(crate) fn check_lhs_assignable(
                         ),
                     ..
                 }) => {
-                    // Check if our lhs is a child of the condition of a while loop
-                    let expr_is_ancestor = std::iter::successors(Some(lhs.hir_id), |id| {
-                        self.tcx.hir().find_parent_node(*id)
-                    })
-                    .take_while(|id| *id != parent)
-                    .any(|id| id == expr.hir_id);
-                    // if it is, then we have a situation like `while Some(0) = value.get(0) {`,
-                    // 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,
-                        );
-                    }
+                    // We have a situation like `while Some(0) = value.get(0) {`, where `while let`
+                    // was more likely intended.
+                    err.span_suggestion_verbose(
+                        expr.span.shrink_to_lo(),
+                        "you might have meant to use pattern destructuring",
+                        "let ".to_string(),
+                        Applicability::MachineApplicable,
+                    );
                     break;
                 }
                 hir::Node::Item(_)