diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-09-03 15:37:03 +0200 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-09-03 15:52:15 +0200 |
| commit | 4231fbc0a8cb4b2b0df431d8ffcf308f837e07e3 (patch) | |
| tree | fa8fe4841b0f2a8a267b8156bd8658f10f06f628 /compiler/rustc_parse/src/lib.rs | |
| parent | 08deb863bdebfcbbb71c18acf903eca84f1df4e7 (diff) | |
| download | rust-4231fbc0a8cb4b2b0df431d8ffcf308f837e07e3.tar.gz rust-4231fbc0a8cb4b2b0df431d8ffcf308f837e07e3.zip | |
Condense StringReader's API to a single function
Diffstat (limited to 'compiler/rustc_parse/src/lib.rs')
| -rw-r--r-- | compiler/rustc_parse/src/lib.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 462279b0a9e..b804e8a825f 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -200,8 +200,13 @@ pub fn maybe_file_to_stream( source_file: Lrc<SourceFile>, override_span: Option<Span>, ) -> Result<(TokenStream, Vec<lexer::UnmatchedBrace>), Vec<Diagnostic>> { - let srdr = lexer::StringReader::new(sess, source_file, override_span); - let (token_trees, unmatched_braces) = srdr.into_token_trees(); + let src = source_file.src.as_ref().unwrap_or_else(|| { + sess.span_diagnostic + .bug(&format!("cannot lex `source_file` without source: {}", source_file.name)); + }); + + let (token_trees, unmatched_braces) = + lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span); match token_trees { Ok(stream) => Ok((stream, unmatched_braces)), |
