about summary refs log tree commit diff
path: root/src/librustc_parse
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-08-30 01:44:01 +0200
committerGitHub <noreply@github.com>2020-08-30 01:44:01 +0200
commit9d7d24d5160469741de87df98664b27b09393488 (patch)
tree7ed5ec1d3f0bac738d77606139a936ce8564c23e /src/librustc_parse
parent11193ca202a765e13d258627933494cd25e38482 (diff)
parent6621895365ea70bcfaf09bb05e35d64c2f52e4c6 (diff)
downloadrust-9d7d24d5160469741de87df98664b27b09393488.tar.gz
rust-9d7d24d5160469741de87df98664b27b09393488.zip
Rollup merge of #76057 - matklad:remove-retokenize, r=petrochenkov
Move retokenize hack to save_analysis

closes #76046
Diffstat (limited to 'src/librustc_parse')
-rw-r--r--src/librustc_parse/lexer/mod.rs30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs
index 7503f15ac55..a65d3446819 100644
--- a/src/librustc_parse/lexer/mod.rs
+++ b/src/librustc_parse/lexer/mod.rs
@@ -46,19 +46,10 @@ impl<'a> StringReader<'a> {
         source_file: Lrc<rustc_span::SourceFile>,
         override_span: Option<Span>,
     ) -> Self {
-        // Make sure external source is loaded first, before accessing it.
-        // While this can't show up during normal parsing, `retokenize` may
-        // be called with a source file from an external crate.
-        sess.source_map().ensure_source_file_source_present(Lrc::clone(&source_file));
-
-        let src = if let Some(src) = &source_file.src {
-            Lrc::clone(&src)
-        } else if let Some(src) = source_file.external_src.borrow().get_source() {
-            Lrc::clone(&src)
-        } else {
+        let src = source_file.src.clone().unwrap_or_else(|| {
             sess.span_diagnostic
                 .bug(&format!("cannot lex `source_file` without source: {}", source_file.name));
-        };
+        });
 
         StringReader {
             sess,
@@ -70,23 +61,6 @@ impl<'a> StringReader<'a> {
         }
     }
 
-    pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
-        let begin = sess.source_map().lookup_byte_offset(span.lo());
-        let end = sess.source_map().lookup_byte_offset(span.hi());
-
-        // Make the range zero-length if the span is invalid.
-        if begin.sf.start_pos != end.sf.start_pos {
-            span = span.shrink_to_lo();
-        }
-
-        let mut sr = StringReader::new(sess, begin.sf, None);
-
-        // Seek the lexer to the right byte range.
-        sr.end_src_index = sr.src_index(span.hi());
-
-        sr
-    }
-
     fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span {
         self.override_span.unwrap_or_else(|| Span::with_root_ctxt(lo, hi))
     }