From c65547337831babea8d9052b960649309263df36 Mon Sep 17 00:00:00 2001 From: Donato Sciarra Date: Sat, 18 Aug 2018 12:13:35 +0200 Subject: [PATCH] mv CodeMap SourceMap --- src/librustc/hir/map/collector.rs | 4 +- src/librustc/hir/map/definitions.rs | 2 +- src/librustc/hir/print.rs | 10 ++-- src/librustc/ich/caching_codemap_view.rs | 6 +-- src/librustc/ich/hcx.rs | 8 ++-- src/librustc/session/mod.rs | 8 ++-- src/librustc/ty/query/on_disk_cache.rs | 8 ++-- src/librustc_driver/lib.rs | 4 +- src/librustc_driver/test.rs | 4 +- src/librustc_errors/emitter.rs | 8 ++-- src/librustc_errors/lib.rs | 10 ++-- src/librustc_metadata/decoder.rs | 4 +- src/librustc_resolve/lib.rs | 4 +- src/librustc_typeck/check/demand.rs | 2 +- src/librustdoc/core.rs | 8 ++-- src/librustdoc/html/highlight.rs | 6 +-- src/librustdoc/test.rs | 12 ++--- src/libsyntax/codemap.rs | 58 ++++++++++++------------ src/libsyntax/ext/base.rs | 4 +- src/libsyntax/json.rs | 12 ++--- src/libsyntax/parse/lexer/comments.rs | 4 +- src/libsyntax/parse/lexer/mod.rs | 36 +++++++-------- src/libsyntax/parse/mod.rs | 10 ++-- src/libsyntax/parse/parser.rs | 4 +- src/libsyntax/print/pprust.rs | 10 ++-- src/libsyntax/test.rs | 2 +- src/libsyntax/test_snippet.rs | 4 +- src/libsyntax_pos/lib.rs | 14 +++--- 28 files changed, 133 insertions(+), 133 deletions(-) diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 3934475bea9..ceeb31934e1 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -18,7 +18,7 @@ use session::CrateDisambiguator; use std::iter::repeat; use syntax::ast::{NodeId, CRATE_NODE_ID}; -use syntax::codemap::CodeMap; +use syntax::codemap::SourceMap; use syntax_pos::Span; use ich::StableHashingContext; @@ -122,7 +122,7 @@ pub(super) fn root(krate: &'hir Crate, pub(super) fn finalize_and_compute_crate_hash(mut self, crate_disambiguator: CrateDisambiguator, cstore: &dyn CrateStore, - codemap: &CodeMap, + codemap: &SourceMap, commandline_args_hash: u64) -> (Vec>, Svh) { self diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index c4b28fe2c43..7ecbf7ebbaf 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -739,7 +739,7 @@ fn name(&self) -> Symbol { LangItems, LangItemsMissing, NativeLibraries, - CodeMap, + SourceMap, Impls, ExportedSymbols }); diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 4499a378be2..512f78763b2 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -12,7 +12,7 @@ use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::codemap::{CodeMap, Spanned}; +use syntax::codemap::{SourceMap, Spanned}; use syntax::parse::ParseSess; use syntax::parse::lexer::comments; use syntax::print::pp::{self, Breaks}; @@ -85,7 +85,7 @@ fn nested(&self, state: &mut State, nested: Nested) -> io::Result<()> { pub struct State<'a> { pub s: pp::Printer<'a>, - cm: Option<&'a CodeMap>, + cm: Option<&'a SourceMap>, comments: Option>, literals: Peekable>, cur_cmnt: usize, @@ -129,7 +129,7 @@ fn bump_lit(&mut self) -> Option { /// Requires you to pass an input filename and reader so that /// it can scan the input text for comments and literals to /// copy forward. -pub fn print_crate<'a>(cm: &'a CodeMap, +pub fn print_crate<'a>(cm: &'a SourceMap, sess: &ParseSess, krate: &hir::Crate, filename: FileName, @@ -149,7 +149,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap, } impl<'a> State<'a> { - pub fn new_from_input(cm: &'a CodeMap, + pub fn new_from_input(cm: &'a SourceMap, sess: &ParseSess, filename: FileName, input: &mut dyn Read, @@ -173,7 +173,7 @@ pub fn new_from_input(cm: &'a CodeMap, }) } - pub fn new(cm: &'a CodeMap, + pub fn new(cm: &'a SourceMap, out: Box, ann: &'a dyn PpAnn, comments: Option>, diff --git a/src/librustc/ich/caching_codemap_view.rs b/src/librustc/ich/caching_codemap_view.rs index e5bf384d253..769c4cfe9fa 100644 --- a/src/librustc/ich/caching_codemap_view.rs +++ b/src/librustc/ich/caching_codemap_view.rs @@ -9,7 +9,7 @@ // except according to those terms. use rustc_data_structures::sync::Lrc; -use syntax::codemap::CodeMap; +use syntax::codemap::SourceMap; use syntax_pos::{BytePos, FileMap}; #[derive(Clone)] @@ -24,13 +24,13 @@ struct CacheEntry { #[derive(Clone)] pub struct CachingCodemapView<'cm> { - codemap: &'cm CodeMap, + codemap: &'cm SourceMap, line_cache: [CacheEntry; 3], time_stamp: usize, } impl<'cm> CachingCodemapView<'cm> { - pub fn new(codemap: &'cm CodeMap) -> CachingCodemapView<'cm> { + pub fn new(codemap: &'cm SourceMap) -> CachingCodemapView<'cm> { let files = codemap.files(); let first_file = files[0].clone(); let entry = CacheEntry { diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 329cc2216a4..91fbb1cc0fd 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -25,7 +25,7 @@ use syntax::ast; -use syntax::codemap::CodeMap; +use syntax::codemap::SourceMap; use syntax::ext::hygiene::SyntaxContext; use syntax::symbol::Symbol; use syntax_pos::{Span, DUMMY_SP}; @@ -58,7 +58,7 @@ pub struct StableHashingContext<'a> { // Very often, we are hashing something that does not need the // CachingCodemapView, so we initialize it lazily. - raw_codemap: &'a CodeMap, + raw_codemap: &'a SourceMap, caching_codemap: Option>, pub(super) alloc_id_recursion_tracker: FxHashSet, @@ -308,9 +308,9 @@ impl<'a> HashStable> for Span { // Hash a span in a stable way. We can't directly hash the span's BytePos // fields (that would be similar to hashing pointers, since those are just - // offsets into the CodeMap). Instead, we hash the (file name, line, column) + // offsets into the SourceMap). Instead, we hash the (file name, line, column) // triple, which stays the same even if the containing FileMap has moved - // within the CodeMap. + // within the SourceMap. // Also note that we are hashing byte offsets for the column, not unicode // codepoint offsets. For the purpose of the hash that's sufficient. // Also, hashing filenames is expensive so we avoid doing it twice when the diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 3dc697e6adb..05f8e3cfb00 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -484,7 +484,7 @@ pub fn diag_span_suggestion_once<'a, 'b>( ); } - pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap { + pub fn codemap<'a>(&'a self) -> &'a codemap::SourceMap { self.parse_sess.codemap() } pub fn verbose(&self) -> bool { @@ -984,7 +984,7 @@ pub fn build_session( sopts, local_crate_source_file, registry, - Lrc::new(codemap::CodeMap::new(file_path_mapping)), + Lrc::new(codemap::SourceMap::new(file_path_mapping)), None, ) } @@ -993,7 +993,7 @@ pub fn build_session_with_codemap( sopts: config::Options, local_crate_source_file: Option, registry: errors::registry::Registry, - codemap: Lrc, + codemap: Lrc, emitter_dest: Option>, ) -> Session { // FIXME: This is not general enough to make the warning lint completely override @@ -1070,7 +1070,7 @@ pub fn build_session_( sopts: config::Options, local_crate_source_file: Option, span_diagnostic: errors::Handler, - codemap: Lrc, + codemap: Lrc, ) -> Session { let host_triple = TargetTriple::from_triple(config::host_triple()); let host = match Target::search(&host_triple) { diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index aa42b4072bd..1f0f6bee777 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -26,7 +26,7 @@ use session::{CrateDisambiguator, Session}; use std::mem; use syntax::ast::NodeId; -use syntax::codemap::{CodeMap, StableFilemapId}; +use syntax::codemap::{SourceMap, StableFilemapId}; use syntax_pos::{BytePos, Span, DUMMY_SP, FileMap}; use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo}; use ty; @@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> { prev_cnums: Vec<(u32, String, CrateDisambiguator)>, cnum_map: Once>>, - codemap: &'sess CodeMap, + codemap: &'sess SourceMap, file_index_to_stable_id: FxHashMap, // These two fields caches that are populated lazily during decoding. @@ -149,7 +149,7 @@ pub fn new(sess: &'sess Session, data: Vec, start_pos: usize) -> OnDiskCache } } - pub fn new_empty(codemap: &'sess CodeMap) -> OnDiskCache<'sess> { + pub fn new_empty(codemap: &'sess SourceMap) -> OnDiskCache<'sess> { OnDiskCache { serialized_data: Vec::new(), file_index_to_stable_id: FxHashMap(), @@ -475,7 +475,7 @@ fn compute_cnum_map(tcx: TyCtxt, struct CacheDecoder<'a, 'tcx: 'a, 'x> { tcx: TyCtxt<'a, 'tcx, 'tcx>, opaque: opaque::Decoder<'x>, - codemap: &'x CodeMap, + codemap: &'x SourceMap, cnum_map: &'x IndexVec>, synthetic_expansion_infos: &'x Lock>, file_index_to_file: &'x Lock>>, diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d25d57a004b..ed6e9db5e4e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -107,7 +107,7 @@ use std::thread; use syntax::ast; -use syntax::codemap::{CodeMap, FileLoader, RealFileLoader}; +use syntax::codemap::{SourceMap, FileLoader, RealFileLoader}; use syntax::feature_gate::{GatedCfg, UnstableFeatures}; use syntax::parse::{self, PResult}; use syntax_pos::{DUMMY_SP, MultiSpan, FileName}; @@ -522,7 +522,7 @@ fn run_compiler_with_pool<'a>( }; let loader = file_loader.unwrap_or(box RealFileLoader); - let codemap = Lrc::new(CodeMap::with_file_loader(loader, sopts.file_path_mapping())); + let codemap = Lrc::new(SourceMap::with_file_loader(loader, sopts.file_path_mapping())); let mut sess = session::build_session_with_codemap( sopts, input_file_path.clone(), descriptions, codemap, emitter_dest, ); diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 03651322bc9..a4bba31b669 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -32,7 +32,7 @@ use syntax; use syntax::ast; use rustc_target::spec::abi::Abi; -use syntax::codemap::{CodeMap, FilePathMapping, FileName}; +use syntax::codemap::{SourceMap, FilePathMapping, FileName}; use errors; use errors::emitter::Emitter; use errors::{Level, DiagnosticBuilder}; @@ -121,7 +121,7 @@ fn test_env_with_pool( let sess = session::build_session_(options, None, diagnostic_handler, - Lrc::new(CodeMap::new(FilePathMapping::empty()))); + Lrc::new(SourceMap::new(FilePathMapping::empty()))); let cstore = CStore::new(::get_codegen_backend(&sess).metadata_loader()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let input = config::Input::Str { diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 6b1298750fb..0a3e4d3ad25 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -12,7 +12,7 @@ use syntax_pos::{FileMap, Span, MultiSpan}; -use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapperDyn, DiagnosticId}; +use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId}; use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style}; use styled_buffer::StyledBuffer; @@ -120,7 +120,7 @@ fn to_color_choice(&self) -> ColorChoice { pub struct EmitterWriter { dst: Destination, - cm: Option>, + cm: Option>, short_message: bool, teach: bool, ui_testing: bool, @@ -134,7 +134,7 @@ struct FileWithAnnotatedLines { impl EmitterWriter { pub fn stderr(color_config: ColorConfig, - code_map: Option>, + code_map: Option>, short_message: bool, teach: bool) -> EmitterWriter { @@ -149,7 +149,7 @@ pub fn stderr(color_config: ColorConfig, } pub fn new(dst: Box, - code_map: Option>, + code_map: Option>, short_message: bool, teach: bool) -> EmitterWriter { diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 1666369e422..40d7a122d30 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -111,9 +111,9 @@ pub struct SubstitutionPart { pub snippet: String, } -pub type CodeMapperDyn = dyn CodeMapper + sync::Send + sync::Sync; +pub type SourceMapperDyn = dyn SourceMapper + sync::Send + sync::Sync; -pub trait CodeMapper { +pub trait SourceMapper { fn lookup_char_pos(&self, pos: BytePos) -> Loc; fn span_to_lines(&self, sp: Span) -> FileLinesResult; fn span_to_string(&self, sp: Span) -> String; @@ -126,7 +126,7 @@ pub trait CodeMapper { impl CodeSuggestion { /// Returns the assembled code suggestions and whether they should be shown with an underline. - pub fn splice_lines(&self, cm: &CodeMapperDyn) + pub fn splice_lines(&self, cm: &SourceMapperDyn) -> Vec<(String, Vec)> { use syntax_pos::{CharPos, Loc, Pos}; @@ -321,7 +321,7 @@ impl Handler { pub fn with_tty_emitter(color_config: ColorConfig, can_emit_warnings: bool, treat_err_as_bug: bool, - cm: Option>) + cm: Option>) -> Handler { Handler::with_tty_emitter_and_flags( color_config, @@ -334,7 +334,7 @@ pub fn with_tty_emitter(color_config: ColorConfig, } pub fn with_tty_emitter_and_flags(color_config: ColorConfig, - cm: Option>, + cm: Option>, flags: HandlerFlags) -> Handler { let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false)); diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 33d4cf26c03..4a17c5845fd 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1117,7 +1117,7 @@ pub fn def_path_hash(&self, index: DefIndex) -> DefPathHash { /// multibyte characters. This information is enough to generate valid debuginfo /// for items inlined from other crates. pub fn imported_filemaps(&'a self, - local_codemap: &codemap::CodeMap) + local_codemap: &codemap::SourceMap) -> ReadGuard<'a, Vec> { { let filemaps = self.codemap_import_info.borrow(); @@ -1154,7 +1154,7 @@ pub fn imported_filemaps(&'a self, // Translate line-start positions and multibyte character // position into frame of reference local to file. - // `CodeMap::new_imported_filemap()` will then translate those + // `SourceMap::new_imported_filemap()` will then translate those // coordinates to their new global frame of reference when the // offset of the FileMap is known. for pos in &mut lines { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2e163cb4c6a..0356bdae7dc 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -49,7 +49,7 @@ use rustc_metadata::creader::CrateLoader; use rustc_metadata::cstore::CStore; -use syntax::codemap::CodeMap; +use syntax::codemap::SourceMap; use syntax::ext::hygiene::{Mark, Transparency, SyntaxContext}; use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy}; use syntax::ext::base::SyntaxExtension; @@ -415,7 +415,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, /// Attention: The method used is very fragile since it essentially duplicates the work of the /// parser. If you need to use this function or something similar, please consider updating the /// codemap functions and this function to something more robust. -fn reduce_impl_span_to_impl_keyword(cm: &CodeMap, impl_span: Span) -> Span { +fn reduce_impl_span_to_impl_keyword(cm: &SourceMap, impl_span: Span) -> Span { let impl_span = cm.span_until_char(impl_span, '<'); let impl_span = cm.span_until_whitespace(impl_span); impl_span diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 92b35bd50f3..8bd53976e26 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -21,7 +21,7 @@ use rustc::hir::{Item, ItemKind, print}; use rustc::ty::{self, Ty, AssociatedItem}; use rustc::ty::adjustment::AllowTwoPhase; -use errors::{DiagnosticBuilder, CodeMapper}; +use errors::{DiagnosticBuilder, SourceMapper}; use super::method::probe; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 68e46183280..6b2cb53b8f1 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -258,9 +258,9 @@ fn is_doc_reachable(&self, did: DefId) -> bool { /// Creates a new diagnostic `Handler` that can be used to emit warnings and errors. /// -/// If the given `error_format` is `ErrorOutputType::Json` and no `CodeMap` is given, a new one +/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one /// will be created for the handler. -pub fn new_handler(error_format: ErrorOutputType, codemap: Option>) +pub fn new_handler(error_format: ErrorOutputType, codemap: Option>) -> errors::Handler { // rustdoc doesn't override (or allow to override) anything from this that is relevant here, so @@ -277,7 +277,7 @@ pub fn new_handler(error_format: ErrorOutputType, codemap: Option { let codemap = codemap.unwrap_or_else( - || Lrc::new(codemap::CodeMap::new(sessopts.file_path_mapping()))); + || Lrc::new(codemap::SourceMap::new(sessopts.file_path_mapping()))); Box::new( JsonEmitter::stderr( None, @@ -387,7 +387,7 @@ pub fn run_core(search_paths: SearchPaths, ..Options::default() }; driver::spawn_thread_pool(sessopts, move |sessopts| { - let codemap = Lrc::new(codemap::CodeMap::new(sessopts.file_path_mapping())); + let codemap = Lrc::new(codemap::SourceMap::new(sessopts.file_path_mapping())); let diagnostic_handler = new_handler(error_format, Some(codemap.clone())); let mut sess = session::build_session_( diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index ff2cc35fce8..a9137009115 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -21,7 +21,7 @@ use std::io; use std::io::prelude::*; -use syntax::codemap::{CodeMap, FilePathMapping}; +use syntax::codemap::{SourceMap, FilePathMapping}; use syntax::parse::lexer::{self, TokenAndSpan}; use syntax::parse::token; use syntax::parse; @@ -60,7 +60,7 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>, /// each span of text in sequence. struct Classifier<'a> { lexer: lexer::StringReader<'a>, - codemap: &'a CodeMap, + codemap: &'a SourceMap, // State of the classifier. in_attribute: bool, @@ -145,7 +145,7 @@ fn exit_span(&mut self) -> io::Result<()> { } impl<'a> Classifier<'a> { - fn new(lexer: lexer::StringReader<'a>, codemap: &'a CodeMap) -> Classifier<'a> { + fn new(lexer: lexer::StringReader<'a>, codemap: &'a SourceMap) -> Classifier<'a> { Classifier { lexer, codemap, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 569815c833a..605b08219a1 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -33,7 +33,7 @@ use rustc_metadata::cstore::CStore; use rustc_resolve::MakeGlobMap; use syntax::ast; -use syntax::codemap::CodeMap; +use syntax::codemap::SourceMap; use syntax::edition::Edition; use syntax::feature_gate::UnstableFeatures; use syntax::with_globals; @@ -86,7 +86,7 @@ pub fn run(input_path: &Path, ..config::Options::default() }; driver::spawn_thread_pool(sessopts, |sessopts| { - let codemap = Lrc::new(CodeMap::new(sessopts.file_path_mapping())); + let codemap = Lrc::new(SourceMap::new(sessopts.file_path_mapping())); let handler = errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, @@ -205,7 +205,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, // never wrap the test in `fn main() { ... }` let (test, line_offset) = make_test(test, Some(cratename), as_test_harness, opts); // FIXME(#44940): if doctests ever support path remapping, then this filename - // needs to be the result of CodeMap::span_to_unmapped_path + // needs to be the result of SourceMap::span_to_unmapped_path let input = config::Input::Str { name: filename.to_owned(), input: test.to_owned(), @@ -262,7 +262,7 @@ fn drop(&mut self) { let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); let (libdir, outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| { - let codemap = Lrc::new(CodeMap::new_doctest( + let codemap = Lrc::new(SourceMap::new_doctest( sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize )); let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()), @@ -500,7 +500,7 @@ pub struct Collector { opts: TestOptions, maybe_sysroot: Option, position: Span, - codemap: Option>, + codemap: Option>, filename: Option, linker: Option, edition: Edition, @@ -509,7 +509,7 @@ pub struct Collector { impl Collector { pub fn new(cratename: String, cfgs: Vec, libs: SearchPaths, cg: CodegenOptions, externs: Externs, use_headers: bool, opts: TestOptions, - maybe_sysroot: Option, codemap: Option>, + maybe_sysroot: Option, codemap: Option>, filename: Option, linker: Option, edition: Edition) -> Collector { Collector { tests: Vec::new(), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 0a9991d33b1..8175e2495c5 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! The CodeMap tracks all the source code used within a single crate, mapping +//! The SourceMap tracks all the source code used within a single crate, mapping //! from integer byte positions to the original source code location. Each bit //! of source parsed during crate parsing (typically files, in-memory strings, //! or various bits of macro expansion) cover a continuous range of bytes in the -//! CodeMap and are represented by FileMaps. Byte positions are stored in +//! SourceMap and are represented by FileMaps. Byte positions are stored in //! `spans` and used pervasively in the compiler. They are absolute positions -//! within the CodeMap, which upon request can be converted to line and column +//! within the SourceMap, which upon request can be converted to line and column //! information, source code snippets, etc. @@ -32,7 +32,7 @@ use std::env; use std::fs; use std::io::{self, Read}; -use errors::CodeMapper; +use errors::SourceMapper; /// Return the span itself if it doesn't come from a macro expansion, /// otherwise return the call site span up to the `enclosing_sp` by @@ -121,29 +121,29 @@ pub fn new(filemap: &FileMap) -> StableFilemapId { } // _____________________________________________________________________________ -// CodeMap +// SourceMap // -pub(super) struct CodeMapFiles { +pub(super) struct SourceMapFiles { pub(super) file_maps: Vec>, stable_id_to_filemap: FxHashMap> } -pub struct CodeMap { - pub(super) files: Lock, +pub struct SourceMap { + pub(super) files: Lock, file_loader: Box, // This is used to apply the file path remapping as specified via - // --remap-path-prefix to all FileMaps allocated within this CodeMap. + // --remap-path-prefix to all FileMaps allocated within this SourceMap. path_mapping: FilePathMapping, /// In case we are in a doctest, replace all file names with the PathBuf, /// and add the given offsets to the line info doctest_offset: Option<(FileName, isize)>, } -impl CodeMap { - pub fn new(path_mapping: FilePathMapping) -> CodeMap { - CodeMap { - files: Lock::new(CodeMapFiles { +impl SourceMap { + pub fn new(path_mapping: FilePathMapping) -> SourceMap { + SourceMap { + files: Lock::new(SourceMapFiles { file_maps: Vec::new(), stable_id_to_filemap: FxHashMap(), }), @@ -154,19 +154,19 @@ pub fn new(path_mapping: FilePathMapping) -> CodeMap { } pub fn new_doctest(path_mapping: FilePathMapping, - file: FileName, line: isize) -> CodeMap { - CodeMap { + file: FileName, line: isize) -> SourceMap { + SourceMap { doctest_offset: Some((file, line)), - ..CodeMap::new(path_mapping) + ..SourceMap::new(path_mapping) } } pub fn with_file_loader(file_loader: Box, path_mapping: FilePathMapping) - -> CodeMap { - CodeMap { - files: Lock::new(CodeMapFiles { + -> SourceMap { + SourceMap { + files: Lock::new(SourceMapFiles { file_maps: Vec::new(), stable_id_to_filemap: FxHashMap(), }), @@ -463,7 +463,7 @@ pub fn span_to_filename(&self, sp: Span) -> FileName { pub fn span_to_unmapped_path(&self, sp: Span) -> FileName { self.lookup_char_pos(sp.lo()).file.unmapped_path.clone() - .expect("CodeMap::span_to_unmapped_path called for imported FileMap?") + .expect("SourceMap::span_to_unmapped_path called for imported FileMap?") } pub fn is_multiline(&self, sp: Span) -> bool { @@ -941,7 +941,7 @@ pub fn generate_local_type_param_snippet(&self, span: Span) -> Option<(Span, Str } } -impl CodeMapper for CodeMap { +impl SourceMapper for SourceMap { fn lookup_char_pos(&self, pos: BytePos) -> Loc { self.lookup_char_pos(pos) } @@ -1023,8 +1023,8 @@ mod tests { use super::*; use rustc_data_structures::sync::Lrc; - fn init_code_map() -> CodeMap { - let cm = CodeMap::new(FilePathMapping::empty()); + fn init_code_map() -> SourceMap { + let cm = SourceMap::new(FilePathMapping::empty()); cm.new_filemap(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string()); cm.new_filemap(PathBuf::from("empty.rs").into(), @@ -1080,8 +1080,8 @@ fn t5() { assert_eq!(loc2.col, CharPos(0)); } - fn init_code_map_mbc() -> CodeMap { - let cm = CodeMap::new(FilePathMapping::empty()); + fn init_code_map_mbc() -> SourceMap { + let cm = SourceMap::new(FilePathMapping::empty()); // € is a three byte utf8 char. cm.new_filemap(PathBuf::from("blork.rs").into(), "fir€st €€€€ line.\nsecond line".to_string()); @@ -1135,7 +1135,7 @@ fn span_from_selection(input: &str, selection: &str) -> Span { /// lines in the middle of a file. #[test] fn span_to_snippet_and_lines_spanning_multiple_lines() { - let cm = CodeMap::new(FilePathMapping::empty()); + let cm = SourceMap::new(FilePathMapping::empty()); let inputtext = "aaaaa\nbbbbBB\nCCC\nDDDDDddddd\neee\n"; let selection = " \n ~~\n~~~\n~~~~~ \n \n"; cm.new_filemap(Path::new("blork.rs").to_owned().into(), inputtext.to_string()); @@ -1177,7 +1177,7 @@ fn t9() { /// Test failing to merge two spans on different lines #[test] fn span_merging_fail() { - let cm = CodeMap::new(FilePathMapping::empty()); + let cm = SourceMap::new(FilePathMapping::empty()); let inputtext = "bbbb BB\ncc CCC\n"; let selection1 = " ~~\n \n"; let selection2 = " \n ~~~\n"; @@ -1190,7 +1190,7 @@ fn span_merging_fail() { /// Returns the span corresponding to the `n`th occurrence of /// `substring` in `source_text`. - trait CodeMapExtension { + trait SourceMapExtension { fn span_substr(&self, file: &Lrc, source_text: &str, @@ -1199,7 +1199,7 @@ fn span_substr(&self, -> Span; } - impl CodeMapExtension for CodeMap { + impl SourceMapExtension for SourceMap { fn span_substr(&self, file: &Lrc, source_text: &str, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 482d8c2cf98..8ae4f9c1aa4 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -12,7 +12,7 @@ use ast::{self, Attribute, Name, PatKind, MetaItem}; use attr::HasAttrs; -use codemap::{self, CodeMap, Spanned, respan}; +use codemap::{self, SourceMap, Spanned, respan}; use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use edition::Edition; use errors::{DiagnosticBuilder, DiagnosticId}; @@ -836,7 +836,7 @@ pub fn monotonic_expander<'b>(&'b mut self) -> expand::MacroExpander<'b, 'a> { pub fn new_parser_from_tts(&self, tts: &[tokenstream::TokenTree]) -> parser::Parser<'a> { parse::stream_to_parser(self.parse_sess, tts.iter().cloned().collect()) } - pub fn codemap(&self) -> &'a CodeMap { self.parse_sess.codemap() } + pub fn codemap(&self) -> &'a SourceMap { self.parse_sess.codemap() } pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess } pub fn cfg(&self) -> &ast::CrateConfig { &self.parse_sess.config } pub fn call_site(&self) -> Span { diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 65de1503966..22de184938f 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -19,10 +19,10 @@ // FIXME spec the JSON output properly. -use codemap::{CodeMap, FilePathMapping}; +use codemap::{SourceMap, FilePathMapping}; use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan}; use errors::registry::Registry; -use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, CodeMapper}; +use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, SourceMapper}; use errors::{DiagnosticId, Applicability}; use errors::emitter::{Emitter, EmitterWriter}; @@ -36,14 +36,14 @@ pub struct JsonEmitter { dst: Box, registry: Option, - cm: Lrc, + cm: Lrc, pretty: bool, ui_testing: bool, } impl JsonEmitter { pub fn stderr(registry: Option, - code_map: Lrc, + code_map: Lrc, pretty: bool) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), @@ -56,13 +56,13 @@ pub fn stderr(registry: Option, pub fn basic(pretty: bool) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); - JsonEmitter::stderr(None, Lrc::new(CodeMap::new(file_path_mapping)), + JsonEmitter::stderr(None, Lrc::new(SourceMap::new(file_path_mapping)), pretty) } pub fn new(dst: Box, registry: Option, - code_map: Lrc, + code_map: Lrc, pretty: bool) -> JsonEmitter { JsonEmitter { dst, diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 2c53dbdc402..2c227756f9a 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -11,7 +11,7 @@ pub use self::CommentStyle::*; use ast; -use codemap::CodeMap; +use codemap::SourceMap; use syntax_pos::{BytePos, CharPos, Pos, FileName}; use parse::lexer::{is_block_doc_comment, is_pattern_whitespace}; use parse::lexer::{self, ParseSess, StringReader, TokenAndSpan}; @@ -371,7 +371,7 @@ pub fn gather_comments_and_literals(sess: &ParseSess, path: FileName, srdr: &mut { let mut src = String::new(); srdr.read_to_string(&mut src).unwrap(); - let cm = CodeMap::new(sess.codemap().path_mapping().clone()); + let cm = SourceMap::new(sess.codemap().path_mapping().clone()); let filemap = cm.new_filemap(path, src); let mut rdr = lexer::StringReader::new_raw(sess, filemap, None); diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index bdf25618f47..c1919434e37 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -10,7 +10,7 @@ use ast::{self, Ident}; use syntax_pos::{self, BytePos, CharPos, Pos, Span, NO_EXPANSION}; -use codemap::{CodeMap, FilePathMapping}; +use codemap::{SourceMap, FilePathMapping}; use errors::{Applicability, FatalError, DiagnosticBuilder}; use parse::{token, ParseSess}; use str::char_at; @@ -622,7 +622,7 @@ fn scan_comment(&mut self) -> Option { // I guess this is the only way to figure out if // we're at the beginning of the file... - let cmap = CodeMap::new(FilePathMapping::empty()); + let cmap = SourceMap::new(FilePathMapping::empty()); cmap.files.borrow_mut().file_maps.push(self.filemap.clone()); let loc = cmap.lookup_char_pos_adj(self.pos); debug!("Skipping a shebang"); @@ -1827,7 +1827,7 @@ mod tests { use ast::{Ident, CrateConfig}; use symbol::Symbol; use syntax_pos::{BytePos, Span, NO_EXPANSION}; - use codemap::CodeMap; + use codemap::SourceMap; use errors; use feature_gate::UnstableFeatures; use parse::token; @@ -1837,7 +1837,7 @@ mod tests { use diagnostics::plugin::ErrorMap; use rustc_data_structures::sync::Lock; use with_globals; - fn mk_sess(cm: Lrc) -> ParseSess { + fn mk_sess(cm: Lrc) -> ParseSess { let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(cm.clone()), false, @@ -1857,7 +1857,7 @@ fn mk_sess(cm: Lrc) -> ParseSess { } // open a string reader for the given string - fn setup<'a>(cm: &CodeMap, + fn setup<'a>(cm: &SourceMap, sess: &'a ParseSess, teststr: String) -> StringReader<'a> { @@ -1868,7 +1868,7 @@ fn setup<'a>(cm: &CodeMap, #[test] fn t1() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); let mut string_reader = setup(&cm, &sh, @@ -1916,7 +1916,7 @@ fn mk_ident(id: &str) -> token::Token { #[test] fn doublecolonparsing() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a b".to_string()), vec![mk_ident("a"), token::Whitespace, mk_ident("b")]); @@ -1926,7 +1926,7 @@ fn doublecolonparsing() { #[test] fn dcparsing_2() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a::b".to_string()), vec![mk_ident("a"), token::ModSep, mk_ident("b")]); @@ -1936,7 +1936,7 @@ fn dcparsing_2() { #[test] fn dcparsing_3() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a ::b".to_string()), vec![mk_ident("a"), token::Whitespace, token::ModSep, mk_ident("b")]); @@ -1946,7 +1946,7 @@ fn dcparsing_3() { #[test] fn dcparsing_4() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a:: b".to_string()), vec![mk_ident("a"), token::ModSep, token::Whitespace, mk_ident("b")]); @@ -1956,7 +1956,7 @@ fn dcparsing_4() { #[test] fn character_a() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "'a'".to_string()).next_token().tok, token::Literal(token::Char(Symbol::intern("a")), None)); @@ -1966,7 +1966,7 @@ fn character_a() { #[test] fn character_space() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "' '".to_string()).next_token().tok, token::Literal(token::Char(Symbol::intern(" ")), None)); @@ -1976,7 +1976,7 @@ fn character_space() { #[test] fn character_escaped() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "'\\n'".to_string()).next_token().tok, token::Literal(token::Char(Symbol::intern("\\n")), None)); @@ -1986,7 +1986,7 @@ fn character_escaped() { #[test] fn lifetime_name() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "'abc".to_string()).next_token().tok, token::Lifetime(Ident::from_str("'abc"))); @@ -1996,7 +1996,7 @@ fn lifetime_name() { #[test] fn raw_string() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()) .next_token() @@ -2008,7 +2008,7 @@ fn raw_string() { #[test] fn literal_suffixes() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); macro_rules! test { ($input: expr, $tok_type: ident, $tok_contents: expr) => {{ @@ -2054,7 +2054,7 @@ fn line_doc_comments() { #[test] fn nested_block_comments() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); let mut lexer = setup(&cm, &sh, "/* /* */ */'a'".to_string()); match lexer.next_token().tok { @@ -2069,7 +2069,7 @@ fn nested_block_comments() { #[test] fn crlf_comments() { with_globals(|| { - let cm = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(cm.clone()); let mut lexer = setup(&cm, &sh, "// test\r\n/// test\r\n".to_string()); let comment = lexer.next_token(); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d029509f0c1..d43cbf38064 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -13,7 +13,7 @@ use rustc_data_structures::sync::{Lrc, Lock}; use ast::{self, CrateConfig, NodeId}; use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; -use codemap::{CodeMap, FilePathMapping}; +use codemap::{SourceMap, FilePathMapping}; use syntax_pos::{Span, FileMap, FileName, MultiSpan}; use errors::{Handler, ColorConfig, DiagnosticBuilder}; use feature_gate::UnstableFeatures; @@ -57,13 +57,13 @@ pub struct ParseSess { pub non_modrs_mods: Lock>, /// Used to determine and report recursive mod inclusions included_mod_stack: Lock>, - code_map: Lrc, + code_map: Lrc, pub buffered_lints: Lock>, } impl ParseSess { pub fn new(file_path_mapping: FilePathMapping) -> Self { - let cm = Lrc::new(CodeMap::new(file_path_mapping)); + let cm = Lrc::new(SourceMap::new(file_path_mapping)); let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, @@ -71,7 +71,7 @@ pub fn new(file_path_mapping: FilePathMapping) -> Self { ParseSess::with_span_handler(handler, cm) } - pub fn with_span_handler(handler: Handler, code_map: Lrc) -> ParseSess { + pub fn with_span_handler(handler: Handler, code_map: Lrc) -> ParseSess { ParseSess { span_diagnostic: handler, unstable_features: UnstableFeatures::from_environment(), @@ -86,7 +86,7 @@ pub fn with_span_handler(handler: Handler, code_map: Lrc) -> ParseSess } } - pub fn codemap(&self) -> &CodeMap { + pub fn codemap(&self) -> &SourceMap { &self.code_map } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 345464c6664..1e6c1eee483 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -42,7 +42,7 @@ use ast::{BinOpKind, UnOp}; use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; -use codemap::{self, CodeMap, Spanned, respan}; +use codemap::{self, SourceMap, Spanned, respan}; use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, edition::Edition}; use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId}; use parse::{self, SeqSep, classify, token}; @@ -6322,7 +6322,7 @@ pub fn default_submod_path( id: ast::Ident, relative: Option, dir_path: &Path, - codemap: &CodeMap) -> ModulePath + codemap: &SourceMap) -> ModulePath { // If we're in a foo.rs file instead of a mod.rs file, // we need to look for submodules in diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 54ce06f61ef..2646d52b739 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -16,7 +16,7 @@ use ast::{Attribute, MacDelimiter, GenericArg}; use util::parser::{self, AssocOp, Fixity}; use attr; -use codemap::{self, CodeMap, Spanned}; +use codemap::{self, SourceMap, Spanned}; use syntax_pos::{self, BytePos}; use syntax_pos::hygiene::{Mark, SyntaxContext}; use parse::token::{self, BinOpToken, Token}; @@ -57,7 +57,7 @@ impl PpAnn for NoAnn {} pub struct State<'a> { pub s: pp::Printer<'a>, - cm: Option<&'a CodeMap>, + cm: Option<&'a SourceMap>, comments: Option >, literals: Peekable>, cur_cmnt: usize, @@ -84,7 +84,7 @@ fn rust_printer<'a>(writer: Box, ann: &'a dyn PpAnn) -> State<'a> /// Requires you to pass an input filename and reader so that /// it can scan the input text for comments and literals to /// copy forward. -pub fn print_crate<'a>(cm: &'a CodeMap, +pub fn print_crate<'a>(cm: &'a SourceMap, sess: &ParseSess, krate: &ast::Crate, filename: FileName, @@ -118,7 +118,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap, } impl<'a> State<'a> { - pub fn new_from_input(cm: &'a CodeMap, + pub fn new_from_input(cm: &'a SourceMap, sess: &ParseSess, filename: FileName, input: &mut dyn Read, @@ -138,7 +138,7 @@ pub fn new_from_input(cm: &'a CodeMap, if is_expanded { None } else { Some(lits) }) } - pub fn new(cm: &'a CodeMap, + pub fn new(cm: &'a SourceMap, out: Box, ann: &'a dyn PpAnn, comments: Option>, diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 1cbaf3cc312..633de812a87 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -22,7 +22,7 @@ use attr::{self, HasAttrs}; use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos}; -use codemap::{self, CodeMap, ExpnInfo, MacroAttribute, dummy_spanned}; +use codemap::{self, SourceMap, ExpnInfo, MacroAttribute, dummy_spanned}; use errors; use config; use entry::{self, EntryPointType}; diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index c7e4fbd1073..12f72a3979e 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use codemap::{CodeMap, FilePathMapping}; +use codemap::{SourceMap, FilePathMapping}; use errors::Handler; use errors::emitter::EmitterWriter; use std::io; @@ -50,7 +50,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & with_globals(|| { let output = Arc::new(Mutex::new(Vec::new())); - let code_map = Lrc::new(CodeMap::new(FilePathMapping::empty())); + let code_map = Lrc::new(SourceMap::new(FilePathMapping::empty())); code_map.new_filemap(Path::new("test.rs").to_owned().into(), file_text.to_owned()); let primary_span = make_span(&file_text, &span_labels[0].start, &span_labels[0].end); diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 98d7d77308f..fec7551a208 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -163,7 +163,7 @@ pub fn is_macros(&self) -> bool { /// Spans represent a region of code, used for error reporting. Positions in spans /// are *absolute* positions from the beginning of the codemap, not positions -/// relative to FileMaps. Methods on the CodeMap can be used to relate spans back +/// relative to FileMaps. Methods on the SourceMap can be used to relate spans back /// to the original source. /// You must be careful if the span crosses more than one file - you will not be /// able to use many of the functions on spans in codemap and you cannot assume @@ -678,7 +678,7 @@ fn from(spans: Vec) -> MultiSpan { /// Identifies an offset of a multi-byte character in a FileMap #[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)] pub struct MultiByteChar { - /// The absolute offset of the character in the CodeMap + /// The absolute offset of the character in the SourceMap pub pos: BytePos, /// The number of bytes, >=2 pub bytes: u8, @@ -705,7 +705,7 @@ fn new(pos: BytePos, width: usize) -> Self { } } - /// Returns the absolute offset of the character in the CodeMap + /// Returns the absolute offset of the character in the SourceMap pub fn pos(&self) -> BytePos { match *self { NonNarrowChar::ZeroWidth(p) | @@ -777,7 +777,7 @@ pub fn get_source(&self) -> Option<&str> { } } -/// A single source in the CodeMap. +/// A single source in the SourceMap. #[derive(Clone)] pub struct FileMap { /// The name of the file that the source came from, source that doesn't @@ -798,9 +798,9 @@ pub struct FileMap { /// The external source code (used for external crates, which will have a `None` /// value as `self.src`. pub external_src: Lock, - /// The start position of this source in the CodeMap + /// The start position of this source in the SourceMap pub start_pos: BytePos, - /// The end position of this source in the CodeMap + /// The end position of this source in the SourceMap pub end_pos: BytePos, /// Locations of lines beginnings in the source code pub lines: Vec, @@ -1141,7 +1141,7 @@ pub trait Pos { pub struct BytePos(pub u32); /// A character offset. Because of multibyte utf8 characters, a byte offset -/// is not equivalent to a character offset. The CodeMap will convert BytePos +/// is not equivalent to a character offset. The SourceMap will convert BytePos /// values to CharPos values as necessary. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] pub struct CharPos(pub usize); -- GitLab