diff options
| author | Donato Sciarra <sciarp@gmail.com> | 2018-08-18 12:14:14 +0200 |
|---|---|---|
| committer | Donato Sciarra <sciarp@gmail.com> | 2018-08-19 23:01:01 +0200 |
| commit | 062bfbf39bef9360e1553f293f4f1015c5680dec (patch) | |
| tree | 84cc72ecf00df5fec9af315ff8d0aef52c55684c | |
| parent | d3fe97f3d32b4cef1c22b6a5ba5326b1b195e262 (diff) | |
| download | rust-062bfbf39bef9360e1553f293f4f1015c5680dec.tar.gz rust-062bfbf39bef9360e1553f293f4f1015c5680dec.zip | |
mv codemap source_map
28 files changed, 130 insertions, 130 deletions
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index bea9d80639c..a14745a1381 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -122,7 +122,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { pub(super) fn finalize_and_compute_crate_hash(mut self, crate_disambiguator: CrateDisambiguator, cstore: &dyn CrateStore, - codemap: &SourceMap, + source_map: &SourceMap, commandline_args_hash: u64) -> (Vec<MapEntry<'hir>>, Svh) { self @@ -155,7 +155,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { // If we included the full mapping in the SVH, we could only have // reproducible builds by compiling from the same directory. So we just // hash the result of the mapping instead of the mapping itself. - let mut source_file_names: Vec<_> = codemap + let mut source_file_names: Vec<_> = source_map .files() .iter() .filter(|source_file| CrateNum::from_u32(source_file.crate_of_origin) == LOCAL_CRATE) diff --git a/src/librustc/ich/caching_codemap_view.rs b/src/librustc/ich/caching_codemap_view.rs index c219bbcb621..6c958823d3f 100644 --- a/src/librustc/ich/caching_codemap_view.rs +++ b/src/librustc/ich/caching_codemap_view.rs @@ -24,14 +24,14 @@ struct CacheEntry { #[derive(Clone)] pub struct CachingCodemapView<'cm> { - codemap: &'cm SourceMap, + source_map: &'cm SourceMap, line_cache: [CacheEntry; 3], time_stamp: usize, } impl<'cm> CachingCodemapView<'cm> { - pub fn new(codemap: &'cm SourceMap) -> CachingCodemapView<'cm> { - let files = codemap.files(); + pub fn new(source_map: &'cm SourceMap) -> CachingCodemapView<'cm> { + let files = source_map.files(); let first_file = files[0].clone(); let entry = CacheEntry { time_stamp: 0, @@ -43,7 +43,7 @@ impl<'cm> CachingCodemapView<'cm> { }; CachingCodemapView { - codemap, + source_map, line_cache: [entry.clone(), entry.clone(), entry.clone()], time_stamp: 0, } @@ -78,9 +78,9 @@ impl<'cm> CachingCodemapView<'cm> { // If the entry doesn't point to the correct file, fix it up if pos < cache_entry.file.start_pos || pos >= cache_entry.file.end_pos { let file_valid; - if self.codemap.files().len() > 0 { - let file_index = self.codemap.lookup_source_file_idx(pos); - let file = self.codemap.files()[file_index].clone(); + if self.source_map.files().len() > 0 { + let file_index = self.source_map.lookup_source_file_idx(pos); + let file = self.source_map.files()[file_index].clone(); if pos >= file.start_pos && pos < file.end_pos { cache_entry.file = file; diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 799887df05d..e496dbb17f6 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -58,8 +58,8 @@ pub struct StableHashingContext<'a> { // Very often, we are hashing something that does not need the // CachingCodemapView, so we initialize it lazily. - raw_codemap: &'a SourceMap, - caching_codemap: Option<CachingCodemapView<'a>>, + raw_source_map: &'a SourceMap, + caching_source_map: Option<CachingCodemapView<'a>>, pub(super) alloc_id_recursion_tracker: FxHashSet<AllocId>, } @@ -100,8 +100,8 @@ impl<'a> StableHashingContext<'a> { body_resolver: BodyResolver(krate), definitions, cstore, - caching_codemap: None, - raw_codemap: sess.source_map(), + caching_source_map: None, + raw_source_map: sess.source_map(), hash_spans: hash_spans_initial, hash_bodies: true, node_id_hashing_mode: NodeIdHashingMode::HashDefPath, @@ -170,12 +170,12 @@ impl<'a> StableHashingContext<'a> { #[inline] pub fn source_map(&mut self) -> &mut CachingCodemapView<'a> { - match self.caching_codemap { + match self.caching_source_map { Some(ref mut cm) => { cm } ref mut none => { - *none = Some(CachingCodemapView::new(self.raw_codemap)); + *none = Some(CachingCodemapView::new(self.raw_source_map)); none.as_mut().unwrap() } } diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index b92f55f4284..78f7de0092d 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -980,7 +980,7 @@ pub fn build_session( ) -> Session { let file_path_mapping = sopts.file_path_mapping(); - build_session_with_codemap( + build_session_with_source_map( sopts, local_crate_source_file, registry, @@ -989,11 +989,11 @@ pub fn build_session( ) } -pub fn build_session_with_codemap( +pub fn build_session_with_source_map( sopts: config::Options, local_crate_source_file: Option<PathBuf>, registry: errors::registry::Registry, - codemap: Lrc<source_map::SourceMap>, + source_map: Lrc<source_map::SourceMap>, emitter_dest: Option<Box<dyn Write + Send>>, ) -> Session { // FIXME: This is not general enough to make the warning lint completely override @@ -1020,19 +1020,19 @@ pub fn build_session_with_codemap( (config::ErrorOutputType::HumanReadable(color_config), None) => Box::new( EmitterWriter::stderr( color_config, - Some(codemap.clone()), + Some(source_map.clone()), false, sopts.debugging_opts.teach, ).ui_testing(sopts.debugging_opts.ui_testing), ), (config::ErrorOutputType::HumanReadable(_), Some(dst)) => Box::new( - EmitterWriter::new(dst, Some(codemap.clone()), false, false) + EmitterWriter::new(dst, Some(source_map.clone()), false, false) .ui_testing(sopts.debugging_opts.ui_testing), ), (config::ErrorOutputType::Json(pretty), None) => Box::new( JsonEmitter::stderr( Some(registry), - codemap.clone(), + source_map.clone(), pretty, ).ui_testing(sopts.debugging_opts.ui_testing), ), @@ -1040,15 +1040,15 @@ pub fn build_session_with_codemap( JsonEmitter::new( dst, Some(registry), - codemap.clone(), + source_map.clone(), pretty, ).ui_testing(sopts.debugging_opts.ui_testing), ), (config::ErrorOutputType::Short(color_config), None) => Box::new( - EmitterWriter::stderr(color_config, Some(codemap.clone()), true, false), + EmitterWriter::stderr(color_config, Some(source_map.clone()), true, false), ), (config::ErrorOutputType::Short(_), Some(dst)) => { - Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true, false)) + Box::new(EmitterWriter::new(dst, Some(source_map.clone()), true, false)) } }; @@ -1063,14 +1063,14 @@ pub fn build_session_with_codemap( }, ); - build_session_(sopts, local_crate_source_file, diagnostic_handler, codemap) + build_session_(sopts, local_crate_source_file, diagnostic_handler, source_map) } pub fn build_session_( sopts: config::Options, local_crate_source_file: Option<PathBuf>, span_diagnostic: errors::Handler, - codemap: Lrc<source_map::SourceMap>, + source_map: Lrc<source_map::SourceMap>, ) -> Session { let host_triple = TargetTriple::from_triple(config::host_triple()); let host = match Target::search(&host_triple) { @@ -1083,7 +1083,7 @@ pub fn build_session_( }; let target_cfg = config::build_target_config(&sopts, &span_diagnostic); - let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap); + let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map); let default_sysroot = match sopts.maybe_sysroot { Some(_) => None, None => Some(filesearch::get_or_default_sysroot()), diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index f7876ee035c..7ccd8574e83 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> { prev_cnums: Vec<(u32, String, CrateDisambiguator)>, cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>, - codemap: &'sess SourceMap, + source_map: &'sess SourceMap, file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>, // These two fields caches that are populated lazily during decoding. @@ -140,7 +140,7 @@ impl<'sess> OnDiskCache<'sess> { file_index_to_file: Lock::new(FxHashMap()), prev_cnums: footer.prev_cnums, cnum_map: Once::new(), - codemap: sess.source_map(), + source_map: sess.source_map(), current_diagnostics: Lock::new(FxHashMap()), query_result_index: footer.query_result_index.into_iter().collect(), prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(), @@ -149,14 +149,14 @@ impl<'sess> OnDiskCache<'sess> { } } - pub fn new_empty(codemap: &'sess SourceMap) -> OnDiskCache<'sess> { + pub fn new_empty(source_map: &'sess SourceMap) -> OnDiskCache<'sess> { OnDiskCache { serialized_data: Vec::new(), file_index_to_stable_id: FxHashMap(), file_index_to_file: Lock::new(FxHashMap()), prev_cnums: vec![], cnum_map: Once::new(), - codemap, + source_map, current_diagnostics: Lock::new(FxHashMap()), query_result_index: FxHashMap(), prev_diagnostics_index: FxHashMap(), @@ -196,7 +196,7 @@ impl<'sess> OnDiskCache<'sess> { expn_info_shorthands: FxHashMap(), interpret_allocs: FxHashMap(), interpret_allocs_inverse: Vec::new(), - codemap: CachingCodemapView::new(tcx.sess.source_map()), + source_map: CachingCodemapView::new(tcx.sess.source_map()), file_to_file_index, }; @@ -413,7 +413,7 @@ impl<'sess> OnDiskCache<'sess> { let mut decoder = CacheDecoder { tcx, opaque: opaque::Decoder::new(&self.serialized_data[..], pos.to_usize()), - codemap: self.codemap, + source_map: self.source_map, cnum_map: self.cnum_map.get(), file_index_to_file: &self.file_index_to_file, file_index_to_stable_id: &self.file_index_to_stable_id, @@ -475,7 +475,7 @@ impl<'sess> OnDiskCache<'sess> { struct CacheDecoder<'a, 'tcx: 'a, 'x> { tcx: TyCtxt<'a, 'tcx, 'tcx>, opaque: opaque::Decoder<'x>, - codemap: &'x SourceMap, + source_map: &'x SourceMap, cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>, synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>, file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>, @@ -488,13 +488,13 @@ impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> { let CacheDecoder { ref file_index_to_file, ref file_index_to_stable_id, - ref codemap, + ref source_map, .. } = *self; file_index_to_file.borrow_mut().entry(index).or_insert_with(|| { let stable_id = file_index_to_stable_id[&index]; - codemap.source_file_by_stable_id(stable_id) + source_map.source_file_by_stable_id(stable_id) .expect("Failed to lookup SourceFile in new context.") }).clone() } @@ -770,7 +770,7 @@ struct CacheEncoder<'enc, 'a, 'tcx, E> expn_info_shorthands: FxHashMap<Mark, AbsoluteBytePos>, interpret_allocs: FxHashMap<interpret::AllocId, usize>, interpret_allocs_inverse: Vec<interpret::AllocId>, - codemap: CachingCodemapView<'tcx>, + source_map: CachingCodemapView<'tcx>, file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>, } @@ -836,7 +836,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'enc, 'a, 'tcx return TAG_INVALID_SPAN.encode(self); } - let (file_lo, line_lo, col_lo) = match self.codemap + let (file_lo, line_lo, col_lo) = match self.source_map .byte_pos_to_line_and_col(span_data.lo) { Some(pos) => pos, None => { diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 07d9ab4e497..f88c619bf77 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -522,9 +522,9 @@ fn run_compiler_with_pool<'a>( }; let loader = file_loader.unwrap_or(box RealFileLoader); - 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, + let source_map = Lrc::new(SourceMap::with_file_loader(loader, sopts.file_path_mapping())); + let mut sess = session::build_session_with_source_map( + sopts, input_file_path.clone(), descriptions, source_map, emitter_dest, ); if let Some(err) = input_err { diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index a10bb3e25df..c242f8d476a 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -245,7 +245,7 @@ impl<'a> CrateLoader<'a> { cnum_map, cnum, dependencies: Lock::new(dependencies), - codemap_import_info: RwLock::new(vec![]), + source_map_import_info: RwLock::new(vec![]), alloc_decoding_state: AllocDecodingState::new(interpret_alloc_index), dep_kind: Lock::new(dep_kind), source: cstore::CrateSource { diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 5c020b70e30..aad632f8918 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -44,11 +44,11 @@ pub struct MetadataBlob(pub MetadataRef); /// Holds information about a syntax_pos::SourceFile imported from another crate. /// See `imported_source_files()` for more information. pub struct ImportedSourceFile { - /// This SourceFile's byte-offset within the codemap of its original crate + /// This SourceFile's byte-offset within the source_map of its original crate pub original_start_pos: syntax_pos::BytePos, - /// The end of this SourceFile within the codemap of its original crate + /// The end of this SourceFile within the source_map of its original crate pub original_end_pos: syntax_pos::BytePos, - /// The imported SourceFile's representation within the local codemap + /// The imported SourceFile's representation within the local source_map pub translated_source_file: Lrc<syntax_pos::SourceFile>, } @@ -64,7 +64,7 @@ pub struct CrateMetadata { pub cnum_map: CrateNumMap, pub cnum: CrateNum, pub dependencies: Lock<Vec<CrateNum>>, - pub codemap_import_info: RwLock<Vec<ImportedSourceFile>>, + pub source_map_import_info: RwLock<Vec<ImportedSourceFile>>, /// Used for decoding interpret::AllocIds in a cached & thread-safe manner. pub alloc_decoding_state: AllocDecodingState, diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index ceccdea6587..76473ec7781 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1094,49 +1094,49 @@ impl<'a, 'tcx> CrateMetadata { self.def_path_table.def_path_hash(index) } - /// Imports the codemap from an external crate into the codemap of the crate + /// Imports the source_map from an external crate into the source_map of the crate /// currently being compiled (the "local crate"). /// /// The import algorithm works analogous to how AST items are inlined from an /// external crate's metadata: - /// For every SourceFile in the external codemap an 'inline' copy is created in the - /// local codemap. The correspondence relation between external and local + /// For every SourceFile in the external source_map an 'inline' copy is created in the + /// local source_map. The correspondence relation between external and local /// SourceFiles is recorded in the `ImportedSourceFile` objects returned from this /// function. When an item from an external crate is later inlined into this /// crate, this correspondence information is used to translate the span /// information of the inlined item so that it refers the correct positions in - /// the local codemap (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`). + /// the local source_map (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`). /// /// The import algorithm in the function below will reuse SourceFiles already - /// existing in the local codemap. For example, even if the SourceFile of some + /// existing in the local source_map. For example, even if the SourceFile of some /// source file of libstd gets imported many times, there will only ever be - /// one SourceFile object for the corresponding file in the local codemap. + /// one SourceFile object for the corresponding file in the local source_map. /// /// Note that imported SourceFiles do not actually contain the source code of the /// file they represent, just information about length, line breaks, and /// multibyte characters. This information is enough to generate valid debuginfo /// for items inlined from other crates. pub fn imported_source_files(&'a self, - local_codemap: &source_map::SourceMap) + local_source_map: &source_map::SourceMap) -> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> { { - let source_files = self.codemap_import_info.borrow(); + let source_files = self.source_map_import_info.borrow(); if !source_files.is_empty() { return source_files; } } - // Lock the codemap_import_info to ensure this only happens once - let mut codemap_import_info = self.codemap_import_info.borrow_mut(); + // Lock the source_map_import_info to ensure this only happens once + let mut source_map_import_info = self.source_map_import_info.borrow_mut(); - if !codemap_import_info.is_empty() { - drop(codemap_import_info); - return self.codemap_import_info.borrow(); + if !source_map_import_info.is_empty() { + drop(source_map_import_info); + return self.source_map_import_info.borrow(); } - let external_codemap = self.root.codemap.decode(self); + let external_source_map = self.root.source_map.decode(self); - let imported_source_files = external_codemap.map(|source_file_to_import| { + let imported_source_files = external_source_map.map(|source_file_to_import| { // We can't reuse an existing SourceFile, so allocate a new one // containing the information we need. let syntax_pos::SourceFile { name, @@ -1167,7 +1167,7 @@ impl<'a, 'tcx> CrateMetadata { *swc = *swc - start_pos; } - let local_version = local_codemap.new_imported_source_file(name, + let local_version = local_source_map.new_imported_source_file(name, name_was_remapped, self.cnum.as_u32(), src_hash, @@ -1189,10 +1189,10 @@ impl<'a, 'tcx> CrateMetadata { } }).collect(); - *codemap_import_info = imported_source_files; - drop(codemap_import_info); + *source_map_import_info = imported_source_files; + drop(source_map_import_info); // This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref. - self.codemap_import_info.borrow() + self.source_map_import_info.borrow() } } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 8f3bed6bdbe..4b5c9d68fd7 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -158,9 +158,9 @@ impl<'a, 'tcx> SpecializedEncoder<Span> for EncodeContext<'a, 'tcx> { debug_assert!(span.lo <= span.hi); if !self.source_file_cache.contains(span.lo) { - let codemap = self.tcx.sess.source_map(); - let source_file_index = codemap.lookup_source_file_idx(span.lo); - self.source_file_cache = codemap.files()[source_file_index].clone(); + let source_map = self.tcx.sess.source_map(); + let source_file_index = source_map.lookup_source_file_idx(span.lo); + self.source_file_cache = source_map.files()[source_file_index].clone(); } if !self.source_file_cache.contains(span.hi) { @@ -338,8 +338,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_source_map(&mut self) -> LazySeq<syntax_pos::SourceFile> { - let codemap = self.tcx.sess.source_map(); - let all_source_files = codemap.files(); + let source_map = self.tcx.sess.source_map(); + let all_source_files = source_map.files(); let (working_dir, working_dir_was_remapped) = self.tcx.sess.working_dir.clone(); @@ -418,10 +418,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { IsolatedEncoder::encode_foreign_modules, ()); - // Encode codemap + // Encode source_map i = self.position(); - let codemap = self.encode_source_map(); - let codemap_bytes = self.position() - i; + let source_map = self.encode_source_map(); + let source_map_bytes = self.position() - i; // Encode DefPathTable i = self.position(); @@ -523,7 +523,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { lang_items_missing, native_libraries, foreign_modules, - codemap, + source_map, def_path_table, impls, exported_symbols, @@ -546,7 +546,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { println!(" lib feature bytes: {}", lib_feature_bytes); println!(" lang item bytes: {}", lang_item_bytes); println!(" native bytes: {}", native_lib_bytes); - println!(" codemap bytes: {}", codemap_bytes); + println!(" source_map bytes: {}", source_map_bytes); println!(" impl bytes: {}", impl_bytes); println!(" exp. symbols bytes: {}", exported_symbols_bytes); println!(" def-path table bytes: {}", def_path_table_bytes); diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 520273487a9..8e454ddc0ad 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -204,7 +204,7 @@ pub struct CrateRoot { pub lang_items_missing: LazySeq<lang_items::LangItem>, pub native_libraries: LazySeq<NativeLibrary>, pub foreign_modules: LazySeq<ForeignModule>, - pub codemap: LazySeq<syntax_pos::SourceFile>, + pub source_map: LazySeq<syntax_pos::SourceFile>, pub def_path_table: Lazy<hir::map::definitions::DefPathTable>, pub impls: LazySeq<TraitImpls>, pub exported_symbols: EncodedExportedSymbols, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 9724d9deead..532c36f427b 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -383,8 +383,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { let region_name = self.synthesize_region_name(counter); // Just grab the first character, the `&`. - let codemap = tcx.sess.source_map(); - let ampersand_span = codemap.start_point(hir_ty.span); + let source_map = tcx.sess.source_map(); + let ampersand_span = source_map.start_point(hir_ty.span); diag.span_label( ampersand_span, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 6dd0c32bb3e..282589c4e68 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -414,7 +414,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. +/// source_map functions and this function to something more robust. 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); diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 66a71cdd3f8..de211d2209c 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -253,7 +253,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Err(()) => { // error types are considered "builtin" if !lhs_ty.references_error() { - let codemap = self.tcx.sess.source_map(); + let source_map = self.tcx.sess.source_map(); match is_assign { IsAssign::Yes => { let mut err = struct_span_err!(self.tcx.sess, expr.span, E0368, @@ -275,7 +275,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Op::Binary(op, is_assign)) .is_ok() } { - if let Ok(lstring) = codemap.span_to_snippet(lhs_expr.span) { + if let Ok(lstring) = source_map.span_to_snippet(lhs_expr.span) { while let TyRef(_, rty_inner, _) = rty.sty { rty = rty_inner; } @@ -343,7 +343,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Op::Binary(op, is_assign)) .is_ok() } { - if let Ok(lstring) = codemap.span_to_snippet(lhs_expr.span) { + if let Ok(lstring) = source_map.span_to_snippet(lhs_expr.span) { while let TyRef(_, rty_inner, _) = rty.sty { rty = rty_inner; } @@ -420,7 +420,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err: &mut errors::DiagnosticBuilder, is_assign: bool, ) -> bool { - let codemap = self.tcx.sess.source_map(); + let source_map = self.tcx.sess.source_map(); let msg = "`to_owned()` can be used to create an owned `String` \ from a string reference. String concatenation \ appends the string on the right to the string \ @@ -434,7 +434,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !is_assign { err.span_label(expr.span, "`+` can't be used to concatenate two `&str` strings"); - match codemap.span_to_snippet(lhs_expr.span) { + match source_map.span_to_snippet(lhs_expr.span) { Ok(lstring) => err.span_suggestion(lhs_expr.span, msg, format!("{}.to_owned()", lstring)), @@ -448,8 +448,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err.span_label(expr.span, "`+` can't be used to concatenate a `&str` with a `String`"); match ( - codemap.span_to_snippet(lhs_expr.span), - codemap.span_to_snippet(rhs_expr.span), + source_map.span_to_snippet(lhs_expr.span), + source_map.span_to_snippet(rhs_expr.span), is_assign, ) { (Ok(l), Ok(r), false) => { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index bd37a87b1e1..a312913a69c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -260,7 +260,7 @@ impl DocAccessLevels for AccessLevels<DefId> { /// /// 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<Lrc<source_map::SourceMap>>) +pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_map::SourceMap>>) -> errors::Handler { // rustdoc doesn't override (or allow to override) anything from this that is relevant here, so @@ -270,18 +270,18 @@ pub fn new_handler(error_format: ErrorOutputType, codemap: Option<Lrc<source_map ErrorOutputType::HumanReadable(color_config) => Box::new( EmitterWriter::stderr( color_config, - codemap.map(|cm| cm as _), + source_map.map(|cm| cm as _), false, sessopts.debugging_opts.teach, ).ui_testing(sessopts.debugging_opts.ui_testing) ), ErrorOutputType::Json(pretty) => { - let codemap = codemap.unwrap_or_else( + let source_map = source_map.unwrap_or_else( || Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()))); Box::new( JsonEmitter::stderr( None, - codemap, + source_map, pretty, ).ui_testing(sessopts.debugging_opts.ui_testing) ) @@ -289,7 +289,7 @@ pub fn new_handler(error_format: ErrorOutputType, codemap: Option<Lrc<source_map ErrorOutputType::Short(color_config) => Box::new( EmitterWriter::stderr( color_config, - codemap.map(|cm| cm as _), + source_map.map(|cm| cm as _), true, false) ), @@ -387,11 +387,11 @@ pub fn run_core(search_paths: SearchPaths, ..Options::default() }; driver::spawn_thread_pool(sessopts, move |sessopts| { - let codemap = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping())); - let diagnostic_handler = new_handler(error_format, Some(codemap.clone())); + let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping())); + let diagnostic_handler = new_handler(error_format, Some(source_map.clone())); let mut sess = session::build_session_( - sessopts, cpath, diagnostic_handler, codemap, + sessopts, cpath, diagnostic_handler, source_map, ); lint::builtin::HardwiredLints.get_lints() diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 4634054cf16..2a9ad6c7f33 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -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 SourceMap, + source_map: &'a SourceMap, // State of the classifier. in_attribute: bool, @@ -145,10 +145,10 @@ impl<U: Write> Writer for U { } impl<'a> Classifier<'a> { - fn new(lexer: lexer::StringReader<'a>, codemap: &'a SourceMap) -> Classifier<'a> { + fn new(lexer: lexer::StringReader<'a>, source_map: &'a SourceMap) -> Classifier<'a> { Classifier { lexer, - codemap, + source_map, in_attribute: false, in_macro: false, in_macro_nonterminal: false, @@ -338,9 +338,9 @@ impl<'a> Classifier<'a> { out.string(Escape(&self.snip(tas.sp)), klass) } - // Helper function to get a snippet from the codemap. + // Helper function to get a snippet from the source_map. fn snip(&self, sp: Span) -> String { - self.codemap.span_to_snippet(sp).unwrap() + self.source_map.span_to_snippet(sp).unwrap() } } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 9854b919f5c..3b07a2ccdde 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -86,14 +86,14 @@ pub fn run(input_path: &Path, ..config::Options::default() }; driver::spawn_thread_pool(sessopts, |sessopts| { - let codemap = Lrc::new(SourceMap::new(sessopts.file_path_mapping())); + let source_map = Lrc::new(SourceMap::new(sessopts.file_path_mapping())); let handler = errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, - Some(codemap.clone())); + Some(source_map.clone())); let mut sess = session::build_session_( - sessopts, Some(input_path.to_owned()), handler, codemap.clone(), + sessopts, Some(input_path.to_owned()), handler, source_map.clone(), ); let codegen_backend = rustc_driver::get_codegen_backend(&sess); let cstore = CStore::new(codegen_backend.metadata_loader()); @@ -133,7 +133,7 @@ pub fn run(input_path: &Path, false, opts, maybe_sysroot, - Some(codemap), + Some(source_map), None, linker, edition @@ -262,11 +262,11 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, 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(SourceMap::new_doctest( + let source_map = 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()), - Some(codemap.clone()), + Some(source_map.clone()), false, false); @@ -274,7 +274,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter); let mut sess = session::build_session_( - sessopts, None, diagnostic_handler, codemap, + sessopts, None, diagnostic_handler, source_map, ); let codegen_backend = rustc_driver::get_codegen_backend(&sess); let cstore = CStore::new(codegen_backend.metadata_loader()); @@ -500,7 +500,7 @@ pub struct Collector { opts: TestOptions, maybe_sysroot: Option<PathBuf>, position: Span, - codemap: Option<Lrc<SourceMap>>, + source_map: Option<Lrc<SourceMap>>, filename: Option<PathBuf>, linker: Option<PathBuf>, edition: Edition, @@ -509,7 +509,7 @@ pub struct Collector { impl Collector { pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, cg: CodegenOptions, externs: Externs, use_headers: bool, opts: TestOptions, - maybe_sysroot: Option<PathBuf>, codemap: Option<Lrc<SourceMap>>, + maybe_sysroot: Option<PathBuf>, source_map: Option<Lrc<SourceMap>>, filename: Option<PathBuf>, linker: Option<PathBuf>, edition: Edition) -> Collector { Collector { tests: Vec::new(), @@ -523,7 +523,7 @@ impl Collector { opts, maybe_sysroot, position: DUMMY_SP, - codemap, + source_map, filename, linker, edition, @@ -589,9 +589,9 @@ impl Collector { } pub fn get_line(&self) -> usize { - if let Some(ref codemap) = self.codemap { + if let Some(ref source_map) = self.source_map { let line = self.position.lo().to_usize(); - let line = codemap.lookup_char_pos(BytePos(line as u32)).line; + let line = source_map.lookup_char_pos(BytePos(line as u32)).line; if line > 0 { line - 1 } else { line } } else { 0 @@ -603,8 +603,8 @@ impl Collector { } fn get_filename(&self) -> FileName { - if let Some(ref codemap) = self.codemap { - let filename = codemap.span_to_filename(self.position); + if let Some(ref source_map) = self.source_map { + let filename = source_map.span_to_filename(self.position); if let FileName::Real(ref filename) = filename { if let Ok(cur_dir) = env::current_dir() { if let Ok(path) = filename.strip_prefix(&cur_dir) { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 6cfa2b4abe8..434548ffd9d 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -43,9 +43,9 @@ impl Default for TokenAndSpan { pub struct StringReader<'a> { pub sess: &'a ParseSess, - /// The absolute offset within the codemap of the next character to read + /// The absolute offset within the source_map of the next character to read pub next_pos: BytePos, - /// The absolute offset within the codemap of the current character + /// The absolute offset within the source_map of the current character pub pos: BytePos, /// The current character (which has been read from self.pos) pub ch: Option<char>, diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 3f66dae4e1b..e3a2c83e4c2 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -189,7 +189,7 @@ pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path) -> Parser<'a> } /// Given a session, a crate config, a path, and a span, add -/// the file at the given path to the codemap, and return a parser. +/// the file at the given path to the source_map, and return a parser. /// On an error, use the given span as the source of the problem. crate fn new_sub_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, @@ -224,7 +224,7 @@ pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser { // base abstractions /// Given a session and a path and an optional span (for error reporting), -/// add the path to the session's codemap and return the new source_file. +/// add the path to the session's source_map and return the new source_file. fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>) -> Lrc<SourceFile> { match sess.source_map().load_file(path) { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c9053f0fec9..b1e2e69863d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6322,7 +6322,7 @@ impl<'a> Parser<'a> { id: ast::Ident, relative: Option<ast::Ident>, dir_path: &Path, - codemap: &SourceMap) -> ModulePath + source_map: &SourceMap) -> ModulePath { // If we're in a foo.rs file instead of a mod.rs file, // we need to look for submodules in @@ -6342,8 +6342,8 @@ impl<'a> Parser<'a> { relative_prefix, mod_name, path::MAIN_SEPARATOR); let default_path = dir_path.join(&default_path_str); let secondary_path = dir_path.join(&secondary_path_str); - let default_exists = codemap.file_exists(&default_path); - let secondary_exists = codemap.file_exists(&secondary_path); + let default_exists = source_map.file_exists(&default_path); + let secondary_exists = source_map.file_exists(&secondary_path); let result = match (default_exists, secondary_exists) { (true, false) => Ok(ModulePathSuccess { diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 34cd026f7a0..457a44b9cbb 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -206,7 +206,7 @@ impl SourceMap { match self.files.borrow().file_maps.last() { None => 0, // Add one so there is some space between files. This lets us distinguish - // positions in the codemap, even in the presence of zero-length files. + // positions in the source_map, even in the presence of zero-length files. Some(last) => last.end_pos.to_usize() + 1, } } @@ -895,7 +895,7 @@ impl SourceMap { /// /// 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. + /// source_map functions and this function to something more robust. pub fn generate_local_type_param_snippet(&self, span: Span) -> Option<(Span, String)> { // Try to extend the span to the previous "fn" keyword to retrieve the function // signature diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 0db24c3b482..1210f331b28 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -21,7 +21,7 @@ use ptr::P; use tokenstream::TokenStream; /// Craft a span that will be ignored by the stability lint's -/// call to codemap's `is_internal` check. +/// call to source_map's `is_internal` check. /// The expanded code uses the unstable `#[prelude_import]` attribute. fn ignored_span(sp: Span) -> Span { let mark = Mark::fresh(Mark::root()); diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 393989711de..988f50b4f0c 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -324,7 +324,7 @@ fn generate_test_harness(sess: &ParseSess, } /// Craft a span that will be ignored by the stability lint's -/// call to codemap's `is_internal` check. +/// call to source_map's `is_internal` check. /// The expanded code calls some unstable functions in the test crate. fn ignored_span(cx: &TestCtxt, sp: Span) -> Span { sp.with_ctxt(cx.ctxt) diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index f9c91dc8a97..bd70344b018 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -162,11 +162,11 @@ impl FileName { } /// Spans represent a region of code, used for error reporting. Positions in spans -/// are *absolute* positions from the beginning of the codemap, not positions +/// are *absolute* positions from the beginning of the source_map, not positions /// relative to SourceFiles. 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 +/// able to use many of the functions on spans in source_map and you cannot assume /// that the length of the span = hi - lo; there may be space in the BytePos /// range between files. /// diff --git a/src/test/incremental/span_hash_stable/main.rs b/src/test/incremental/span_hash_stable/main.rs index 1512c5dc537..646a388c877 100644 --- a/src/test/incremental/span_hash_stable/main.rs +++ b/src/test/incremental/span_hash_stable/main.rs @@ -9,7 +9,7 @@ // except according to those terms. // This test makes sure that it doesn't make a difference in which order we are -// adding source files to the codemap. The order affects the BytePos values of +// adding source files to the source_map. The order affects the BytePos values of // the spans and this test makes sure that we handle them correctly by hashing // file:line:column instead of raw byte offset. diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs index 5214d7db5cc..7edb3e0f8a0 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs @@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass { _: intravisit::FnKind<'tcx>, _: &'tcx hir::FnDecl, _: &'tcx hir::Body, - span: codemap::Span, + span: source_map::Span, id: ast::NodeId) { let item = match cx.tcx.hir.get(id) { diff --git a/src/test/ui/cfg-empty-codemap.rs b/src/test/ui/cfg-empty-codemap.rs index 8868a5a9549..f06d22d985f 100644 --- a/src/test/ui/cfg-empty-codemap.rs +++ b/src/test/ui/cfg-empty-codemap.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Tests that empty codemaps don't ICE (#23301) +// Tests that empty source_maps don't ICE (#23301) // compile-flags: --cfg "" diff --git a/src/test/ui/mod/mod_file_correct_spans.rs b/src/test/ui/mod/mod_file_correct_spans.rs index 52837479869..1efd9ba8e55 100644 --- a/src/test/ui/mod/mod_file_correct_spans.rs +++ b/src/test/ui/mod/mod_file_correct_spans.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Testing that the codemap is maintained correctly when parsing mods from external files +// Testing that the source_map is maintained correctly when parsing mods from external files mod mod_file_aux; |
