@@ -911,12 +911,13 @@ impl SourceMap {
911
911
912
912
/// Returns a new span representing just the last character of this span.
913
913
pub fn end_point ( & self , sp : Span ) -> Span {
914
- let pos = sp. hi ( ) . 0 ;
914
+ let sp = sp. data ( ) ;
915
+ let pos = sp. hi . 0 ;
915
916
916
917
let width = self . find_width_of_character_at_span ( sp, false ) ;
917
918
let corrected_end_position = pos. checked_sub ( width) . unwrap_or ( pos) ;
918
919
919
- let end_point = BytePos ( cmp:: max ( corrected_end_position, sp. lo ( ) . 0 ) ) ;
920
+ let end_point = BytePos ( cmp:: max ( corrected_end_position, sp. lo . 0 ) ) ;
920
921
sp. with_lo ( end_point)
921
922
}
922
923
@@ -930,8 +931,9 @@ impl SourceMap {
930
931
if sp. is_dummy ( ) {
931
932
return sp;
932
933
}
933
- let start_of_next_point = sp. hi ( ) . 0 ;
934
934
935
+ let sp = sp. data ( ) ;
936
+ let start_of_next_point = sp. hi . 0 ;
935
937
let width = self . find_width_of_character_at_span ( sp, true ) ;
936
938
// If the width is 1, then the next span should only contain the next char besides current ending.
937
939
// However, in the case of a multibyte character, where the width != 1, the next span should
@@ -940,7 +942,7 @@ impl SourceMap {
940
942
start_of_next_point. checked_add ( width) . unwrap_or ( start_of_next_point) ;
941
943
942
944
let end_of_next_point = BytePos ( cmp:: max ( start_of_next_point + 1 , end_of_next_point) ) ;
943
- Span :: new ( BytePos ( start_of_next_point) , end_of_next_point, sp. ctxt ( ) , None )
945
+ Span :: new ( BytePos ( start_of_next_point) , end_of_next_point, sp. ctxt , None )
944
946
}
945
947
946
948
/// Check whether span is followed by some specified expected string in limit scope
@@ -963,9 +965,7 @@ impl SourceMap {
963
965
/// Finds the width of the character, either before or after the end of provided span,
964
966
/// depending on the `forwards` parameter.
965
967
#[ instrument( skip( self , sp) ) ]
966
- fn find_width_of_character_at_span ( & self , sp : Span , forwards : bool ) -> u32 {
967
- let sp = sp. data ( ) ;
968
-
968
+ fn find_width_of_character_at_span ( & self , sp : SpanData , forwards : bool ) -> u32 {
969
969
if sp. lo == sp. hi && !forwards {
970
970
debug ! ( "early return empty span" ) ;
971
971
return 1 ;
0 commit comments