about summary refs log tree commit diff
path: root/src/librustc_parse
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-08-29 11:38:15 +0200
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-08-29 12:29:06 +0200
commit6621895365ea70bcfaf09bb05e35d64c2f52e4c6 (patch)
treefc5b322a8efbc56c7049debf4117f7f1b7721bd9 /src/librustc_parse
parentc03c213daf5fe3b52c768b4f145e45d8994d87ea (diff)
downloadrust-6621895365ea70bcfaf09bb05e35d64c2f52e4c6.tar.gz
rust-6621895365ea70bcfaf09bb05e35d64c2f52e4c6.zip
Move retokenize hack to save_analysis
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 675cfa41f10..fdcabe41673 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))
     }