about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-05 20:22:27 +0000
committerbors <bors@rust-lang.org>2019-11-05 20:22:27 +0000
commit1423bec54cf2db283b614e527cfd602b481485d1 (patch)
tree8be41192c0d558c2b4f16e8c3d174f2b3552d5e8 /src/libsyntax
parent3a1b3b30c6cdd674049b144a3ced7b711de962b2 (diff)
parent135b7841829c5bb67e584bf57610139f55c7a10f (diff)
downloadrust-1423bec54cf2db283b614e527cfd602b481485d1.tar.gz
rust-1423bec54cf2db283b614e527cfd602b481485d1.zip
Auto merge of #66121 - pietroalbini:rollup-8zrwe7l, r=pietroalbini
Rollup of 8 pull requests

Successful merges:

 - #65948 (Improve MaybeUninit::get_{ref,mut} documentation)
 - #65953 (Allow specifying LLVM's MCTargetOptions::ABIName in target specification files)
 - #66012 (De-querify `trivial_dropck_outlives`.)
 - #66025 (`Span` cannot represent `span.hi < span.lo`)
 - #66047 (Don't double-count `simd_shuffle` promotion candidates)
 - #66053 (when Miri tests are not passing, do not add Miri component)
 - #66082 (clean highlightSourceLines code)
 - #66091 (Implemented the home_dir for VxWorks)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/lexer/mod.rs2
-rw-r--r--src/libsyntax/source_map.rs18
2 files changed, 6 insertions, 14 deletions
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<F>(&self, sp: Span, extract_source: F) -> Result<String, SpanSnippetError>
         where F: Fn(&str, usize, usize) -> Result<String, SpanSnippetError>
     {
-        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);