about summary refs log tree commit diff
diff options
context:
space:
mode:
authordianne <diannes.gm@gmail.com>2025-02-19 10:01:13 -0800
committerdianne <diannes.gm@gmail.com>2025-02-19 10:01:13 -0800
commit2be26f0fe80ce2bcf25653ad3e4ca7fe9f4d4b26 (patch)
tree2d3b562ba7feba8138542329a2b65367800c2766
parent452c14e7c2f749a664ada644d294d40187c0a540 (diff)
downloadrust-2be26f0fe80ce2bcf25653ad3e4ca7fe9f4d4b26.tar.gz
rust-2be26f0fe80ce2bcf25653ad3e4ca7fe9f4d4b26.zip
add clarifying comments to chars used for label-trimming
-rw-r--r--compiler/rustc_hir_typeck/src/pat.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 00ee3e10db1..0ef1b923399 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -835,7 +835,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     self.add_rust_2024_migration_desugared_pat(
                         pat_info.top_info.hir_id,
                         pat,
-                        't',
+                        't', // last char of `mut`
                         def_br_mutbl,
                     );
                     BindingMode(ByRef::No, Mutability::Mut)
@@ -848,7 +848,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     self.add_rust_2024_migration_desugared_pat(
                         pat_info.top_info.hir_id,
                         pat,
-                        if user_br_mutbl.is_mut() { 't' } else { 'f' },
+                        match user_br_mutbl {
+                            Mutability::Not => 'f', // last char of `ref`
+                            Mutability::Mut => 't', // last char of `ref mut`
+                        },
                         def_br_mutbl,
                     );
                 }
@@ -2387,7 +2390,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     self.add_rust_2024_migration_desugared_pat(
                         pat_info.top_info.hir_id,
                         pat,
-                        if pat_mutbl.is_mut() { 't' } else { '&' },
+                        match pat_mutbl {
+                            Mutability::Not => '&', // last char of `&`
+                            Mutability::Mut => 't', // last char of `&mut`
+                        },
                         inh_mut,
                     )
                 }