@@ -648,7 +648,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
648
648
) ,
649
649
match & args[ ..] {
650
650
[ ] => (
651
- self . tcx. adjust_span( base. span) . shrink_to_hi( ) . with_hi( deref. span. hi( ) ) ,
651
+ self . tcx
652
+ . mark_span_for_resize( base. span)
653
+ . shrink_to_hi( )
654
+ . with_hi( deref. span. hi( ) ) ,
652
655
")" . to_string( ) ,
653
656
) ,
654
657
[ first, ..] => ( base. span. between( first. span) , ", " . to_string( ) ) ,
@@ -774,8 +777,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
774
777
"use `?` to coerce and return an appropriate `Err`, and wrap the resulting value \
775
778
in `Ok` so the expression remains of type `Result`",
776
779
vec ! [
777
- ( self . tcx. adjust_span ( expr. span) . shrink_to_lo( ) , "Ok(" . to_string( ) ) ,
778
- ( self . tcx. adjust_span ( expr. span) . shrink_to_hi( ) , "?)" . to_string( ) ) ,
780
+ ( self . tcx. mark_span_for_resize ( expr. span) . shrink_to_lo( ) , "Ok(" . to_string( ) ) ,
781
+ ( self . tcx. mark_span_for_resize ( expr. span) . shrink_to_hi( ) , "?)" . to_string( ) ) ,
779
782
] ,
780
783
Applicability :: MaybeIncorrect ,
781
784
) ;
@@ -846,20 +849,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
846
849
} else {
847
850
return false ;
848
851
} ;
849
- if let Some ( indent) = self
850
- . tcx
851
- . sess
852
- . source_map ( )
853
- . indentation_before ( self . tcx . adjust_span ( span) . shrink_to_lo ( ) )
854
- {
852
+ if let Some ( indent) = self . tcx . sess . source_map ( ) . indentation_before (
853
+ self . tcx . mark_span_for_resize ( span) . shrink_to_lo ( ) ,
854
+ ) {
855
855
// Add a semicolon, except after `}`.
856
856
let semicolon =
857
857
match self . tcx . sess . source_map ( ) . span_to_snippet ( span) {
858
858
Ok ( s) if s. ends_with ( '}' ) => "" ,
859
859
_ => ";" ,
860
860
} ;
861
861
err. span_suggestions (
862
- self . tcx . adjust_span ( span) . shrink_to_hi ( ) ,
862
+ self . tcx . mark_span_for_resize ( span) . shrink_to_hi ( ) ,
863
863
"try adding an expression at the end of the block" ,
864
864
return_suggestions
865
865
. into_iter ( )
@@ -938,10 +938,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
938
938
939
939
vec ! [
940
940
(
941
- self . tcx. adjust_span ( expr. span) . shrink_to_lo( ) ,
941
+ self . tcx. mark_span_for_resize ( expr. span) . shrink_to_lo( ) ,
942
942
format!( "{prefix}{variant}{open}" ) ,
943
943
) ,
944
- ( self . tcx. adjust_span ( expr. span) . shrink_to_hi( ) , close. to_owned( ) ) ,
944
+ ( self . tcx. mark_span_for_resize ( expr. span) . shrink_to_hi( ) , close. to_owned( ) ) ,
945
945
]
946
946
} ;
947
947
@@ -1025,8 +1025,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1025
1025
err. multipart_suggestion (
1026
1026
format ! ( "consider calling `{s}::new`" ) ,
1027
1027
vec ! [
1028
- ( self . tcx. adjust_span ( expr. span) . shrink_to_lo( ) , format!( "{path}::new(" ) ) ,
1029
- ( self . tcx. adjust_span ( expr. span) . shrink_to_hi( ) , format!( "){unwrap}" ) ) ,
1028
+ ( self . tcx. mark_span_for_resize ( expr. span) . shrink_to_lo( ) , format!( "{path}::new(" ) ) ,
1029
+ ( self . tcx. mark_span_for_resize ( expr. span) . shrink_to_hi( ) , format!( "){unwrap}" ) ) ,
1030
1030
] ,
1031
1031
Applicability :: MaybeIncorrect ,
1032
1032
) ;
@@ -1280,7 +1280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1280
1280
&& replace_prefix ( & src, "\" " , "b\" " ) . is_some ( )
1281
1281
{
1282
1282
return Some ( (
1283
- self . tcx . adjust_span ( sp) . shrink_to_lo ( ) ,
1283
+ self . tcx . mark_span_for_resize ( sp) . shrink_to_lo ( ) ,
1284
1284
"consider adding a leading `b`" . to_string ( ) ,
1285
1285
"b" . to_string ( ) ,
1286
1286
Applicability :: MachineApplicable ,
@@ -1477,7 +1477,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1477
1477
_ if sp == expr. span => {
1478
1478
if let Some ( mut steps) = self . deref_steps ( checked_ty, expected) {
1479
1479
let mut expr = expr. peel_blocks ( ) ;
1480
- let mut prefix_span = self . tcx . adjust_span ( expr. span ) . shrink_to_lo ( ) ;
1480
+ let mut prefix_span = self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_lo ( ) ;
1481
1481
let mut remove = String :: new ( ) ;
1482
1482
1483
1483
// Try peeling off any existing `&` and `&mut` to reach our target type
@@ -1548,7 +1548,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1548
1548
return None ;
1549
1549
} else if let Some ( expr) = self . maybe_get_block_expr ( expr) {
1550
1550
// prefix should be empty here..
1551
- ( self . tcx . adjust_span ( expr. span ) . shrink_to_lo ( ) , "*" . to_string ( ) )
1551
+ ( self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_lo ( ) , "*" . to_string ( ) )
1552
1552
} else {
1553
1553
( prefix_span, format ! ( "{}{}" , prefix, "*" . repeat( steps) ) )
1554
1554
} ;
@@ -1606,7 +1606,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1606
1606
if field. is_shorthand {
1607
1607
// This is a field literal
1608
1608
sugg. push ( (
1609
- self . tcx . adjust_span ( field. ident . span ) . shrink_to_lo ( ) ,
1609
+ self . tcx . mark_span_for_resize ( field. ident . span ) . shrink_to_lo ( ) ,
1610
1610
format ! ( "{}: " , field. ident) ,
1611
1611
) ) ;
1612
1612
} else {
@@ -1664,20 +1664,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1664
1664
) ;
1665
1665
1666
1666
let close_paren = if expr. precedence ( ) . order ( ) < PREC_POSTFIX {
1667
- sugg. push ( ( self . tcx . adjust_span ( expr. span ) . shrink_to_lo ( ) , "(" . to_string ( ) ) ) ;
1667
+ sugg. push ( ( self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_lo ( ) , "(" . to_string ( ) ) ) ;
1668
1668
")"
1669
1669
} else {
1670
1670
""
1671
1671
} ;
1672
1672
1673
1673
let mut cast_suggestion = sugg. clone ( ) ;
1674
1674
cast_suggestion. push ( (
1675
- self . tcx . adjust_span ( expr. span ) . shrink_to_hi ( ) ,
1675
+ self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_hi ( ) ,
1676
1676
format ! ( "{close_paren} as {expected_ty}" ) ,
1677
1677
) ) ;
1678
1678
let mut into_suggestion = sugg. clone ( ) ;
1679
1679
into_suggestion. push ( (
1680
- self . tcx . adjust_span ( expr. span ) . shrink_to_hi ( ) ,
1680
+ self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_hi ( ) ,
1681
1681
format ! ( "{close_paren}.into()" ) ,
1682
1682
) ) ;
1683
1683
let mut suffix_suggestion = sugg. clone ( ) ;
@@ -1734,17 +1734,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1734
1734
) ;
1735
1735
let suggestion = vec ! [
1736
1736
(
1737
- self . tcx. adjust_span ( lhs_expr. span) . shrink_to_lo( ) ,
1737
+ self . tcx. mark_span_for_resize ( lhs_expr. span) . shrink_to_lo( ) ,
1738
1738
format!( "{checked_ty}::from(" ) ,
1739
1739
) ,
1740
- ( self . tcx. adjust_span( lhs_expr. span) . shrink_to_hi( ) , ")" . to_string( ) ) ,
1740
+ (
1741
+ self . tcx. mark_span_for_resize( lhs_expr. span) . shrink_to_hi( ) ,
1742
+ ")" . to_string( ) ,
1743
+ ) ,
1741
1744
] ;
1742
1745
( msg, suggestion)
1743
1746
} else {
1744
1747
let msg = format ! ( "{msg} and panic if the converted value doesn't fit" ) ;
1745
1748
let mut suggestion = sugg. clone ( ) ;
1746
1749
suggestion. push ( (
1747
- self . tcx . adjust_span ( expr. span ) . shrink_to_hi ( ) ,
1750
+ self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_hi ( ) ,
1748
1751
format ! ( "{close_paren}.try_into().unwrap()" ) ,
1749
1752
) ) ;
1750
1753
( msg, suggestion)
0 commit comments