@@ -498,10 +498,6 @@ impl SourceMap {
498
498
pub fn span_to_lines ( & self , sp : Span ) -> FileLinesResult {
499
499
debug ! ( "span_to_lines(sp={:?})" , sp) ;
500
500
501
- if sp. lo ( ) > sp. hi ( ) {
502
- return Err ( SpanLinesError :: IllFormedSpan ( sp) ) ;
503
- }
504
-
505
501
let lo = self . lookup_char_pos ( sp. lo ( ) ) ;
506
502
debug ! ( "span_to_lines: lo={:?}" , lo) ;
507
503
let hi = self . lookup_char_pos ( sp. hi ( ) ) ;
@@ -549,10 +545,6 @@ impl SourceMap {
549
545
fn span_to_source < F > ( & self , sp : Span , extract_source : F ) -> Result < String , SpanSnippetError >
550
546
where F : Fn ( & str , usize , usize ) -> Result < String , SpanSnippetError >
551
547
{
552
- if sp. lo ( ) > sp. hi ( ) {
553
- return Err ( SpanSnippetError :: IllFormedSpan ( sp) ) ;
554
- }
555
-
556
548
let local_begin = self . lookup_byte_offset ( sp. lo ( ) ) ;
557
549
let local_end = self . lookup_byte_offset ( sp. hi ( ) ) ;
558
550
@@ -762,14 +754,14 @@ impl SourceMap {
762
754
763
755
/// Finds the width of a character, either before or after the provided span.
764
756
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" ) ;
768
760
return 1 ;
769
761
}
770
762
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 ) ;
773
765
debug ! ( "find_width_of_character_at_span: local_begin=`{:?}`, local_end=`{:?}`" ,
774
766
local_begin, local_end) ;
775
767
0 commit comments