File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
compiler/rustc_borrowck/src/diagnostics Expand file tree Collapse file tree 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>(
14741474 // let x: &i32 = &'a 5;
14751475 // ^^ lifetime annotation not allowed
14761476 //
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 ( '&' )
14801480 {
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 " ) ;
14821482 // We don't support raw refs yet
14831483 if is_raw_ref {
14841484 return None ;
14851485 }
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" ) {
14871487 match rest. chars ( ) . next ( ) {
14881488 // e.g. `&mut x`
14891489 Some ( c) if c. is_whitespace ( ) => true ,
@@ -1500,7 +1500,7 @@ fn suggest_ampmut<'tcx>(
15001500 // if the reference is already mutable then there is nothing we can do
15011501 // here.
15021502 if !is_mut {
1503- let span = assignment_rhs_span ;
1503+ let span = rhs_span ;
15041504 // shrink the span to just after the `&` in `&variable`
15051505 let span = span. with_lo ( span. lo ( ) + BytePos ( 1 ) ) . shrink_to_lo ( ) ;
15061506
You can’t perform that action at this time.
0 commit comments