Skip to content

Commit c655473

Browse files
committed
mv CodeMap SourceMap
1 parent 3ac79c7 commit c655473

File tree

28 files changed

+133
-133
lines changed

28 files changed

+133
-133
lines changed

src/librustc/hir/map/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use middle::cstore::CrateStore;
1818
use session::CrateDisambiguator;
1919
use std::iter::repeat;
2020
use syntax::ast::{NodeId, CRATE_NODE_ID};
21-
use syntax::codemap::CodeMap;
21+
use syntax::codemap::SourceMap;
2222
use syntax_pos::Span;
2323

2424
use ich::StableHashingContext;
@@ -122,7 +122,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
122122
pub(super) fn finalize_and_compute_crate_hash(mut self,
123123
crate_disambiguator: CrateDisambiguator,
124124
cstore: &dyn CrateStore,
125-
codemap: &CodeMap,
125+
codemap: &SourceMap,
126126
commandline_args_hash: u64)
127127
-> (Vec<MapEntry<'hir>>, Svh) {
128128
self

src/librustc/hir/map/definitions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ define_global_metadata_kind!(pub enum GlobalMetaDataKind {
739739
LangItems,
740740
LangItemsMissing,
741741
NativeLibraries,
742-
CodeMap,
742+
SourceMap,
743743
Impls,
744744
ExportedSymbols
745745
});

src/librustc/hir/print.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub use self::AnnNode::*;
1212

1313
use rustc_target::spec::abi::Abi;
1414
use syntax::ast;
15-
use syntax::codemap::{CodeMap, Spanned};
15+
use syntax::codemap::{SourceMap, Spanned};
1616
use syntax::parse::ParseSess;
1717
use syntax::parse::lexer::comments;
1818
use syntax::print::pp::{self, Breaks};
@@ -85,7 +85,7 @@ impl PpAnn for hir::Crate {
8585

8686
pub struct State<'a> {
8787
pub s: pp::Printer<'a>,
88-
cm: Option<&'a CodeMap>,
88+
cm: Option<&'a SourceMap>,
8989
comments: Option<Vec<comments::Comment>>,
9090
literals: Peekable<vec::IntoIter<comments::Literal>>,
9191
cur_cmnt: usize,
@@ -129,7 +129,7 @@ pub const default_columns: usize = 78;
129129
/// Requires you to pass an input filename and reader so that
130130
/// it can scan the input text for comments and literals to
131131
/// copy forward.
132-
pub fn print_crate<'a>(cm: &'a CodeMap,
132+
pub fn print_crate<'a>(cm: &'a SourceMap,
133133
sess: &ParseSess,
134134
krate: &hir::Crate,
135135
filename: FileName,
@@ -149,7 +149,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
149149
}
150150

151151
impl<'a> State<'a> {
152-
pub fn new_from_input(cm: &'a CodeMap,
152+
pub fn new_from_input(cm: &'a SourceMap,
153153
sess: &ParseSess,
154154
filename: FileName,
155155
input: &mut dyn Read,
@@ -173,7 +173,7 @@ impl<'a> State<'a> {
173173
})
174174
}
175175

176-
pub fn new(cm: &'a CodeMap,
176+
pub fn new(cm: &'a SourceMap,
177177
out: Box<dyn Write + 'a>,
178178
ann: &'a dyn PpAnn,
179179
comments: Option<Vec<comments::Comment>>,

src/librustc/ich/caching_codemap_view.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use rustc_data_structures::sync::Lrc;
12-
use syntax::codemap::CodeMap;
12+
use syntax::codemap::SourceMap;
1313
use syntax_pos::{BytePos, FileMap};
1414

1515
#[derive(Clone)]
@@ -24,13 +24,13 @@ struct CacheEntry {
2424

2525
#[derive(Clone)]
2626
pub struct CachingCodemapView<'cm> {
27-
codemap: &'cm CodeMap,
27+
codemap: &'cm SourceMap,
2828
line_cache: [CacheEntry; 3],
2929
time_stamp: usize,
3030
}
3131

3232
impl<'cm> CachingCodemapView<'cm> {
33-
pub fn new(codemap: &'cm CodeMap) -> CachingCodemapView<'cm> {
33+
pub fn new(codemap: &'cm SourceMap) -> CachingCodemapView<'cm> {
3434
let files = codemap.files();
3535
let first_file = files[0].clone();
3636
let entry = CacheEntry {

src/librustc/ich/hcx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::cell::RefCell;
2525

2626
use syntax::ast;
2727

28-
use syntax::codemap::CodeMap;
28+
use syntax::codemap::SourceMap;
2929
use syntax::ext::hygiene::SyntaxContext;
3030
use syntax::symbol::Symbol;
3131
use syntax_pos::{Span, DUMMY_SP};
@@ -58,7 +58,7 @@ pub struct StableHashingContext<'a> {
5858

5959
// Very often, we are hashing something that does not need the
6060
// CachingCodemapView, so we initialize it lazily.
61-
raw_codemap: &'a CodeMap,
61+
raw_codemap: &'a SourceMap,
6262
caching_codemap: Option<CachingCodemapView<'a>>,
6363

6464
pub(super) alloc_id_recursion_tracker: FxHashSet<AllocId>,
@@ -308,9 +308,9 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
308308

309309
// Hash a span in a stable way. We can't directly hash the span's BytePos
310310
// fields (that would be similar to hashing pointers, since those are just
311-
// offsets into the CodeMap). Instead, we hash the (file name, line, column)
311+
// offsets into the SourceMap). Instead, we hash the (file name, line, column)
312312
// triple, which stays the same even if the containing FileMap has moved
313-
// within the CodeMap.
313+
// within the SourceMap.
314314
// Also note that we are hashing byte offsets for the column, not unicode
315315
// codepoint offsets. For the purpose of the hash that's sufficient.
316316
// Also, hashing filenames is expensive so we avoid doing it twice when the

src/librustc/session/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl Session {
484484
);
485485
}
486486

487-
pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
487+
pub fn codemap<'a>(&'a self) -> &'a codemap::SourceMap {
488488
self.parse_sess.codemap()
489489
}
490490
pub fn verbose(&self) -> bool {
@@ -984,7 +984,7 @@ pub fn build_session(
984984
sopts,
985985
local_crate_source_file,
986986
registry,
987-
Lrc::new(codemap::CodeMap::new(file_path_mapping)),
987+
Lrc::new(codemap::SourceMap::new(file_path_mapping)),
988988
None,
989989
)
990990
}
@@ -993,7 +993,7 @@ pub fn build_session_with_codemap(
993993
sopts: config::Options,
994994
local_crate_source_file: Option<PathBuf>,
995995
registry: errors::registry::Registry,
996-
codemap: Lrc<codemap::CodeMap>,
996+
codemap: Lrc<codemap::SourceMap>,
997997
emitter_dest: Option<Box<dyn Write + Send>>,
998998
) -> Session {
999999
// FIXME: This is not general enough to make the warning lint completely override
@@ -1070,7 +1070,7 @@ pub fn build_session_(
10701070
sopts: config::Options,
10711071
local_crate_source_file: Option<PathBuf>,
10721072
span_diagnostic: errors::Handler,
1073-
codemap: Lrc<codemap::CodeMap>,
1073+
codemap: Lrc<codemap::SourceMap>,
10741074
) -> Session {
10751075
let host_triple = TargetTriple::from_triple(config::host_triple());
10761076
let host = match Target::search(&host_triple) {

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
2626
use session::{CrateDisambiguator, Session};
2727
use std::mem;
2828
use syntax::ast::NodeId;
29-
use syntax::codemap::{CodeMap, StableFilemapId};
29+
use syntax::codemap::{SourceMap, StableFilemapId};
3030
use syntax_pos::{BytePos, Span, DUMMY_SP, FileMap};
3131
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
3232
use ty;
@@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> {
6262
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
6363
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
6464

65-
codemap: &'sess CodeMap,
65+
codemap: &'sess SourceMap,
6666
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
6767

6868
// These two fields caches that are populated lazily during decoding.
@@ -149,7 +149,7 @@ impl<'sess> OnDiskCache<'sess> {
149149
}
150150
}
151151

152-
pub fn new_empty(codemap: &'sess CodeMap) -> OnDiskCache<'sess> {
152+
pub fn new_empty(codemap: &'sess SourceMap) -> OnDiskCache<'sess> {
153153
OnDiskCache {
154154
serialized_data: Vec::new(),
155155
file_index_to_stable_id: FxHashMap(),
@@ -475,7 +475,7 @@ impl<'sess> OnDiskCache<'sess> {
475475
struct CacheDecoder<'a, 'tcx: 'a, 'x> {
476476
tcx: TyCtxt<'a, 'tcx, 'tcx>,
477477
opaque: opaque::Decoder<'x>,
478-
codemap: &'x CodeMap,
478+
codemap: &'x SourceMap,
479479
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
480480
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
481481
file_index_to_file: &'x Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,

src/librustc_driver/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ use std::sync::{Once, ONCE_INIT};
107107
use std::thread;
108108

109109
use syntax::ast;
110-
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
110+
use syntax::codemap::{SourceMap, FileLoader, RealFileLoader};
111111
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
112112
use syntax::parse::{self, PResult};
113113
use syntax_pos::{DUMMY_SP, MultiSpan, FileName};
@@ -522,7 +522,7 @@ fn run_compiler_with_pool<'a>(
522522
};
523523

524524
let loader = file_loader.unwrap_or(box RealFileLoader);
525-
let codemap = Lrc::new(CodeMap::with_file_loader(loader, sopts.file_path_mapping()));
525+
let codemap = Lrc::new(SourceMap::with_file_loader(loader, sopts.file_path_mapping()));
526526
let mut sess = session::build_session_with_codemap(
527527
sopts, input_file_path.clone(), descriptions, codemap, emitter_dest,
528528
);

src/librustc_driver/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_data_structures::sync::{self, Lrc};
3232
use syntax;
3333
use syntax::ast;
3434
use rustc_target::spec::abi::Abi;
35-
use syntax::codemap::{CodeMap, FilePathMapping, FileName};
35+
use syntax::codemap::{SourceMap, FilePathMapping, FileName};
3636
use errors;
3737
use errors::emitter::Emitter;
3838
use errors::{Level, DiagnosticBuilder};
@@ -121,7 +121,7 @@ fn test_env_with_pool<F>(
121121
let sess = session::build_session_(options,
122122
None,
123123
diagnostic_handler,
124-
Lrc::new(CodeMap::new(FilePathMapping::empty())));
124+
Lrc::new(SourceMap::new(FilePathMapping::empty())));
125125
let cstore = CStore::new(::get_codegen_backend(&sess).metadata_loader());
126126
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
127127
let input = config::Input::Str {

src/librustc_errors/emitter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use self::Destination::*;
1212

1313
use syntax_pos::{FileMap, Span, MultiSpan};
1414

15-
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapperDyn, DiagnosticId};
15+
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId};
1616
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
1717
use styled_buffer::StyledBuffer;
1818

@@ -120,7 +120,7 @@ impl ColorConfig {
120120

121121
pub struct EmitterWriter {
122122
dst: Destination,
123-
cm: Option<Lrc<CodeMapperDyn>>,
123+
cm: Option<Lrc<SourceMapperDyn>>,
124124
short_message: bool,
125125
teach: bool,
126126
ui_testing: bool,
@@ -134,7 +134,7 @@ struct FileWithAnnotatedLines {
134134

135135
impl EmitterWriter {
136136
pub fn stderr(color_config: ColorConfig,
137-
code_map: Option<Lrc<CodeMapperDyn>>,
137+
code_map: Option<Lrc<SourceMapperDyn>>,
138138
short_message: bool,
139139
teach: bool)
140140
-> EmitterWriter {
@@ -149,7 +149,7 @@ impl EmitterWriter {
149149
}
150150

151151
pub fn new(dst: Box<dyn Write + Send>,
152-
code_map: Option<Lrc<CodeMapperDyn>>,
152+
code_map: Option<Lrc<SourceMapperDyn>>,
153153
short_message: bool,
154154
teach: bool)
155155
-> EmitterWriter {

src/librustc_errors/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ pub struct SubstitutionPart {
111111
pub snippet: String,
112112
}
113113

114-
pub type CodeMapperDyn = dyn CodeMapper + sync::Send + sync::Sync;
114+
pub type SourceMapperDyn = dyn SourceMapper + sync::Send + sync::Sync;
115115

116-
pub trait CodeMapper {
116+
pub trait SourceMapper {
117117
fn lookup_char_pos(&self, pos: BytePos) -> Loc;
118118
fn span_to_lines(&self, sp: Span) -> FileLinesResult;
119119
fn span_to_string(&self, sp: Span) -> String;
@@ -126,7 +126,7 @@ pub trait CodeMapper {
126126

127127
impl CodeSuggestion {
128128
/// Returns the assembled code suggestions and whether they should be shown with an underline.
129-
pub fn splice_lines(&self, cm: &CodeMapperDyn)
129+
pub fn splice_lines(&self, cm: &SourceMapperDyn)
130130
-> Vec<(String, Vec<SubstitutionPart>)> {
131131
use syntax_pos::{CharPos, Loc, Pos};
132132

@@ -321,7 +321,7 @@ impl Handler {
321321
pub fn with_tty_emitter(color_config: ColorConfig,
322322
can_emit_warnings: bool,
323323
treat_err_as_bug: bool,
324-
cm: Option<Lrc<CodeMapperDyn>>)
324+
cm: Option<Lrc<SourceMapperDyn>>)
325325
-> Handler {
326326
Handler::with_tty_emitter_and_flags(
327327
color_config,
@@ -334,7 +334,7 @@ impl Handler {
334334
}
335335

336336
pub fn with_tty_emitter_and_flags(color_config: ColorConfig,
337-
cm: Option<Lrc<CodeMapperDyn>>,
337+
cm: Option<Lrc<SourceMapperDyn>>,
338338
flags: HandlerFlags)
339339
-> Handler {
340340
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false));

src/librustc_metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ impl<'a, 'tcx> CrateMetadata {
11171117
/// multibyte characters. This information is enough to generate valid debuginfo
11181118
/// for items inlined from other crates.
11191119
pub fn imported_filemaps(&'a self,
1120-
local_codemap: &codemap::CodeMap)
1120+
local_codemap: &codemap::SourceMap)
11211121
-> ReadGuard<'a, Vec<cstore::ImportedFileMap>> {
11221122
{
11231123
let filemaps = self.codemap_import_info.borrow();
@@ -1154,7 +1154,7 @@ impl<'a, 'tcx> CrateMetadata {
11541154

11551155
// Translate line-start positions and multibyte character
11561156
// position into frame of reference local to file.
1157-
// `CodeMap::new_imported_filemap()` will then translate those
1157+
// `SourceMap::new_imported_filemap()` will then translate those
11581158
// coordinates to their new global frame of reference when the
11591159
// offset of the FileMap is known.
11601160
for pos in &mut lines {

src/librustc_resolve/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap};
4949
use rustc_metadata::creader::CrateLoader;
5050
use rustc_metadata::cstore::CStore;
5151

52-
use syntax::codemap::CodeMap;
52+
use syntax::codemap::SourceMap;
5353
use syntax::ext::hygiene::{Mark, Transparency, SyntaxContext};
5454
use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy};
5555
use syntax::ext::base::SyntaxExtension;
@@ -415,7 +415,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
415415
/// Attention: The method used is very fragile since it essentially duplicates the work of the
416416
/// parser. If you need to use this function or something similar, please consider updating the
417417
/// codemap functions and this function to something more robust.
418-
fn reduce_impl_span_to_impl_keyword(cm: &CodeMap, impl_span: Span) -> Span {
418+
fn reduce_impl_span_to_impl_keyword(cm: &SourceMap, impl_span: Span) -> Span {
419419
let impl_span = cm.span_until_char(impl_span, '<');
420420
let impl_span = cm.span_until_whitespace(impl_span);
421421
impl_span

src/librustc_typeck/check/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc::hir::map::{NodeItem, NodeExpr};
2121
use rustc::hir::{Item, ItemKind, print};
2222
use rustc::ty::{self, Ty, AssociatedItem};
2323
use rustc::ty::adjustment::AllowTwoPhase;
24-
use errors::{DiagnosticBuilder, CodeMapper};
24+
use errors::{DiagnosticBuilder, SourceMapper};
2525

2626
use super::method::probe;
2727

src/librustdoc/core.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ impl DocAccessLevels for AccessLevels<DefId> {
258258

259259
/// Creates a new diagnostic `Handler` that can be used to emit warnings and errors.
260260
///
261-
/// If the given `error_format` is `ErrorOutputType::Json` and no `CodeMap` is given, a new one
261+
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
262262
/// will be created for the handler.
263-
pub fn new_handler(error_format: ErrorOutputType, codemap: Option<Lrc<codemap::CodeMap>>)
263+
pub fn new_handler(error_format: ErrorOutputType, codemap: Option<Lrc<codemap::SourceMap>>)
264264
-> errors::Handler
265265
{
266266
// 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<Lrc<codemap::C
277277
),
278278
ErrorOutputType::Json(pretty) => {
279279
let codemap = codemap.unwrap_or_else(
280-
|| Lrc::new(codemap::CodeMap::new(sessopts.file_path_mapping())));
280+
|| Lrc::new(codemap::SourceMap::new(sessopts.file_path_mapping())));
281281
Box::new(
282282
JsonEmitter::stderr(
283283
None,
@@ -387,7 +387,7 @@ pub fn run_core(search_paths: SearchPaths,
387387
..Options::default()
388388
};
389389
driver::spawn_thread_pool(sessopts, move |sessopts| {
390-
let codemap = Lrc::new(codemap::CodeMap::new(sessopts.file_path_mapping()));
390+
let codemap = Lrc::new(codemap::SourceMap::new(sessopts.file_path_mapping()));
391391
let diagnostic_handler = new_handler(error_format, Some(codemap.clone()));
392392

393393
let mut sess = session::build_session_(

0 commit comments

Comments
 (0)