@@ -648,7 +648,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
648648 ) ,
649649 match & args[ ..] {
650650 [ ] => (
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( ) ) ,
652655 ")" . to_string( ) ,
653656 ) ,
654657 [ first, ..] => ( base. span. between( first. span) , ", " . to_string( ) ) ,
@@ -774,8 +777,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
774777 "use `?` to coerce and return an appropriate `Err`, and wrap the resulting value \
775778 in `Ok` so the expression remains of type `Result`",
776779 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( ) ) ,
779782 ] ,
780783 Applicability :: MaybeIncorrect ,
781784 ) ;
@@ -846,20 +849,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
846849 } else {
847850 return false ;
848851 } ;
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+ ) {
855855 // Add a semicolon, except after `}`.
856856 let semicolon =
857857 match self . tcx . sess . source_map ( ) . span_to_snippet ( span) {
858858 Ok ( s) if s. ends_with ( '}' ) => "" ,
859859 _ => ";" ,
860860 } ;
861861 err. span_suggestions (
862- self . tcx . adjust_span ( span) . shrink_to_hi ( ) ,
862+ self . tcx . mark_span_for_resize ( span) . shrink_to_hi ( ) ,
863863 "try adding an expression at the end of the block" ,
864864 return_suggestions
865865 . into_iter ( )
@@ -938,10 +938,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
938938
939939 vec ! [
940940 (
941- self . tcx. adjust_span ( expr. span) . shrink_to_lo( ) ,
941+ self . tcx. mark_span_for_resize ( expr. span) . shrink_to_lo( ) ,
942942 format!( "{prefix}{variant}{open}" ) ,
943943 ) ,
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( ) ) ,
945945 ]
946946 } ;
947947
@@ -1025,8 +1025,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10251025 err. multipart_suggestion (
10261026 format ! ( "consider calling `{s}::new`" ) ,
10271027 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}" ) ) ,
10301030 ] ,
10311031 Applicability :: MaybeIncorrect ,
10321032 ) ;
@@ -1280,7 +1280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12801280 && replace_prefix ( & src, "\" " , "b\" " ) . is_some ( )
12811281 {
12821282 return Some ( (
1283- self . tcx . adjust_span ( sp) . shrink_to_lo ( ) ,
1283+ self . tcx . mark_span_for_resize ( sp) . shrink_to_lo ( ) ,
12841284 "consider adding a leading `b`" . to_string ( ) ,
12851285 "b" . to_string ( ) ,
12861286 Applicability :: MachineApplicable ,
@@ -1477,7 +1477,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14771477 _ if sp == expr. span => {
14781478 if let Some ( mut steps) = self . deref_steps ( checked_ty, expected) {
14791479 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 ( ) ;
14811481 let mut remove = String :: new ( ) ;
14821482
14831483 // Try peeling off any existing `&` and `&mut` to reach our target type
@@ -1548,7 +1548,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15481548 return None ;
15491549 } else if let Some ( expr) = self . maybe_get_block_expr ( expr) {
15501550 // 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 ( ) )
15521552 } else {
15531553 ( prefix_span, format ! ( "{}{}" , prefix, "*" . repeat( steps) ) )
15541554 } ;
@@ -1606,7 +1606,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16061606 if field. is_shorthand {
16071607 // This is a field literal
16081608 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 ( ) ,
16101610 format ! ( "{}: " , field. ident) ,
16111611 ) ) ;
16121612 } else {
@@ -1664,20 +1664,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16641664 ) ;
16651665
16661666 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 ( ) ) ) ;
16681668 ")"
16691669 } else {
16701670 ""
16711671 } ;
16721672
16731673 let mut cast_suggestion = sugg. clone ( ) ;
16741674 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 ( ) ,
16761676 format ! ( "{close_paren} as {expected_ty}" ) ,
16771677 ) ) ;
16781678 let mut into_suggestion = sugg. clone ( ) ;
16791679 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 ( ) ,
16811681 format ! ( "{close_paren}.into()" ) ,
16821682 ) ) ;
16831683 let mut suffix_suggestion = sugg. clone ( ) ;
@@ -1734,17 +1734,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17341734 ) ;
17351735 let suggestion = vec ! [
17361736 (
1737- self . tcx. adjust_span ( lhs_expr. span) . shrink_to_lo( ) ,
1737+ self . tcx. mark_span_for_resize ( lhs_expr. span) . shrink_to_lo( ) ,
17381738 format!( "{checked_ty}::from(" ) ,
17391739 ) ,
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+ ) ,
17411744 ] ;
17421745 ( msg, suggestion)
17431746 } else {
17441747 let msg = format ! ( "{msg} and panic if the converted value doesn't fit" ) ;
17451748 let mut suggestion = sugg. clone ( ) ;
17461749 suggestion. push ( (
1747- self . tcx . adjust_span ( expr. span ) . shrink_to_hi ( ) ,
1750+ self . tcx . mark_span_for_resize ( expr. span ) . shrink_to_hi ( ) ,
17481751 format ! ( "{close_paren}.try_into().unwrap()" ) ,
17491752 ) ) ;
17501753 ( msg, suggestion)
0 commit comments