diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 957dab39414..a5b131520c2 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -309,11 +309,6 @@ impl<'a> HashStable> for Span { // position that belongs to it, as opposed to hashing the first // position past it. let span = self.data(); - - if span.hi < span.lo { - return std_hash::Hash::hash(&TAG_INVALID_SPAN, hasher); - } - let (file_lo, line_lo, col_lo) = match hcx.source_map() .byte_pos_to_line_and_col(span.lo) { Some(pos) => pos, diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 21a7cf00b28..4dabea01c9e 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -796,11 +796,6 @@ where } let span_data = span.data(); - - if span_data.hi < span_data.lo { - return TAG_INVALID_SPAN.encode(self); - } - let (file_lo, line_lo, col_lo) = match self.source_map .byte_pos_to_line_and_col(span_data.lo) { Some(pos) => pos, diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 48cf117f65a..e2a7ea28b9b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -68,7 +68,7 @@ impl<'a> StringReader<'a> { let end = sess.source_map().lookup_byte_offset(span.hi()); // Make the range zero-length if the span is invalid. - if span.lo() > span.hi() || begin.sf.start_pos != end.sf.start_pos { + if begin.sf.start_pos != end.sf.start_pos { span = span.shrink_to_lo(); } diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index d7760e0cf9e..d9f618602a4 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -498,10 +498,6 @@ impl SourceMap { pub fn span_to_lines(&self, sp: Span) -> FileLinesResult { debug!("span_to_lines(sp={:?})", sp); - if sp.lo() > sp.hi() { - return Err(SpanLinesError::IllFormedSpan(sp)); - } - let lo = self.lookup_char_pos(sp.lo()); debug!("span_to_lines: lo={:?}", lo); let hi = self.lookup_char_pos(sp.hi()); @@ -549,10 +545,6 @@ impl SourceMap { fn span_to_source(&self, sp: Span, extract_source: F) -> Result where F: Fn(&str, usize, usize) -> Result { - if sp.lo() > sp.hi() { - return Err(SpanSnippetError::IllFormedSpan(sp)); - } - let local_begin = self.lookup_byte_offset(sp.lo()); let local_end = self.lookup_byte_offset(sp.hi()); @@ -762,14 +754,14 @@ impl SourceMap { /// Finds the width of a character, either before or after the provided span. fn find_width_of_character_at_span(&self, sp: Span, forwards: bool) -> u32 { - // Disregard malformed spans and assume a one-byte wide character. - if sp.lo() >= sp.hi() { - debug!("find_width_of_character_at_span: early return malformed span"); + let sp = sp.data(); + if sp.lo == sp.hi { + debug!("find_width_of_character_at_span: early return empty span"); return 1; } - let local_begin = self.lookup_byte_offset(sp.lo()); - let local_end = self.lookup_byte_offset(sp.hi()); + let local_begin = self.lookup_byte_offset(sp.lo); + let local_end = self.lookup_byte_offset(sp.hi); debug!("find_width_of_character_at_span: local_begin=`{:?}`, local_end=`{:?}`", local_begin, local_end); diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 9034f8c1afd..dc29b189639 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -1512,7 +1512,6 @@ pub type FileLinesResult = Result; #[derive(Clone, PartialEq, Eq, Debug)] pub enum SpanLinesError { - IllFormedSpan(Span), DistinctSources(DistinctSources), }