about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_borrowck/src/nll.rs4
-rw-r--r--compiler/rustc_borrowck/src/polonius/dump.rs2
-rw-r--r--compiler/rustc_middle/src/mir/pretty.rs62
-rw-r--r--compiler/rustc_mir_transform/src/coroutine.rs10
-rw-r--r--compiler/rustc_mir_transform/src/coroutine/by_move_body.rs2
-rw-r--r--compiler/rustc_mir_transform/src/coroutine/drop.rs6
-rw-r--r--compiler/rustc_mir_transform/src/dest_prop.rs2
-rw-r--r--compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs2
-rw-r--r--compiler/rustc_mir_transform/src/pass_manager.rs6
-rw-r--r--compiler/rustc_mir_transform/src/shim.rs2
10 files changed, 39 insertions, 59 deletions
diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs
index 8608a8a3a66..021dba9c9a9 100644
--- a/compiler/rustc_borrowck/src/nll.rs
+++ b/compiler/rustc_borrowck/src/nll.rs
@@ -68,7 +68,7 @@ pub(crate) fn replace_regions_in_mir<'tcx>(
     // Replace all remaining regions with fresh inference variables.
     renumber::renumber_mir(infcx, body, promoted);
 
-    dump_mir(infcx.tcx, false, "renumber", &0, body, |_, _| Ok(()));
+    dump_mir(infcx.tcx, false, "renumber", &0, body, &|_, _| Ok(()));
 
     universal_regions
 }
@@ -194,7 +194,7 @@ pub(super) fn dump_nll_mir<'tcx>(
         "nll",
         &0,
         body,
-        |pass_where, out| {
+        &|pass_where, out| {
             emit_nll_mir(tcx, regioncx, closure_region_requirements, borrow_set, pass_where, out)
         },
         options,
diff --git a/compiler/rustc_borrowck/src/polonius/dump.rs b/compiler/rustc_borrowck/src/polonius/dump.rs
index 6b13b5ad081..173fb596976 100644
--- a/compiler/rustc_borrowck/src/polonius/dump.rs
+++ b/compiler/rustc_borrowck/src/polonius/dump.rs
@@ -175,7 +175,7 @@ fn emit_html_mir<'tcx>(
         &0,
         body,
         &mut buffer,
-        |pass_where, out| {
+        &|pass_where, out| {
             emit_polonius_mir(
                 tcx,
                 regioncx,
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs
index c2cc2042581..13b619a5a8b 100644
--- a/compiler/rustc_middle/src/mir/pretty.rs
+++ b/compiler/rustc_middle/src/mir/pretty.rs
@@ -83,16 +83,14 @@ impl PrettyPrintMirOptions {
 /// - `foo & nll | bar & typeck` == match if `foo` and `nll` both appear in the name
 ///   or `typeck` and `bar` both appear in the name.
 #[inline]
-pub fn dump_mir<'tcx, F>(
+pub fn dump_mir<'tcx>(
     tcx: TyCtxt<'tcx>,
     pass_num: bool,
     pass_name: &str,
     disambiguator: &dyn Display,
     body: &Body<'tcx>,
-    extra_data: F,
-) where
-    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
-{
+    extra_data: &dyn Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+) {
     dump_mir_with_options(
         tcx,
         pass_num,
@@ -110,17 +108,15 @@ pub fn dump_mir<'tcx, F>(
 /// See [`dump_mir`] for more details.
 ///
 #[inline]
-pub fn dump_mir_with_options<'tcx, F>(
+pub fn dump_mir_with_options<'tcx>(
     tcx: TyCtxt<'tcx>,
     pass_num: bool,
     pass_name: &str,
     disambiguator: &dyn Display,
     body: &Body<'tcx>,
-    extra_data: F,
+    extra_data: &dyn Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
     options: PrettyPrintMirOptions,
-) where
-    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
-{
+) {
     if !dump_enabled(tcx, pass_name, body.source.def_id()) {
         return;
     }
@@ -165,18 +161,15 @@ pub fn dump_enabled(tcx: TyCtxt<'_>, pass_name: &str, def_id: DefId) -> bool {
 /// most of the MIR dumping occurs, if one needs to export it to a file they have created with
 /// [create_dump_file], rather than to a new file created as part of [dump_mir], or to stdout/stderr
 /// for debugging purposes.
-pub fn dump_mir_to_writer<'tcx, F>(
+pub fn dump_mir_to_writer<'tcx>(
     tcx: TyCtxt<'tcx>,
     pass_name: &str,
     disambiguator: &dyn Display,
     body: &Body<'tcx>,
     w: &mut dyn io::Write,
-    extra_data: F,
+    extra_data: &dyn Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
     options: PrettyPrintMirOptions,
-) -> io::Result<()>
-where
-    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
-{
+) -> io::Result<()> {
     // see notes on #41697 above
     let def_path =
         ty::print::with_forced_impl_filename_line!(tcx.def_path_str(body.source.def_id()));
@@ -193,7 +186,7 @@ where
     writeln!(w)?;
     extra_data(PassWhere::BeforeCFG, w)?;
     write_user_type_annotations(tcx, body, w)?;
-    write_mir_fn(tcx, body, &extra_data, w, options)?;
+    write_mir_fn(tcx, body, extra_data, w, options)?;
     extra_data(PassWhere::AfterCFG, w)
 }
 
@@ -369,16 +362,13 @@ pub fn write_mir_pretty<'tcx>(
 }
 
 /// Write out a human-readable textual representation for the given function.
-pub fn write_mir_fn<'tcx, F>(
+pub fn write_mir_fn<'tcx>(
     tcx: TyCtxt<'tcx>,
     body: &Body<'tcx>,
-    extra_data: &F,
+    extra_data: &dyn Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
     w: &mut dyn io::Write,
     options: PrettyPrintMirOptions,
-) -> io::Result<()>
-where
-    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
-{
+) -> io::Result<()> {
     write_mir_intro(tcx, body, w, options)?;
     for block in body.basic_blocks.indices() {
         extra_data(PassWhere::BeforeBlock(block), w)?;
@@ -706,17 +696,14 @@ pub fn dump_mir_def_ids(tcx: TyCtxt<'_>, single: Option<DefId>) -> Vec<DefId> {
 // Basic blocks and their parts (statements, terminators, ...)
 
 /// Write out a human-readable textual representation for the given basic block.
-fn write_basic_block<'tcx, F>(
+fn write_basic_block<'tcx>(
     tcx: TyCtxt<'tcx>,
     block: BasicBlock,
     body: &Body<'tcx>,
-    extra_data: &F,
+    extra_data: &dyn Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
     w: &mut dyn io::Write,
     options: PrettyPrintMirOptions,
-) -> io::Result<()>
-where
-    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
-{
+) -> io::Result<()> {
     let data = &body[block];
 
     // Basic block label at the top.
@@ -748,9 +735,7 @@ where
         write_extra(
             tcx,
             w,
-            |visitor| {
-                visitor.visit_statement(statement, current_location);
-            },
+            &|visitor| visitor.visit_statement(statement, current_location),
             options,
         )?;
 
@@ -783,9 +768,7 @@ where
         write_extra(
             tcx,
             w,
-            |visitor| {
-                visitor.visit_terminator(data.terminator(), current_location);
-            },
+            &|visitor| visitor.visit_terminator(data.terminator(), current_location),
             options,
         )?;
     }
@@ -1360,15 +1343,12 @@ fn post_fmt_projection(projection: &[PlaceElem<'_>], fmt: &mut Formatter<'_>) ->
 /// After we print the main statement, we sometimes dump extra
 /// information. There's often a lot of little things "nuzzled up" in
 /// a statement.
-fn write_extra<'tcx, F>(
+fn write_extra<'tcx>(
     tcx: TyCtxt<'tcx>,
     write: &mut dyn io::Write,
-    visit_op: F,
+    visit_op: &dyn Fn(&mut ExtraComments<'tcx>),
     options: PrettyPrintMirOptions,
-) -> io::Result<()>
-where
-    F: Fn(&mut ExtraComments<'tcx>),
-{
+) -> io::Result<()> {
     if options.include_extra_comments {
         let mut extra_comments = ExtraComments { tcx, comments: vec![] };
         visit_op(&mut extra_comments);
diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs
index 761d5461a99..592192944d2 100644
--- a/compiler/rustc_mir_transform/src/coroutine.rs
+++ b/compiler/rustc_mir_transform/src/coroutine.rs
@@ -1294,7 +1294,7 @@ fn create_coroutine_resume_function<'tcx>(
 
     pm::run_passes_no_validate(tcx, body, &[&abort_unwinding_calls::AbortUnwindingCalls], None);
 
-    dump_mir(tcx, false, "coroutine_resume", &0, body, |_, _| Ok(()));
+    dump_mir(tcx, false, "coroutine_resume", &0, body, &|_, _| Ok(()));
 }
 
 /// An operation that can be performed on a coroutine.
@@ -1446,7 +1446,7 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform {
 
         assert!(body.coroutine_drop().is_none() && body.coroutine_drop_async().is_none());
 
-        dump_mir(tcx, false, "coroutine_before", &0, body, |_, _| Ok(()));
+        dump_mir(tcx, false, "coroutine_before", &0, body, &|_, _| Ok(()));
 
         // The first argument is the coroutine type passed by value
         let coroutine_ty = body.local_decls.raw[1].ty;
@@ -1506,7 +1506,7 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform {
         ) {
             let context_mut_ref = transform_async_context(tcx, body);
             expand_async_drops(tcx, body, context_mut_ref, coroutine_kind, coroutine_ty);
-            dump_mir(tcx, false, "coroutine_async_drop_expand", &0, body, |_, _| Ok(()));
+            dump_mir(tcx, false, "coroutine_async_drop_expand", &0, body, &|_, _| Ok(()));
         } else {
             cleanup_async_drops(body);
         }
@@ -1605,14 +1605,14 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform {
         // This is expanded to a drop ladder in `elaborate_coroutine_drops`.
         let drop_clean = insert_clean_drop(tcx, body, has_async_drops);
 
-        dump_mir(tcx, false, "coroutine_pre-elab", &0, body, |_, _| Ok(()));
+        dump_mir(tcx, false, "coroutine_pre-elab", &0, body, &|_, _| Ok(()));
 
         // Expand `drop(coroutine_struct)` to a drop ladder which destroys upvars.
         // If any upvars are moved out of, drop elaboration will handle upvar destruction.
         // However we need to also elaborate the code generated by `insert_clean_drop`.
         elaborate_coroutine_drops(tcx, body);
 
-        dump_mir(tcx, false, "coroutine_post-transform", &0, body, |_, _| Ok(()));
+        dump_mir(tcx, false, "coroutine_post-transform", &0, body, &|_, _| Ok(()));
 
         let can_unwind = can_unwind(tcx, body);
 
diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
index 81d7b7ba02c..5ba6fea9faf 100644
--- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
+++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
@@ -225,7 +225,7 @@ pub(crate) fn coroutine_by_move_body_def_id<'tcx>(
     );
     by_move_body.source =
         mir::MirSource::from_instance(InstanceKind::Item(body_def.def_id().to_def_id()));
-    dump_mir(tcx, false, "built", &"after", &by_move_body, |_, _| Ok(()));
+    dump_mir(tcx, false, "built", &"after", &by_move_body, &|_, _| Ok(()));
 
     // Feed HIR because we try to access this body's attrs in the inliner.
     body_def.feed_hir();
diff --git a/compiler/rustc_mir_transform/src/coroutine/drop.rs b/compiler/rustc_mir_transform/src/coroutine/drop.rs
index 1a314e029f4..6dffbc86627 100644
--- a/compiler/rustc_mir_transform/src/coroutine/drop.rs
+++ b/compiler/rustc_mir_transform/src/coroutine/drop.rs
@@ -605,7 +605,7 @@ pub(super) fn create_coroutine_drop_shim<'tcx>(
     // Temporary change MirSource to coroutine's instance so that dump_mir produces more sensible
     // filename.
     body.source.instance = coroutine_instance;
-    dump_mir(tcx, false, "coroutine_drop", &0, &body, |_, _| Ok(()));
+    dump_mir(tcx, false, "coroutine_drop", &0, &body, &|_, _| Ok(()));
     body.source.instance = drop_instance;
 
     // Creating a coroutine drop shim happens on `Analysis(PostCleanup) -> Runtime(Initial)`
@@ -696,7 +696,7 @@ pub(super) fn create_coroutine_drop_shim_async<'tcx>(
         None,
     );
 
-    dump_mir(tcx, false, "coroutine_drop_async", &0, &body, |_, _| Ok(()));
+    dump_mir(tcx, false, "coroutine_drop_async", &0, &body, &|_, _| Ok(()));
 
     body
 }
@@ -741,7 +741,7 @@ pub(super) fn create_coroutine_drop_shim_proxy_async<'tcx>(
     };
     body.basic_blocks_mut()[call_bb].terminator = Some(Terminator { source_info, kind });
 
-    dump_mir(tcx, false, "coroutine_drop_proxy_async", &0, &body, |_, _| Ok(()));
+    dump_mir(tcx, false, "coroutine_drop_proxy_async", &0, &body, &|_, _| Ok(()));
 
     body
 }
diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs
index 4c94a6c524e..bb68d1a0659 100644
--- a/compiler/rustc_mir_transform/src/dest_prop.rs
+++ b/compiler/rustc_mir_transform/src/dest_prop.rs
@@ -810,7 +810,7 @@ fn dest_prop_mir_dump<'tcx>(
         let location = points.point_from_location(location);
         live.rows().filter(|&r| live.contains(r, location)).collect::<Vec<_>>()
     };
-    dump_mir(tcx, false, "DestinationPropagation-dataflow", &round, body, |pass_where, w| {
+    dump_mir(tcx, false, "DestinationPropagation-dataflow", &round, body, &|pass_where, w| {
         if let PassWhere::BeforeLocation(loc) = pass_where {
             writeln!(w, "        // live: {:?}", locals_live_at(loc))?;
         }
diff --git a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs
index 2f0edf31162..0d0a71bc6c7 100644
--- a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs
+++ b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs
@@ -227,7 +227,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
         return;
     }
 
-    dump_mir(tcx, false, "lint_tail_expr_drop_order", &0 as _, body, |_, _| Ok(()));
+    dump_mir(tcx, false, "lint_tail_expr_drop_order", &0 as _, body, &|_, _| Ok(()));
     let locals_with_user_names = collect_user_names(body);
     let is_closure_like = tcx.is_closure_like(def_id.to_def_id());
 
diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs
index 37442150723..374623d4ea5 100644
--- a/compiler/rustc_mir_transform/src/pass_manager.rs
+++ b/compiler/rustc_mir_transform/src/pass_manager.rs
@@ -291,7 +291,7 @@ fn run_passes_inner<'tcx>(
             let dump_enabled = pass.is_mir_dump_enabled();
 
             if dump_enabled {
-                mir::dump_mir(tcx, pass_num, pass_name, &"before", body, |_, _| Ok(()));
+                mir::dump_mir(tcx, pass_num, pass_name, &"before", body, &|_, _| Ok(()));
             }
 
             if let Some(prof_arg) = &prof_arg {
@@ -304,7 +304,7 @@ fn run_passes_inner<'tcx>(
             }
 
             if dump_enabled {
-                mir::dump_mir(tcx, pass_num, pass_name, &"after", body, |_, _| Ok(()));
+                mir::dump_mir(tcx, pass_num, pass_name, &"after", body, &|_, _| Ok(()));
             }
             if validate {
                 validate_body(tcx, body, format!("after pass {pass_name}"));
@@ -348,5 +348,5 @@ pub(super) fn validate_body<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when
 
 pub(super) fn dump_mir_for_phase_change<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
     assert_eq!(body.pass_count, 0);
-    mir::dump_mir(tcx, true, body.phase.name(), &"after", body, |_, _| Ok(()))
+    mir::dump_mir(tcx, true, body.phase.name(), &"after", body, &|_, _| Ok(()))
 }
diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs
index c6760b3583f..39d4aaa9857 100644
--- a/compiler/rustc_mir_transform/src/shim.rs
+++ b/compiler/rustc_mir_transform/src/shim.rs
@@ -1248,7 +1248,7 @@ fn build_construct_coroutine_by_move_shim<'tcx>(
         if receiver_by_ref { "coroutine_closure_by_ref" } else { "coroutine_closure_by_move" },
         &0,
         &body,
-        |_, _| Ok(()),
+        &|_, _| Ok(()),
     );
 
     body