about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-08-03 04:33:07 +0000
committerMichael Goulet <michael@errs.io>2023-08-03 04:33:07 +0000
commitaa41c9873762af552369822da5361c5bdfe438cb (patch)
treedef6c820337feaf010758c7e3841a664aa9bde0c
parenta63bb245939d116bf22a1e7c15a14a751b177a4f (diff)
downloadrust-aa41c9873762af552369822da5361c5bdfe438cb.tar.gz
rust-aa41c9873762af552369822da5361c5bdfe438cb.zip
Make Option<&dyn FnMut> into impl FnOnce
-rw-r--r--compiler/rustc_hir_typeck/src/_match.rs6
-rw-r--r--compiler/rustc_hir_typeck/src/coercion.rs12
-rw-r--r--compiler/rustc_hir_typeck/src/expr.rs6
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs6
4 files changed, 13 insertions, 17 deletions
diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs
index f32327ad21b..c2d987a95cf 100644
--- a/compiler/rustc_hir_typeck/src/_match.rs
+++ b/compiler/rustc_hir_typeck/src/_match.rs
@@ -136,9 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 &cause,
                 Some(&arm.body),
                 arm_ty,
-                Some(&mut |err| {
-                    self.suggest_removing_semicolon_for_coerce(err, expr, arm_ty, prior_arm)
-                }),
+                |err| self.suggest_removing_semicolon_for_coerce(err, expr, arm_ty, prior_arm),
                 false,
             );
 
@@ -269,7 +267,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         coercion.coerce_forced_unit(
             self,
             &cause,
-            &mut |err| {
+            |err| {
                 if let Some((span, msg)) = &ret_reason {
                     err.span_label(*span, msg.clone());
                 } else if let ExprKind::Block(block, _) = &then_expr.kind
diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs
index 4fdfc51bc86..fa6bad84376 100644
--- a/compiler/rustc_hir_typeck/src/coercion.rs
+++ b/compiler/rustc_hir_typeck/src/coercion.rs
@@ -1418,7 +1418,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
         expression: &'tcx hir::Expr<'tcx>,
         expression_ty: Ty<'tcx>,
     ) {
-        self.coerce_inner(fcx, cause, Some(expression), expression_ty, None, false)
+        self.coerce_inner(fcx, cause, Some(expression), expression_ty, |_| {}, false)
     }
 
     /// Indicates that one of the inputs is a "forced unit". This
@@ -1437,7 +1437,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
         &mut self,
         fcx: &FnCtxt<'a, 'tcx>,
         cause: &ObligationCause<'tcx>,
-        augment_error: &mut dyn FnMut(&mut Diagnostic),
+        augment_error: impl FnOnce(&mut Diagnostic),
         label_unit_as_expected: bool,
     ) {
         self.coerce_inner(
@@ -1445,7 +1445,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
             cause,
             None,
             Ty::new_unit(fcx.tcx),
-            Some(augment_error),
+            augment_error,
             label_unit_as_expected,
         )
     }
@@ -1460,7 +1460,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
         cause: &ObligationCause<'tcx>,
         expression: Option<&'tcx hir::Expr<'tcx>>,
         mut expression_ty: Ty<'tcx>,
-        augment_error: Option<&mut dyn FnMut(&mut Diagnostic)>,
+        augment_error: impl FnOnce(&mut Diagnostic),
         label_expression_as_expected: bool,
     ) {
         // Incorporate whatever type inference information we have
@@ -1639,9 +1639,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
                     }
                 }
 
-                if let Some(augment_error) = augment_error {
-                    augment_error(&mut err);
-                }
+                augment_error(&mut err);
 
                 let is_insufficiently_polymorphic =
                     matches!(coercion_error, TypeError::RegionsInsufficientlyPolymorphic(..));
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index 401eff3d5c8..80d7cc57edb 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -652,7 +652,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     coerce.coerce_forced_unit(
                         self,
                         &cause,
-                        &mut |mut err| {
+                        |mut err| {
                             self.suggest_mismatched_types_on_tail(
                                 &mut err, expr, ty, e_ty, target_id,
                             );
@@ -748,7 +748,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 coercion.coerce_forced_unit(
                     self,
                     &cause,
-                    &mut |db| {
+                    |db| {
                         let span = fn_decl.output.span();
                         if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
                             db.span_label(
@@ -760,7 +760,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     true,
                 );
             } else {
-                coercion.coerce_forced_unit(self, &cause, &mut |_| (), true);
+                coercion.coerce_forced_unit(self, &cause, |_| (), true);
             }
         }
         self.tcx.types.never
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 302b5fd8d9c..94c54197294 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -1587,9 +1587,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     &cause,
                     Some(tail_expr),
                     tail_expr_ty,
-                    Some(&mut |diag: &mut Diagnostic| {
+                    |diag| {
                         self.suggest_block_to_brackets(diag, blk, tail_expr_ty, ty_for_diagnostic);
-                    }),
+                    },
                     false,
                 );
             } else {
@@ -1626,7 +1626,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     coerce.coerce_forced_unit(
                         self,
                         &self.misc(sp),
-                        &mut |err| {
+                        |err| {
                             if let Some(expected_ty) = expected.only_has_type(self) {
                                 if blk.stmts.is_empty() && blk.expr.is_none() {
                                     self.suggest_boxing_when_appropriate(