about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorMartin Nordholts <martin.nordholts@codetale.se>2024-12-16 20:24:34 +0100
committerMartin Nordholts <martin.nordholts@codetale.se>2024-12-16 20:29:33 +0100
commitbfb027a50da1cd398159f09a7ce0acbf87b33eac (patch)
treec8bd74562e4e5c9593414787adb98ea25dac23f9 /compiler/rustc_borrowck/src
parent85641f729f43b3b826f2269f82817ea0b577613f (diff)
downloadrust-bfb027a50da1cd398159f09a7ce0acbf87b33eac.tar.gz
rust-bfb027a50da1cd398159f09a7ce0acbf87b33eac.zip
rustc_borrowck: suggest_ampmut(): Just rename some variables
By making the variable names more descriptive it becomes easier to
understand the code. Especially with the more complicated code in the
next commit.
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
index 4fb7b22f289..ed249555ae4 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
@@ -1474,16 +1474,16 @@ fn suggest_ampmut<'tcx>(
     // let x: &i32 = &'a 5;
     //                ^^ lifetime annotation not allowed
     //
-    if let Some(assignment_rhs_span) = opt_assignment_rhs_span
-        && let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
-        && let Some(stripped) = src.strip_prefix('&')
+    if let Some(rhs_span) = opt_assignment_rhs_span
+        && let Ok(rhs_str) = tcx.sess.source_map().span_to_snippet(rhs_span)
+        && let Some(rhs_str_no_amp) = rhs_str.strip_prefix('&')
     {
-        let is_raw_ref = stripped.trim_start().starts_with("raw ");
+        let is_raw_ref = rhs_str_no_amp.trim_start().starts_with("raw ");
         // We don't support raw refs yet
         if is_raw_ref {
             return None;
         }
-        let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") {
+        let is_mut = if let Some(rest) = rhs_str_no_amp.trim_start().strip_prefix("mut") {
             match rest.chars().next() {
                 // e.g. `&mut x`
                 Some(c) if c.is_whitespace() => true,
@@ -1500,7 +1500,7 @@ fn suggest_ampmut<'tcx>(
         // if the reference is already mutable then there is nothing we can do
         // here.
         if !is_mut {
-            let span = assignment_rhs_span;
+            let span = rhs_span;
             // shrink the span to just after the `&` in `&variable`
             let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo();