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.
This commit is contained in:
parent
85641f729f
commit
bfb027a50d
1 changed files with 6 additions and 6 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue