File tree 1 file changed +6
-6
lines changed
compiler/rustc_borrowck/src/diagnostics
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1474,16 +1474,16 @@ fn suggest_ampmut<'tcx>(
1474
1474
// let x: &i32 = &'a 5;
1475
1475
// ^^ lifetime annotation not allowed
1476
1476
//
1477
- if let Some ( assignment_rhs_span ) = opt_assignment_rhs_span
1478
- && let Ok ( src ) = tcx. sess . source_map ( ) . span_to_snippet ( assignment_rhs_span )
1479
- && let Some ( stripped ) = src . strip_prefix ( '&' )
1477
+ if let Some ( rhs_span ) = opt_assignment_rhs_span
1478
+ && let Ok ( rhs_str ) = tcx. sess . source_map ( ) . span_to_snippet ( rhs_span )
1479
+ && let Some ( rhs_str_no_amp ) = rhs_str . strip_prefix ( '&' )
1480
1480
{
1481
- let is_raw_ref = stripped . trim_start ( ) . starts_with ( "raw " ) ;
1481
+ let is_raw_ref = rhs_str_no_amp . trim_start ( ) . starts_with ( "raw " ) ;
1482
1482
// We don't support raw refs yet
1483
1483
if is_raw_ref {
1484
1484
return None ;
1485
1485
}
1486
- let is_mut = if let Some ( rest) = stripped . trim_start ( ) . strip_prefix ( "mut" ) {
1486
+ let is_mut = if let Some ( rest) = rhs_str_no_amp . trim_start ( ) . strip_prefix ( "mut" ) {
1487
1487
match rest. chars ( ) . next ( ) {
1488
1488
// e.g. `&mut x`
1489
1489
Some ( c) if c. is_whitespace ( ) => true ,
@@ -1500,7 +1500,7 @@ fn suggest_ampmut<'tcx>(
1500
1500
// if the reference is already mutable then there is nothing we can do
1501
1501
// here.
1502
1502
if !is_mut {
1503
- let span = assignment_rhs_span ;
1503
+ let span = rhs_span ;
1504
1504
// shrink the span to just after the `&` in `&variable`
1505
1505
let span = span. with_lo ( span. lo ( ) + BytePos ( 1 ) ) . shrink_to_lo ( ) ;
1506
1506
You can’t perform that action at this time.
0 commit comments