about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-08-15 09:13:23 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2025-09-01 08:52:34 +1000
commitd7faa5630daf13c3d298e81ac329bf048a0d5a01 (patch)
treedc6f4653c701460aff4f0f1a0983ab7295043915 /compiler/rustc_middle/src
parent3a0d0be586c0135bff8e8e2a280ee647337a07e7 (diff)
downloadrust-d7faa5630daf13c3d298e81ac329bf048a0d5a01.tar.gz
rust-d7faa5630daf13c3d298e81ac329bf048a0d5a01.zip
Avoid unnecessary `mut`-ness for various closures.
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/mir/pretty.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs
index 94f9c58b5cf..c2cc2042581 100644
--- a/compiler/rustc_middle/src/mir/pretty.rs
+++ b/compiler/rustc_middle/src/mir/pretty.rs
@@ -91,7 +91,7 @@ pub fn dump_mir<'tcx, F>(
     body: &Body<'tcx>,
     extra_data: F,
 ) where
-    F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
 {
     dump_mir_with_options(
         tcx,
@@ -119,7 +119,7 @@ pub fn dump_mir_with_options<'tcx, F>(
     extra_data: F,
     options: PrettyPrintMirOptions,
 ) where
-    F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
 {
     if !dump_enabled(tcx, pass_name, body.source.def_id()) {
         return;
@@ -171,11 +171,11 @@ pub fn dump_mir_to_writer<'tcx, F>(
     disambiguator: &dyn Display,
     body: &Body<'tcx>,
     w: &mut dyn io::Write,
-    mut extra_data: F,
+    extra_data: F,
     options: PrettyPrintMirOptions,
 ) -> io::Result<()>
 where
-    F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
 {
     // see notes on #41697 above
     let def_path =
@@ -193,7 +193,7 @@ where
     writeln!(w)?;
     extra_data(PassWhere::BeforeCFG, w)?;
     write_user_type_annotations(tcx, body, w)?;
-    write_mir_fn(tcx, body, &mut extra_data, w, options)?;
+    write_mir_fn(tcx, body, &extra_data, w, options)?;
     extra_data(PassWhere::AfterCFG, w)
 }
 
@@ -343,11 +343,11 @@ pub fn write_mir_pretty<'tcx>(
         }
 
         let render_body = |w: &mut dyn io::Write, body| -> io::Result<()> {
-            write_mir_fn(tcx, body, &mut |_, _| Ok(()), w, options)?;
+            write_mir_fn(tcx, body, &|_, _| Ok(()), w, options)?;
 
             for body in tcx.promoted_mir(def_id) {
                 writeln!(w)?;
-                write_mir_fn(tcx, body, &mut |_, _| Ok(()), w, options)?;
+                write_mir_fn(tcx, body, &|_, _| Ok(()), w, options)?;
             }
             Ok(())
         };
@@ -359,7 +359,7 @@ pub fn write_mir_pretty<'tcx>(
             writeln!(w, "// MIR FOR CTFE")?;
             // Do not use `render_body`, as that would render the promoteds again, but these
             // are shared between mir_for_ctfe and optimized_mir
-            write_mir_fn(tcx, tcx.mir_for_ctfe(def_id), &mut |_, _| Ok(()), w, options)?;
+            write_mir_fn(tcx, tcx.mir_for_ctfe(def_id), &|_, _| Ok(()), w, options)?;
         } else {
             let instance_mir = tcx.instance_mir(ty::InstanceKind::Item(def_id));
             render_body(w, instance_mir)?;
@@ -372,12 +372,12 @@ pub fn write_mir_pretty<'tcx>(
 pub fn write_mir_fn<'tcx, F>(
     tcx: TyCtxt<'tcx>,
     body: &Body<'tcx>,
-    extra_data: &mut F,
+    extra_data: &F,
     w: &mut dyn io::Write,
     options: PrettyPrintMirOptions,
 ) -> io::Result<()>
 where
-    F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
 {
     write_mir_intro(tcx, body, w, options)?;
     for block in body.basic_blocks.indices() {
@@ -710,12 +710,12 @@ fn write_basic_block<'tcx, F>(
     tcx: TyCtxt<'tcx>,
     block: BasicBlock,
     body: &Body<'tcx>,
-    extra_data: &mut F,
+    extra_data: &F,
     w: &mut dyn io::Write,
     options: PrettyPrintMirOptions,
 ) -> io::Result<()>
 where
-    F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+    F: Fn(PassWhere, &mut dyn io::Write) -> io::Result<()>,
 {
     let data = &body[block];
 
@@ -1363,11 +1363,11 @@ fn post_fmt_projection(projection: &[PlaceElem<'_>], fmt: &mut Formatter<'_>) ->
 fn write_extra<'tcx, F>(
     tcx: TyCtxt<'tcx>,
     write: &mut dyn io::Write,
-    mut visit_op: F,
+    visit_op: F,
     options: PrettyPrintMirOptions,
 ) -> io::Result<()>
 where
-    F: FnMut(&mut ExtraComments<'tcx>),
+    F: Fn(&mut ExtraComments<'tcx>),
 {
     if options.include_extra_comments {
         let mut extra_comments = ExtraComments { tcx, comments: vec![] };