@@ -498,10 +498,6 @@ impl SourceMap {
498498 pub fn span_to_lines ( & self , sp : Span ) -> FileLinesResult {
499499 debug ! ( "span_to_lines(sp={:?})" , sp) ;
500500
501- if sp. lo ( ) > sp. hi ( ) {
502- return Err ( SpanLinesError :: IllFormedSpan ( sp) ) ;
503- }
504-
505501 let lo = self . lookup_char_pos ( sp. lo ( ) ) ;
506502 debug ! ( "span_to_lines: lo={:?}" , lo) ;
507503 let hi = self . lookup_char_pos ( sp. hi ( ) ) ;
@@ -549,10 +545,6 @@ impl SourceMap {
549545 fn span_to_source < F > ( & self , sp : Span , extract_source : F ) -> Result < String , SpanSnippetError >
550546 where F : Fn ( & str , usize , usize ) -> Result < String , SpanSnippetError >
551547 {
552- if sp. lo ( ) > sp. hi ( ) {
553- return Err ( SpanSnippetError :: IllFormedSpan ( sp) ) ;
554- }
555-
556548 let local_begin = self . lookup_byte_offset ( sp. lo ( ) ) ;
557549 let local_end = self . lookup_byte_offset ( sp. hi ( ) ) ;
558550
@@ -762,14 +754,14 @@ impl SourceMap {
762754
763755 /// Finds the width of a character, either before or after the provided span.
764756 fn find_width_of_character_at_span ( & self , sp : Span , forwards : bool ) -> u32 {
765- // Disregard malformed spans and assume a one-byte wide character.
766- if sp. lo ( ) >= sp. hi ( ) {
767- debug ! ( "find_width_of_character_at_span: early return malformed span" ) ;
757+ let sp = sp . data ( ) ;
758+ if sp. lo == sp. hi {
759+ debug ! ( "find_width_of_character_at_span: early return empty span" ) ;
768760 return 1 ;
769761 }
770762
771- let local_begin = self . lookup_byte_offset ( sp. lo ( ) ) ;
772- let local_end = self . lookup_byte_offset ( sp. hi ( ) ) ;
763+ let local_begin = self . lookup_byte_offset ( sp. lo ) ;
764+ let local_end = self . lookup_byte_offset ( sp. hi ) ;
773765 debug ! ( "find_width_of_character_at_span: local_begin=`{:?}`, local_end=`{:?}`" ,
774766 local_begin, local_end) ;
775767
0 commit comments