diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-08-13 19:51:32 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-08-15 10:42:31 +0300 |
| commit | 66dc08ad604cdb75cbc2a89d3551c51fbc6cc20e (patch) | |
| tree | 08ea2138360902194a89b8955ac6399b0a7f903c /src/libsyntax/ext | |
| parent | 9e9a136fcec5eb78f09a14dfd072a51ae2550269 (diff) | |
| download | rust-66dc08ad604cdb75cbc2a89d3551c51fbc6cc20e.tar.gz rust-66dc08ad604cdb75cbc2a89d3551c51fbc6cc20e.zip | |
Make sure that all file loading happens via SourceMap
That way, callers don't need to repeat "let's add this to sm manually for tracking dependencies" trick. It should make it easier to switch to using `FileLoader` for binary files in the future as well
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 402b42dfbc8..e9789764383 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -25,7 +25,6 @@ use syntax_pos::{Span, DUMMY_SP, FileName}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; -use std::fs; use std::io::ErrorKind; use std::{iter, mem}; use std::ops::DerefMut; @@ -1239,13 +1238,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } let filename = self.cx.resolve_path(&*file.as_str(), it.span()); - match fs::read_to_string(&filename) { - Ok(src) => { - let src_interned = Symbol::intern(&src); - - // Add this input file to the code map to make it available as - // dependency information - self.cx.source_map().new_source_file(filename.into(), src); + match self.cx.source_map().load_file(&filename) { + Ok(source_file) => { + let src = source_file.src.as_ref() + .expect("freshly loaded file should have a source"); + let src_interned = Symbol::intern(src.as_str()); let include_info = vec