mv CodeMap SourceMap
This commit is contained in:
parent
3ac79c7184
commit
c655473378
28 changed files with 133 additions and 133 deletions
|
|
@ -18,7 +18,7 @@ use middle::cstore::CrateStore;
|
|||
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 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||
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<MapEntry<'hir>>, Svh) {
|
||||
self
|
||||
|
|
|
|||
|
|
@ -739,7 +739,7 @@ define_global_metadata_kind!(pub enum GlobalMetaDataKind {
|
|||
LangItems,
|
||||
LangItemsMissing,
|
||||
NativeLibraries,
|
||||
CodeMap,
|
||||
SourceMap,
|
||||
Impls,
|
||||
ExportedSymbols
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub use self::AnnNode::*;
|
|||
|
||||
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 @@ impl PpAnn for hir::Crate {
|
|||
|
||||
pub struct State<'a> {
|
||||
pub s: pp::Printer<'a>,
|
||||
cm: Option<&'a CodeMap>,
|
||||
cm: Option<&'a SourceMap>,
|
||||
comments: Option<Vec<comments::Comment>>,
|
||||
literals: Peekable<vec::IntoIter<comments::Literal>>,
|
||||
cur_cmnt: usize,
|
||||
|
|
@ -129,7 +129,7 @@ pub const default_columns: usize = 78;
|
|||
/// 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 @@ impl<'a> State<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn new(cm: &'a CodeMap,
|
||||
pub fn new(cm: &'a SourceMap,
|
||||
out: Box<dyn Write + 'a>,
|
||||
ann: &'a dyn PpAnn,
|
||||
comments: Option<Vec<comments::Comment>>,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use std::cell::RefCell;
|
|||
|
||||
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<CachingCodemapView<'a>>,
|
||||
|
||||
pub(super) alloc_id_recursion_tracker: FxHashSet<AllocId>,
|
||||
|
|
@ -308,9 +308,9 @@ impl<'a> HashStable<StableHashingContext<'a>> 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
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ impl Session {
|
|||
);
|
||||
}
|
||||
|
||||
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<PathBuf>,
|
||||
registry: errors::registry::Registry,
|
||||
codemap: Lrc<codemap::CodeMap>,
|
||||
codemap: Lrc<codemap::SourceMap>,
|
||||
emitter_dest: Option<Box<dyn Write + Send>>,
|
||||
) -> 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<PathBuf>,
|
||||
span_diagnostic: errors::Handler,
|
||||
codemap: Lrc<codemap::CodeMap>,
|
||||
codemap: Lrc<codemap::SourceMap>,
|
||||
) -> Session {
|
||||
let host_triple = TargetTriple::from_triple(config::host_triple());
|
||||
let host = match Target::search(&host_triple) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
|
|||
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<IndexVec<CrateNum, Option<CrateNum>>>,
|
||||
|
||||
codemap: &'sess CodeMap,
|
||||
codemap: &'sess SourceMap,
|
||||
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
|
||||
|
||||
// These two fields caches that are populated lazily during decoding.
|
||||
|
|
@ -149,7 +149,7 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
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<CrateNum, Option<CrateNum>>,
|
||||
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
|
||||
file_index_to_file: &'x Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ use std::sync::{Once, ONCE_INIT};
|
|||
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,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use rustc_data_structures::sync::{self, Lrc};
|
|||
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<F>(
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use self::Destination::*;
|
|||
|
||||
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 @@ impl ColorConfig {
|
|||
|
||||
pub struct EmitterWriter {
|
||||
dst: Destination,
|
||||
cm: Option<Lrc<CodeMapperDyn>>,
|
||||
cm: Option<Lrc<SourceMapperDyn>>,
|
||||
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<Lrc<CodeMapperDyn>>,
|
||||
code_map: Option<Lrc<SourceMapperDyn>>,
|
||||
short_message: bool,
|
||||
teach: bool)
|
||||
-> EmitterWriter {
|
||||
|
|
@ -149,7 +149,7 @@ impl EmitterWriter {
|
|||
}
|
||||
|
||||
pub fn new(dst: Box<dyn Write + Send>,
|
||||
code_map: Option<Lrc<CodeMapperDyn>>,
|
||||
code_map: Option<Lrc<SourceMapperDyn>>,
|
||||
short_message: bool,
|
||||
teach: bool)
|
||||
-> EmitterWriter {
|
||||
|
|
|
|||
|
|
@ -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<SubstitutionPart>)> {
|
||||
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<Lrc<CodeMapperDyn>>)
|
||||
cm: Option<Lrc<SourceMapperDyn>>)
|
||||
-> Handler {
|
||||
Handler::with_tty_emitter_and_flags(
|
||||
color_config,
|
||||
|
|
@ -334,7 +334,7 @@ impl Handler {
|
|||
}
|
||||
|
||||
pub fn with_tty_emitter_and_flags(color_config: ColorConfig,
|
||||
cm: Option<Lrc<CodeMapperDyn>>,
|
||||
cm: Option<Lrc<SourceMapperDyn>>,
|
||||
flags: HandlerFlags)
|
||||
-> Handler {
|
||||
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false));
|
||||
|
|
|
|||
|
|
@ -1117,7 +1117,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
/// 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<cstore::ImportedFileMap>> {
|
||||
{
|
||||
let filemaps = self.codemap_import_info.borrow();
|
||||
|
|
@ -1154,7 +1154,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
|
||||
// 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 {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap};
|
|||
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
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use rustc::hir::map::{NodeItem, NodeExpr};
|
|||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -258,9 +258,9 @@ impl DocAccessLevels for AccessLevels<DefId> {
|
|||
|
||||
/// 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<Lrc<codemap::CodeMap>>)
|
||||
pub fn new_handler(error_format: ErrorOutputType, codemap: Option<Lrc<codemap::SourceMap>>)
|
||||
-> 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<Lrc<codemap::C
|
|||
),
|
||||
ErrorOutputType::Json(pretty) => {
|
||||
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_(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use std::fmt::Display;
|
|||
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 @@ impl<U: Write> Writer for U {
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use rustc_driver::driver::phase_2_configure_and_expand;
|
|||
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 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(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<PathBuf>,
|
||||
position: Span,
|
||||
codemap: Option<Lrc<CodeMap>>,
|
||||
codemap: 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<CodeMap>>,
|
||||
maybe_sysroot: Option<PathBuf>, codemap: Option<Lrc<SourceMap>>,
|
||||
filename: Option<PathBuf>, linker: Option<PathBuf>, edition: Edition) -> Collector {
|
||||
Collector {
|
||||
tests: Vec::new(),
|
||||
|
|
|
|||
|
|
@ -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::path::{Path, PathBuf};
|
|||
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 @@ impl StableFilemapId {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
// CodeMap
|
||||
// SourceMap
|
||||
//
|
||||
|
||||
pub(super) struct CodeMapFiles {
|
||||
pub(super) struct SourceMapFiles {
|
||||
pub(super) file_maps: Vec<Lrc<FileMap>>,
|
||||
stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<FileMap>>
|
||||
}
|
||||
|
||||
pub struct CodeMap {
|
||||
pub(super) files: Lock<CodeMapFiles>,
|
||||
pub struct SourceMap {
|
||||
pub(super) files: Lock<SourceMapFiles>,
|
||||
file_loader: Box<dyn FileLoader + Sync + Send>,
|
||||
// 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 @@ impl 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<dyn FileLoader + Sync + Send>,
|
||||
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 @@ impl CodeMap {
|
|||
|
||||
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 @@ impl CodeMap {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
/// 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 @@ mod tests {
|
|||
/// 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 @@ mod tests {
|
|||
|
||||
/// Returns the span corresponding to the `n`th occurrence of
|
||||
/// `substring` in `source_text`.
|
||||
trait CodeMapExtension {
|
||||
trait SourceMapExtension {
|
||||
fn span_substr(&self,
|
||||
file: &Lrc<FileMap>,
|
||||
source_text: &str,
|
||||
|
|
@ -1199,7 +1199,7 @@ mod tests {
|
|||
-> Span;
|
||||
}
|
||||
|
||||
impl CodeMapExtension for CodeMap {
|
||||
impl SourceMapExtension for SourceMap {
|
||||
fn span_substr(&self,
|
||||
file: &Lrc<FileMap>,
|
||||
source_text: &str,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub use self::SyntaxExtension::*;
|
|||
|
||||
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 @@ impl<'a> ExtCtxt<'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 {
|
||||
|
|
|
|||
|
|
@ -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 @@ use rustc_serialize::json::{as_json, as_pretty_json};
|
|||
pub struct JsonEmitter {
|
||||
dst: Box<dyn Write + Send>,
|
||||
registry: Option<Registry>,
|
||||
cm: Lrc<dyn CodeMapper + sync::Send + sync::Sync>,
|
||||
cm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
|
||||
pretty: bool,
|
||||
ui_testing: bool,
|
||||
}
|
||||
|
||||
impl JsonEmitter {
|
||||
pub fn stderr(registry: Option<Registry>,
|
||||
code_map: Lrc<CodeMap>,
|
||||
code_map: Lrc<SourceMap>,
|
||||
pretty: bool) -> JsonEmitter {
|
||||
JsonEmitter {
|
||||
dst: Box::new(io::stderr()),
|
||||
|
|
@ -56,13 +56,13 @@ impl JsonEmitter {
|
|||
|
||||
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<dyn Write + Send>,
|
||||
registry: Option<Registry>,
|
||||
code_map: Lrc<CodeMap>,
|
||||
code_map: Lrc<SourceMap>,
|
||||
pretty: bool) -> JsonEmitter {
|
||||
JsonEmitter {
|
||||
dst,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@ impl<'a> StringReader<'a> {
|
|||
|
||||
// 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<CodeMap>) -> ParseSess {
|
||||
fn mk_sess(cm: Lrc<SourceMap>) -> ParseSess {
|
||||
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
|
||||
Some(cm.clone()),
|
||||
false,
|
||||
|
|
@ -1857,7 +1857,7 @@ mod tests {
|
|||
}
|
||||
|
||||
// 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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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 @@ mod tests {
|
|||
#[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();
|
||||
|
|
|
|||
|
|
@ -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<Vec<(ast::Ident, Span)>>,
|
||||
/// Used to determine and report recursive mod inclusions
|
||||
included_mod_stack: Lock<Vec<PathBuf>>,
|
||||
code_map: Lrc<CodeMap>,
|
||||
code_map: Lrc<SourceMap>,
|
||||
pub buffered_lints: Lock<Vec<BufferedEarlyLint>>,
|
||||
}
|
||||
|
||||
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 @@ impl ParseSess {
|
|||
ParseSess::with_span_handler(handler, cm)
|
||||
}
|
||||
|
||||
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>) -> ParseSess {
|
||||
pub fn with_span_handler(handler: Handler, code_map: Lrc<SourceMap>) -> ParseSess {
|
||||
ParseSess {
|
||||
span_diagnostic: handler,
|
||||
unstable_features: UnstableFeatures::from_environment(),
|
||||
|
|
@ -86,7 +86,7 @@ impl ParseSess {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn codemap(&self) -> &CodeMap {
|
||||
pub fn codemap(&self) -> &SourceMap {
|
||||
&self.code_map
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ use ast::{UseTree, UseTreeKind};
|
|||
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 @@ impl<'a> Parser<'a> {
|
|||
id: ast::Ident,
|
||||
relative: Option<ast::Ident>,
|
||||
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
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use ast::{SelfKind, GenericBound, TraitBoundModifier};
|
|||
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<Vec<comments::Comment> >,
|
||||
literals: Peekable<vec::IntoIter<comments::Literal>>,
|
||||
cur_cmnt: usize,
|
||||
|
|
@ -84,7 +84,7 @@ pub const DEFAULT_COLUMNS: usize = 78;
|
|||
/// 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 @@ impl<'a> State<'a> {
|
|||
if is_expanded { None } else { Some(lits) })
|
||||
}
|
||||
|
||||
pub fn new(cm: &'a CodeMap,
|
||||
pub fn new(cm: &'a SourceMap,
|
||||
out: Box<dyn Write+'a>,
|
||||
ann: &'a dyn PpAnn,
|
||||
comments: Option<Vec<comments::Comment>>,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use std::vec;
|
|||
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};
|
||||
|
|
|
|||
|
|
@ -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<SpanLabel>, 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);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ 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
|
||||
/// 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 @@ pub const NO_EXPANSION: SyntaxContext = SyntaxContext::empty();
|
|||
/// 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 @@ impl NonNarrowChar {
|
|||
}
|
||||
}
|
||||
|
||||
/// 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 @@ impl ExternalSource {
|
|||
}
|
||||
}
|
||||
|
||||
/// 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<ExternalSource>,
|
||||
/// 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<BytePos>,
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue