about summary refs log tree commit diff
path: root/compiler/rustc_mir_build
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-28 05:25:23 +0000
committerbors <bors@rust-lang.org>2025-07-28 05:25:23 +0000
commitd242a8bd5a73f633ba1ec5aacf19acf35a3c747d (patch)
tree0c2c8a3f7ebcbd838f4afef27acad292c7b0bab1 /compiler/rustc_mir_build
parent733dab558992d902d6d17576de1da768094e2cf3 (diff)
parentb8eb046e6ee3294969bf8faf31da226b0ea29d18 (diff)
downloadrust-d242a8bd5a73f633ba1ec5aacf19acf35a3c747d.tar.gz
rust-d242a8bd5a73f633ba1ec5aacf19acf35a3c747d.zip
Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLii
Some `let chains` clean-up

Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one

r? compiler
Diffstat (limited to 'compiler/rustc_mir_build')
-rw-r--r--compiler/rustc_mir_build/src/thir/cx/block.rs38
-rw-r--r--compiler/rustc_mir_build/src/thir/cx/expr.rs18
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/check_match.rs12
3 files changed, 31 insertions, 37 deletions
diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs
index e858b629ab1..57ddb8eddb8 100644
--- a/compiler/rustc_mir_build/src/thir/cx/block.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/block.rs
@@ -76,28 +76,24 @@ impl<'tcx> ThirBuildCx<'tcx> {
                         let mut pattern = self.pattern_from_hir(local.pat);
                         debug!(?pattern);
 
-                        if let Some(ty) = &local.ty {
-                            if let Some(&user_ty) =
+                        if let Some(ty) = &local.ty
+                            && let Some(&user_ty) =
                                 self.typeck_results.user_provided_types().get(ty.hir_id)
-                            {
-                                debug!("mirror_stmts: user_ty={:?}", user_ty);
-                                let annotation = CanonicalUserTypeAnnotation {
-                                    user_ty: Box::new(user_ty),
-                                    span: ty.span,
-                                    inferred_ty: self.typeck_results.node_type(ty.hir_id),
-                                };
-                                pattern = Box::new(Pat {
-                                    ty: pattern.ty,
-                                    span: pattern.span,
-                                    kind: PatKind::AscribeUserType {
-                                        ascription: Ascription {
-                                            annotation,
-                                            variance: ty::Covariant,
-                                        },
-                                        subpattern: pattern,
-                                    },
-                                });
-                            }
+                        {
+                            debug!("mirror_stmts: user_ty={:?}", user_ty);
+                            let annotation = CanonicalUserTypeAnnotation {
+                                user_ty: Box::new(user_ty),
+                                span: ty.span,
+                                inferred_ty: self.typeck_results.node_type(ty.hir_id),
+                            };
+                            pattern = Box::new(Pat {
+                                ty: pattern.ty,
+                                span: pattern.span,
+                                kind: PatKind::AscribeUserType {
+                                    ascription: Ascription { annotation, variance: ty::Covariant },
+                                    subpattern: pattern,
+                                },
+                            });
                         }
 
                         let span = match local.init {
diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs
index b694409f327..33bf4e3e29f 100644
--- a/compiler/rustc_mir_build/src/thir/cx/expr.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs
@@ -105,11 +105,11 @@ impl<'tcx> ThirBuildCx<'tcx> {
         //   // ^ error message points at this expression.
         // }
         let mut adjust_span = |expr: &mut Expr<'tcx>| {
-            if let ExprKind::Block { block } = expr.kind {
-                if let Some(last_expr) = self.thir[block].expr {
-                    span = self.thir[last_expr].span;
-                    expr.span = span;
-                }
+            if let ExprKind::Block { block } = expr.kind
+                && let Some(last_expr) = self.thir[block].expr
+            {
+                span = self.thir[last_expr].span;
+                expr.span = span;
             }
         };
 
@@ -956,10 +956,10 @@ impl<'tcx> ThirBuildCx<'tcx> {
                     };
 
                     fn local(expr: &rustc_hir::Expr<'_>) -> Option<hir::HirId> {
-                        if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = expr.kind {
-                            if let Res::Local(hir_id) = path.res {
-                                return Some(hir_id);
-                            }
+                        if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = expr.kind
+                            && let Res::Local(hir_id) = path.res
+                        {
+                            return Some(hir_id);
                         }
 
                         None
diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
index 7f47754f6bc..ae67bb5075e 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
@@ -1155,14 +1155,12 @@ fn find_fallback_pattern_typo<'tcx>(
                     }
                     hir::Node::Block(hir::Block { stmts, .. }) => {
                         for stmt in *stmts {
-                            if let hir::StmtKind::Let(let_stmt) = stmt.kind {
-                                if let hir::PatKind::Binding(_, _, binding_name, _) =
+                            if let hir::StmtKind::Let(let_stmt) = stmt.kind
+                                && let hir::PatKind::Binding(_, _, binding_name, _) =
                                     let_stmt.pat.kind
-                                {
-                                    if name == binding_name.name {
-                                        lint.pattern_let_binding = Some(binding_name.span);
-                                    }
-                                }
+                                && name == binding_name.name
+                            {
+                                lint.pattern_let_binding = Some(binding_name.span);
                             }
                         }
                     }