about summary refs log tree commit diff
path: root/compiler/rustc_infer
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2023-07-12 21:49:27 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2023-07-12 21:49:27 -0400
commitcc907f80b95c6ec530c5ee1b05b044a468f07eca (patch)
tree47015a30be181fdb089b7daa4b8f18e9bb1d62f2 /compiler/rustc_infer
parent67b0cfc761c9ad31a1dbacca36c42803b255f17a (diff)
downloadrust-cc907f80b95c6ec530c5ee1b05b044a468f07eca.tar.gz
rust-cc907f80b95c6ec530c5ee1b05b044a468f07eca.zip
Re-format let-else per rustfmt update
Diffstat (limited to 'compiler/rustc_infer')
-rw-r--r--compiler/rustc_infer/src/errors/mod.rs3
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs5
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs6
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs8
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs4
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/note.rs44
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/suggest.rs20
7 files changed, 55 insertions, 35 deletions
diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs
index 7e1fa08f23a..1ffa8633afd 100644
--- a/compiler/rustc_infer/src/errors/mod.rs
+++ b/compiler/rustc_infer/src/errors/mod.rs
@@ -363,7 +363,8 @@ impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
             let (
                 hir::Ty { kind: hir::TyKind::Ref(lifetime_sub, _), .. },
                 hir::Ty { kind: hir::TyKind::Ref(lifetime_sup, _), .. },
-            ) = (self.ty_sub, self.ty_sup) else {
+            ) = (self.ty_sub, self.ty_sup)
+            else {
                 return false;
             };
 
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index b826ced0453..37249b62e8b 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -2109,14 +2109,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         found: Ty<'tcx>,
         expected_fields: &List<Ty<'tcx>>,
     ) -> Option<TypeErrorAdditionalDiags> {
-        let [expected_tup_elem] = expected_fields[..] else { return None};
+        let [expected_tup_elem] = expected_fields[..] else { return None };
 
         if !self.same_type_modulo_infer(expected_tup_elem, found) {
             return None;
         }
 
-        let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span)
-            else { return None };
+        let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) else { return None };
 
         let sugg = if code.starts_with('(') && code.ends_with(')') {
             let before_close = span.hi() - BytePos::from_u32(1);
diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
index a90a41f5d70..d192624b17e 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
@@ -419,7 +419,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         }
 
         let Some(InferSource { span, kind }) = local_visitor.infer_source else {
-            return self.bad_inference_failure_err(failure_span, arg_data, error_code)
+            return self.bad_inference_failure_err(failure_span, arg_data, error_code);
         };
 
         let (source_kind, name) = kind.ty_localized_msg(self);
@@ -1157,9 +1157,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
                 continue;
             }
 
-            let Some(param_ty) = self.opt_node_type(param.hir_id) else {
-                continue
-            };
+            let Some(param_ty) = self.opt_node_type(param.hir_id) else { continue };
 
             if self.generic_arg_contains_target(param_ty.into()) {
                 self.update_infer_source(InferSource {
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs
index 2c63a390410..d46dd8f3268 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs
@@ -38,8 +38,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
         let ObligationCauseCode::MatchImpl(parent, impl_def_id) = code else {
             return None;
         };
-        let (ObligationCauseCode::BindingObligation(_, binding_span) | ObligationCauseCode::ExprBindingObligation(_, binding_span, ..))
-            = *parent.code() else {
+        let (ObligationCauseCode::BindingObligation(_, binding_span)
+        | ObligationCauseCode::ExprBindingObligation(_, binding_span, ..)) = *parent.code()
+        else {
             return None;
         };
 
@@ -67,7 +68,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
             let hir::Node::Item(hir::Item {
                 kind: hir::ItemKind::Impl(hir::Impl { self_ty: impl_self_ty, .. }),
                 ..
-            }) = impl_node else {
+            }) = impl_node
+            else {
                 bug!("Node not an impl.");
             };
 
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs
index a9b485a6f7e..d70fea20cf4 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs
@@ -503,7 +503,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
 
         // Get the `Ident` of the method being called and the corresponding `impl` (to point at
         // `Bar` in `impl Foo for dyn Bar {}` and the definition of the method being called).
-        let Some((ident, self_ty)) = NiceRegionError::get_impl_ident_and_self_ty_from_trait(tcx, instance.def_id(), &v.0) else {
+        let Some((ident, self_ty)) =
+            NiceRegionError::get_impl_ident_and_self_ty_from_trait(tcx, instance.def_id(), &v.0)
+        else {
             return false;
         };
 
diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs
index e55e9e75fb6..6517b904404 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/note.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs
@@ -295,12 +295,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         // but right now it's not really very smart when it comes to implicit `Sized`
         // predicates and bounds on the trait itself.
 
-        let Some(impl_def_id) =
-            self.tcx.associated_item(impl_item_def_id).impl_container(self.tcx) else { return; };
-        let Some(trait_ref) = self
-            .tcx
-            .impl_trait_ref(impl_def_id)
-            else { return; };
+        let Some(impl_def_id) = self.tcx.associated_item(impl_item_def_id).impl_container(self.tcx)
+        else {
+            return;
+        };
+        let Some(trait_ref) = self.tcx.impl_trait_ref(impl_def_id) else {
+            return;
+        };
         let trait_substs = trait_ref
             .subst_identity()
             // Replace the explicit self type with `Self` for better suggestion rendering
@@ -309,20 +310,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         let trait_item_substs = ty::InternalSubsts::identity_for_item(self.tcx, impl_item_def_id)
             .rebase_onto(self.tcx, impl_def_id, trait_substs);
 
-        let Ok(trait_predicates) = self
-            .tcx
-            .explicit_predicates_of(trait_item_def_id)
-            .instantiate_own(self.tcx, trait_item_substs)
-            .map(|(pred, _)| {
-                if pred.is_suggestable(self.tcx, false) {
-                    Ok(pred.to_string())
-                } else {
-                    Err(())
-                }
-            })
-            .collect::<Result<Vec<_>, ()>>() else { return; };
+        let Ok(trait_predicates) =
+            self.tcx
+                .explicit_predicates_of(trait_item_def_id)
+                .instantiate_own(self.tcx, trait_item_substs)
+                .map(|(pred, _)| {
+                    if pred.is_suggestable(self.tcx, false) {
+                        Ok(pred.to_string())
+                    } else {
+                        Err(())
+                    }
+                })
+                .collect::<Result<Vec<_>, ()>>()
+        else {
+            return;
+        };
 
-        let Some(generics) = self.tcx.hir().get_generics(impl_item_def_id) else { return; };
+        let Some(generics) = self.tcx.hir().get_generics(impl_item_def_id) else {
+            return;
+        };
 
         let suggestion = if trait_predicates.is_empty() {
             WhereClauseSuggestions::Remove { span: generics.where_clause_span }
diff --git a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs
index b0e7cf23cae..aac2a43648b 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs
@@ -526,13 +526,23 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         diag: &mut Diagnostic,
     ) {
         // 0. Extract fn_decl from hir
-        let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(hir::Closure { body, fn_decl, .. }), .. }) = hir else { return; };
+        let hir::Node::Expr(hir::Expr {
+            kind: hir::ExprKind::Closure(hir::Closure { body, fn_decl, .. }),
+            ..
+        }) = hir
+        else {
+            return;
+        };
         let hir::Body { params, .. } = self.tcx.hir().body(*body);
 
         // 1. Get the substs of the closure.
         // 2. Assume exp_found is FnOnce / FnMut / Fn, we can extract function parameters from [1].
-        let Some(expected) = exp_found.expected.skip_binder().substs.get(1) else { return; };
-        let Some(found) = exp_found.found.skip_binder().substs.get(1) else { return; };
+        let Some(expected) = exp_found.expected.skip_binder().substs.get(1) else {
+            return;
+        };
+        let Some(found) = exp_found.found.skip_binder().substs.get(1) else {
+            return;
+        };
         let expected = expected.unpack();
         let found = found.unpack();
         // 3. Extract the tuple type from Fn trait and suggest the change.
@@ -711,7 +721,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
 
         let hir = self.tcx.hir();
         for stmt in blk.stmts.iter().rev() {
-            let hir::StmtKind::Local(local) = &stmt.kind else { continue; };
+            let hir::StmtKind::Local(local) = &stmt.kind else {
+                continue;
+            };
             local.pat.walk(&mut find_compatible_candidates);
         }
         match hir.find_parent(blk.hir_id) {