Auto merge of #52953 - dsciarra:mv-codemap-sourcemap, r=petrochenkov
Rename CodeMap/FileMap to SourceMap/SourceFile A first renaming for #51574
This commit is contained in:
commit
6bf6d50a6f
164 changed files with 879 additions and 858 deletions
|
@ -63,7 +63,7 @@ use syntax::errors::DiagnosticBuilder;
|
|||
use syntax::parse::{self, token};
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::tokenstream;
|
||||
use syntax_pos::{FileMap, Pos, FileName};
|
||||
use syntax_pos::{Pos, FileName};
|
||||
|
||||
/// The main type provided by this crate, representing an abstract stream of
|
||||
/// tokens, or, more specifically, a sequence of token trees.
|
||||
|
@ -308,7 +308,7 @@ impl Span {
|
|||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||
pub fn source_file(&self) -> SourceFile {
|
||||
SourceFile {
|
||||
filemap: __internal::lookup_char_pos(self.0.lo()).file,
|
||||
source_file: __internal::lookup_char_pos(self.0.lo()).file,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ impl !Sync for LineColumn {}
|
|||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||
#[derive(Clone)]
|
||||
pub struct SourceFile {
|
||||
filemap: Lrc<FileMap>,
|
||||
source_file: Lrc<syntax_pos::SourceFile>,
|
||||
}
|
||||
|
||||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||
|
@ -432,7 +432,7 @@ impl SourceFile {
|
|||
///
|
||||
/// ### Note
|
||||
/// If the code span associated with this `SourceFile` was generated by an external macro, this
|
||||
/// may not be an actual path on the filesystem. Use [`is_real`] to check.
|
||||
/// macro, this may not be an actual path on the filesystem. Use [`is_real`] to check.
|
||||
///
|
||||
/// Also note that even if `is_real` returns `true`, if `--remap-path-prefix` was passed on
|
||||
/// the command line, the path as given may not actually be valid.
|
||||
|
@ -440,9 +440,9 @@ impl SourceFile {
|
|||
/// [`is_real`]: #method.is_real
|
||||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||
pub fn path(&self) -> PathBuf {
|
||||
match self.filemap.name {
|
||||
match self.source_file.name {
|
||||
FileName::Real(ref path) => path.clone(),
|
||||
_ => PathBuf::from(self.filemap.name.to_string())
|
||||
_ => PathBuf::from(self.source_file.name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ impl SourceFile {
|
|||
// This is a hack until intercrate spans are implemented and we can have real source files
|
||||
// for spans generated in external macros.
|
||||
// https://github.com/rust-lang/rust/pull/43604#issuecomment-333334368
|
||||
self.filemap.is_real_file()
|
||||
self.source_file.is_real_file()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,7 +471,7 @@ impl fmt::Debug for SourceFile {
|
|||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||
impl PartialEq for SourceFile {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Lrc::ptr_eq(&self.filemap, &other.filemap)
|
||||
Lrc::ptr_eq(&self.source_file, &other.source_file)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1186,7 +1186,7 @@ pub mod __internal {
|
|||
use super::{TokenStream, LexError, Span};
|
||||
|
||||
pub fn lookup_char_pos(pos: BytePos) -> Loc {
|
||||
with_sess(|sess, _| sess.codemap().lookup_char_pos(pos))
|
||||
with_sess(|sess, _| sess.source_map().lookup_char_pos(pos))
|
||||
}
|
||||
|
||||
pub fn new_token_stream(item: P<ast::Item>) -> TokenStream {
|
||||
|
|
|
@ -68,7 +68,7 @@ use syntax::errors;
|
|||
use syntax::ext::hygiene::{Mark, SyntaxContext};
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap::{self, respan, CompilerDesugaringKind, Spanned};
|
||||
use syntax::source_map::{self, respan, CompilerDesugaringKind, Spanned};
|
||||
use syntax::std_inject;
|
||||
use syntax::symbol::{keywords, Symbol};
|
||||
use syntax::tokenstream::{Delimited, TokenStream, TokenTree};
|
||||
|
@ -614,14 +614,14 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
fn allow_internal_unstable(&self, reason: CompilerDesugaringKind, span: Span) -> Span {
|
||||
let mark = Mark::fresh(Mark::root());
|
||||
mark.set_expn_info(codemap::ExpnInfo {
|
||||
mark.set_expn_info(source_map::ExpnInfo {
|
||||
call_site: span,
|
||||
def_site: Some(span),
|
||||
format: codemap::CompilerDesugaring(reason),
|
||||
format: source_map::CompilerDesugaring(reason),
|
||||
allow_internal_unstable: true,
|
||||
allow_internal_unsafe: false,
|
||||
local_inner_macros: false,
|
||||
edition: codemap::hygiene::default_edition(),
|
||||
edition: source_map::hygiene::default_edition(),
|
||||
});
|
||||
span.with_ctxt(SyntaxContext::empty().apply_mark(mark))
|
||||
}
|
||||
|
@ -3621,7 +3621,7 @@ impl<'a> LoweringContext<'a> {
|
|||
let tail = block.expr.take().map_or_else(
|
||||
|| {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let span = this.sess.codemap().end_point(unstable_span);
|
||||
let span = this.sess.source_map().end_point(unstable_span);
|
||||
hir::Expr {
|
||||
id: node_id,
|
||||
span,
|
||||
|
|
|
@ -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::source_map::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,
|
||||
source_map: &SourceMap,
|
||||
commandline_args_hash: u64)
|
||||
-> (Vec<MapEntry<'hir>>, Svh) {
|
||||
self
|
||||
|
@ -155,11 +155,11 @@ 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(|filemap| CrateNum::from_u32(filemap.crate_of_origin) == LOCAL_CRATE)
|
||||
.map(|filemap| filemap.name_hash)
|
||||
.filter(|source_file| CrateNum::from_u32(source_file.crate_of_origin) == LOCAL_CRATE)
|
||||
.map(|source_file| source_file.name_hash)
|
||||
.collect();
|
||||
|
||||
source_file_names.sort_unstable();
|
||||
|
|
|
@ -739,7 +739,7 @@ define_global_metadata_kind!(pub enum GlobalMetaDataKind {
|
|||
LangItems,
|
||||
LangItemsMissing,
|
||||
NativeLibraries,
|
||||
CodeMap,
|
||||
SourceMap,
|
||||
Impls,
|
||||
ExportedSymbols
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ use middle::cstore::CrateStore;
|
|||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID};
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::ext::base::MacroKind;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ pub fn map_crate<'hir>(sess: &::session::Session,
|
|||
let cmdline_args = sess.opts.dep_tracking_hash();
|
||||
collector.finalize_and_compute_crate_hash(crate_disambiguator,
|
||||
cstore,
|
||||
sess.codemap(),
|
||||
sess.source_map(),
|
||||
cmdline_args)
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use util::nodemap::{NodeMap, FxHashSet};
|
|||
use mir::mono::Linkage;
|
||||
|
||||
use syntax_pos::{Span, DUMMY_SP, symbol::InternedString};
|
||||
use syntax::codemap::{self, Spanned};
|
||||
use syntax::source_map::{self, Spanned};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect};
|
||||
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
|
||||
|
@ -1100,7 +1100,7 @@ pub type Stmt = Spanned<StmtKind>;
|
|||
impl fmt::Debug for StmtKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// Sadness.
|
||||
let spanned = codemap::dummy_spanned(self.clone());
|
||||
let spanned = source_map::dummy_spanned(self.clone());
|
||||
write!(f,
|
||||
"stmt({}: {})",
|
||||
spanned.node.id(),
|
||||
|
|
|
@ -12,7 +12,7 @@ pub use self::AnnNode::*;
|
|||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{CodeMap, Spanned};
|
||||
use syntax::source_map::{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,8 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax::codemap::CodeMap;
|
||||
use syntax_pos::{BytePos, FileMap};
|
||||
use syntax::source_map::SourceMap;
|
||||
use syntax_pos::{BytePos, SourceFile};
|
||||
|
||||
#[derive(Clone)]
|
||||
struct CacheEntry {
|
||||
|
@ -18,20 +18,20 @@ struct CacheEntry {
|
|||
line_number: usize,
|
||||
line_start: BytePos,
|
||||
line_end: BytePos,
|
||||
file: Lrc<FileMap>,
|
||||
file: Lrc<SourceFile>,
|
||||
file_index: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CachingCodemapView<'cm> {
|
||||
codemap: &'cm CodeMap,
|
||||
pub struct CachingSourceMapView<'cm> {
|
||||
source_map: &'cm SourceMap,
|
||||
line_cache: [CacheEntry; 3],
|
||||
time_stamp: usize,
|
||||
}
|
||||
|
||||
impl<'cm> CachingCodemapView<'cm> {
|
||||
pub fn new(codemap: &'cm CodeMap) -> CachingCodemapView<'cm> {
|
||||
let files = codemap.files();
|
||||
impl<'cm> CachingSourceMapView<'cm> {
|
||||
pub fn new(source_map: &'cm SourceMap) -> CachingSourceMapView<'cm> {
|
||||
let files = source_map.files();
|
||||
let first_file = files[0].clone();
|
||||
let entry = CacheEntry {
|
||||
time_stamp: 0,
|
||||
|
@ -42,8 +42,8 @@ impl<'cm> CachingCodemapView<'cm> {
|
|||
file_index: 0,
|
||||
};
|
||||
|
||||
CachingCodemapView {
|
||||
codemap,
|
||||
CachingSourceMapView {
|
||||
source_map,
|
||||
line_cache: [entry.clone(), entry.clone(), entry.clone()],
|
||||
time_stamp: 0,
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl<'cm> CachingCodemapView<'cm> {
|
|||
|
||||
pub fn byte_pos_to_line_and_col(&mut self,
|
||||
pos: BytePos)
|
||||
-> Option<(Lrc<FileMap>, usize, BytePos)> {
|
||||
-> Option<(Lrc<SourceFile>, usize, BytePos)> {
|
||||
self.time_stamp += 1;
|
||||
|
||||
// Check if the position is in one of the cached lines
|
||||
|
@ -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_filemap_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;
|
||||
|
|
|
@ -12,7 +12,7 @@ use hir;
|
|||
use hir::def_id::{DefId, DefIndex};
|
||||
use hir::map::DefPathHash;
|
||||
use hir::map::definitions::Definitions;
|
||||
use ich::{self, CachingCodemapView, Fingerprint};
|
||||
use ich::{self, CachingSourceMapView, Fingerprint};
|
||||
use middle::cstore::CrateStore;
|
||||
use ty::{TyCtxt, fast_reject};
|
||||
use mir::interpret::AllocId;
|
||||
|
@ -25,7 +25,7 @@ use std::cell::RefCell;
|
|||
|
||||
use syntax::ast;
|
||||
|
||||
use syntax::codemap::CodeMap;
|
||||
use syntax::source_map::SourceMap;
|
||||
use syntax::ext::hygiene::SyntaxContext;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
@ -57,9 +57,9 @@ pub struct StableHashingContext<'a> {
|
|||
node_id_hashing_mode: NodeIdHashingMode,
|
||||
|
||||
// Very often, we are hashing something that does not need the
|
||||
// CachingCodemapView, so we initialize it lazily.
|
||||
raw_codemap: &'a CodeMap,
|
||||
caching_codemap: Option<CachingCodemapView<'a>>,
|
||||
// CachingSourceMapView, so we initialize it lazily.
|
||||
raw_source_map: &'a SourceMap,
|
||||
caching_source_map: Option<CachingSourceMapView<'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.codemap(),
|
||||
caching_source_map: None,
|
||||
raw_source_map: sess.source_map(),
|
||||
hash_spans: hash_spans_initial,
|
||||
hash_bodies: true,
|
||||
node_id_hashing_mode: NodeIdHashingMode::HashDefPath,
|
||||
|
@ -169,13 +169,13 @@ impl<'a> StableHashingContext<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn codemap(&mut self) -> &mut CachingCodemapView<'a> {
|
||||
match self.caching_codemap {
|
||||
pub fn source_map(&mut self) -> &mut CachingSourceMapView<'a> {
|
||||
match self.caching_source_map {
|
||||
Some(ref mut cm) => {
|
||||
cm
|
||||
}
|
||||
ref mut none => {
|
||||
*none = Some(CachingCodemapView::new(self.raw_codemap));
|
||||
*none = Some(CachingSourceMapView::new(self.raw_source_map));
|
||||
none.as_mut().unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
// triple, which stays the same even if the containing FileMap has moved
|
||||
// within the CodeMap.
|
||||
// offsets into the SourceMap). Instead, we hash the (file name, line, column)
|
||||
// triple, which stays the same even if the containing SourceFile has moved
|
||||
// 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
|
||||
|
@ -340,7 +340,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
|
|||
return std_hash::Hash::hash(&TAG_INVALID_SPAN, hasher);
|
||||
}
|
||||
|
||||
let (file_lo, line_lo, col_lo) = match hcx.codemap()
|
||||
let (file_lo, line_lo, col_lo) = match hcx.source_map()
|
||||
.byte_pos_to_line_and_col(span.lo) {
|
||||
Some(pos) => pos,
|
||||
None => {
|
||||
|
|
|
@ -21,7 +21,7 @@ use syntax::feature_gate;
|
|||
use syntax::parse::token;
|
||||
use syntax::symbol::{InternedString, LocalInternedString};
|
||||
use syntax::tokenstream;
|
||||
use syntax_pos::FileMap;
|
||||
use syntax_pos::SourceFile;
|
||||
|
||||
use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
|
||||
|
||||
|
@ -427,11 +427,11 @@ impl_stable_hash_for!(enum ::syntax_pos::FileName {
|
|||
Custom(s)
|
||||
});
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for FileMap {
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let FileMap {
|
||||
let SourceFile {
|
||||
name: _, // We hash the smaller name_hash instead of this
|
||||
name_hash,
|
||||
name_was_remapped,
|
||||
|
@ -458,13 +458,13 @@ impl<'a> HashStable<StableHashingContext<'a>> for FileMap {
|
|||
|
||||
src_hash.hash_stable(hcx, hasher);
|
||||
|
||||
// We only hash the relative position within this filemap
|
||||
// We only hash the relative position within this source_file
|
||||
lines.len().hash_stable(hcx, hasher);
|
||||
for &line in lines.iter() {
|
||||
stable_byte_pos(line, start_pos).hash_stable(hcx, hasher);
|
||||
}
|
||||
|
||||
// We only hash the relative position within this filemap
|
||||
// We only hash the relative position within this source_file
|
||||
multibyte_chars.len().hash_stable(hcx, hasher);
|
||||
for &char_pos in multibyte_chars.iter() {
|
||||
stable_multibyte_char(char_pos, start_pos).hash_stable(hcx, hasher);
|
||||
|
@ -478,29 +478,29 @@ impl<'a> HashStable<StableHashingContext<'a>> for FileMap {
|
|||
}
|
||||
|
||||
fn stable_byte_pos(pos: ::syntax_pos::BytePos,
|
||||
filemap_start: ::syntax_pos::BytePos)
|
||||
source_file_start: ::syntax_pos::BytePos)
|
||||
-> u32 {
|
||||
pos.0 - filemap_start.0
|
||||
pos.0 - source_file_start.0
|
||||
}
|
||||
|
||||
fn stable_multibyte_char(mbc: ::syntax_pos::MultiByteChar,
|
||||
filemap_start: ::syntax_pos::BytePos)
|
||||
source_file_start: ::syntax_pos::BytePos)
|
||||
-> (u32, u32) {
|
||||
let ::syntax_pos::MultiByteChar {
|
||||
pos,
|
||||
bytes,
|
||||
} = mbc;
|
||||
|
||||
(pos.0 - filemap_start.0, bytes as u32)
|
||||
(pos.0 - source_file_start.0, bytes as u32)
|
||||
}
|
||||
|
||||
fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar,
|
||||
filemap_start: ::syntax_pos::BytePos)
|
||||
source_file_start: ::syntax_pos::BytePos)
|
||||
-> (u32, u32) {
|
||||
let pos = swc.pos();
|
||||
let width = swc.width();
|
||||
|
||||
(pos.0 - filemap_start.0, width as u32)
|
||||
(pos.0 - source_file_start.0, width as u32)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//! ICH - Incremental Compilation Hash
|
||||
|
||||
crate use rustc_data_structures::fingerprint::Fingerprint;
|
||||
pub use self::caching_codemap_view::CachingCodemapView;
|
||||
pub use self::caching_codemap_view::CachingSourceMapView;
|
||||
pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
|
||||
hash_stable_trait_impls};
|
||||
mod caching_codemap_view;
|
||||
|
|
|
@ -37,7 +37,7 @@ use rustc_data_structures::small_vec::SmallVec;
|
|||
use rustc_data_structures::sync::Lrc;
|
||||
use serialize::UseSpecializedDecodable;
|
||||
use std::ops::Index;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use ty::fold::TypeFoldable;
|
||||
use ty::subst::Kind;
|
||||
use ty::{self, CanonicalVar, Lift, Region, Slice, TyCtxt};
|
||||
|
|
|
@ -189,7 +189,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
self,
|
||||
region: ty::Region<'tcx>,
|
||||
) -> (String, Option<Span>) {
|
||||
let cm = self.sess.codemap();
|
||||
let cm = self.sess.source_map();
|
||||
|
||||
let scope = region.free_region_binding_scope(self);
|
||||
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
|
||||
|
@ -286,7 +286,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
fn explain_span(self, heading: &str, span: Span) -> (String, Option<Span>) {
|
||||
let lo = self.sess.codemap().lookup_char_pos_adj(span.lo());
|
||||
let lo = self.sess.source_map().lookup_char_pos_adj(span.lo());
|
||||
(
|
||||
format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
|
||||
Some(span),
|
||||
|
@ -502,14 +502,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
ObligationCauseCode::MatchExpressionArm { arm_span, source } => match source {
|
||||
hir::MatchSource::IfLetDesugar { .. } => {
|
||||
let msg = "`if let` arm with an incompatible type";
|
||||
if self.tcx.sess.codemap().is_multiline(arm_span) {
|
||||
if self.tcx.sess.source_map().is_multiline(arm_span) {
|
||||
err.span_note(arm_span, msg);
|
||||
} else {
|
||||
err.span_label(arm_span, msg);
|
||||
}
|
||||
},
|
||||
hir::MatchSource::TryDesugar => { // Issue #51632
|
||||
if let Ok(try_snippet) = self.tcx.sess.codemap().span_to_snippet(arm_span) {
|
||||
if let Ok(try_snippet) = self.tcx.sess.source_map().span_to_snippet(arm_span) {
|
||||
err.span_suggestion_with_applicability(
|
||||
arm_span,
|
||||
"try wrapping with a success variant",
|
||||
|
@ -520,7 +520,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
},
|
||||
_ => {
|
||||
let msg = "match arm with an incompatible type";
|
||||
if self.tcx.sess.codemap().is_multiline(arm_span) {
|
||||
if self.tcx.sess.source_map().is_multiline(arm_span) {
|
||||
err.span_note(arm_span, msg);
|
||||
} else {
|
||||
err.span_label(arm_span, msg);
|
||||
|
@ -1136,8 +1136,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let sp = if has_bounds {
|
||||
sp.to(self.tcx
|
||||
.sess
|
||||
.codemap()
|
||||
.next_point(self.tcx.sess.codemap().next_point(sp)))
|
||||
.source_map()
|
||||
.next_point(self.tcx.sess.source_map().next_point(sp)))
|
||||
} else {
|
||||
sp
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
|
|||
use infer::InferCtxt;
|
||||
use infer::type_variable::TypeVariableOrigin;
|
||||
use ty::{self, Ty, TyInfer, TyVar};
|
||||
use syntax::codemap::CompilerDesugaringKind;
|
||||
use syntax::source_map::CompilerDesugaringKind;
|
||||
use syntax_pos::Span;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use infer::InferCtxt;
|
||||
use infer::lexical_region_resolve::RegionResolutionError;
|
||||
use infer::lexical_region_resolve::RegionResolutionError::*;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use ty::{self, TyCtxt};
|
||||
use util::common::ErrorReported;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
|
|||
}) => name.to_string(),
|
||||
_ => "'_".to_owned(),
|
||||
};
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(return_sp) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(return_sp) {
|
||||
err.span_suggestion(
|
||||
return_sp,
|
||||
&format!(
|
||||
|
|
|
@ -18,7 +18,7 @@ use errors::{Applicability, DiagnosticBuilder};
|
|||
use lint::{LintPass, LateLintPass, LintArray};
|
||||
use session::Session;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
|
||||
declare_lint! {
|
||||
pub EXCEEDING_BITSHIFTS,
|
||||
|
@ -420,7 +420,7 @@ impl BuiltinLintDiagnostics {
|
|||
match self {
|
||||
BuiltinLintDiagnostics::Normal => (),
|
||||
BuiltinLintDiagnostics::BareTraitObject(span, is_global) => {
|
||||
let (sugg, app) = match sess.codemap().span_to_snippet(span) {
|
||||
let (sugg, app) = match sess.source_map().span_to_snippet(span) {
|
||||
Ok(ref s) if is_global => (format!("dyn ({})", s),
|
||||
Applicability::MachineApplicable),
|
||||
Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable),
|
||||
|
@ -429,7 +429,7 @@ impl BuiltinLintDiagnostics {
|
|||
db.span_suggestion_with_applicability(span, "use `dyn`", sugg, app);
|
||||
}
|
||||
BuiltinLintDiagnostics::AbsPathWithModule(span) => {
|
||||
let (sugg, app) = match sess.codemap().span_to_snippet(span) {
|
||||
let (sugg, app) = match sess.source_map().span_to_snippet(span) {
|
||||
Ok(ref s) => {
|
||||
// FIXME(Manishearth) ideally the emitting code
|
||||
// can tell us whether or not this is global
|
||||
|
@ -462,7 +462,7 @@ impl BuiltinLintDiagnostics {
|
|||
// When possible, prefer a suggestion that replaces the whole
|
||||
// `Path<T>` expression with `Path<'_, T>`, rather than inserting `'_, `
|
||||
// at a point (which makes for an ugly/confusing label)
|
||||
if let Ok(snippet) = sess.codemap().span_to_snippet(path_span) {
|
||||
if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) {
|
||||
// But our spans can get out of whack due to macros; if the place we think
|
||||
// we want to insert `'_` isn't even within the path expression's span, we
|
||||
// should bail out of making any suggestion rather than panicking on a
|
||||
|
|
|
@ -21,7 +21,7 @@ use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
|
|||
use session::Session;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::MultiSpan;
|
||||
use syntax::source_map::MultiSpan;
|
||||
use syntax::feature_gate;
|
||||
use syntax::symbol::Symbol;
|
||||
use util::nodemap::FxHashMap;
|
||||
|
|
|
@ -42,7 +42,7 @@ use lint::builtin::parser::QUESTION_MARK_MACRO_SEP;
|
|||
use session::{Session, DiagnosticMessageId};
|
||||
use std::{hash, ptr};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{MultiSpan, ExpnFormat};
|
||||
use syntax::source_map::{MultiSpan, ExpnFormat};
|
||||
use syntax::early_buffered_lints::BufferedEarlyLintId;
|
||||
use syntax::edition::Edition;
|
||||
use syntax::symbol::Symbol;
|
||||
|
@ -754,7 +754,7 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
|
|||
None => return true,
|
||||
};
|
||||
|
||||
match sess.codemap().span_to_snippet(def_site) {
|
||||
match sess.source_map().span_to_snippet(def_site) {
|
||||
Ok(code) => !code.starts_with("macro_rules"),
|
||||
// no snippet = external macro or compiler-builtin expansion
|
||||
Err(_) => true,
|
||||
|
|
|
@ -147,7 +147,7 @@ macro_rules! impl_stable_hash_for {
|
|||
macro_rules! impl_stable_hash_for_spanned {
|
||||
($T:path) => (
|
||||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ::syntax::codemap::Spanned<$T>
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
|
||||
{
|
||||
#[inline]
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
|
|
|
@ -24,7 +24,7 @@ use middle::privacy;
|
|||
use ty::{self, TyCtxt};
|
||||
use util::nodemap::FxHashSet;
|
||||
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::{ast, source_map};
|
||||
use syntax::attr;
|
||||
use syntax_pos;
|
||||
|
||||
|
@ -115,7 +115,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, def: Def,
|
||||
pats: &[codemap::Spanned<hir::FieldPat>]) {
|
||||
pats: &[source_map::Spanned<hir::FieldPat>]) {
|
||||
let variant = match self.tables.node_id_to_type(lhs.hir_id).sty {
|
||||
ty::TyAdt(adt, _) => adt.variant_of_def(def),
|
||||
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
|
||||
|
@ -551,7 +551,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
|||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
hir::ItemKind::Trait(..) |
|
||||
hir::ItemKind::Impl(..) => self.tcx.sess.codemap().def_span(item.span),
|
||||
hir::ItemKind::Impl(..) => self.tcx.sess.source_map().def_span(item.span),
|
||||
_ => item.span,
|
||||
};
|
||||
let participle = match item.node {
|
||||
|
@ -612,7 +612,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
|||
}
|
||||
hir::ImplItemKind::Method(_, body_id) => {
|
||||
if !self.symbol_is_live(impl_item.id, None) {
|
||||
let span = self.tcx.sess.codemap().def_span(impl_item.span);
|
||||
let span = self.tcx.sess.source_map().def_span(impl_item.span);
|
||||
self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used");
|
||||
}
|
||||
self.visit_nested_body(body_id)
|
||||
|
|
|
@ -157,7 +157,7 @@ enum LiveNodeKind {
|
|||
}
|
||||
|
||||
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt) -> String {
|
||||
let cm = tcx.sess.codemap();
|
||||
let cm = tcx.sess.source_map();
|
||||
match lnk {
|
||||
FreeVarNode(s) => {
|
||||
format!("Free var node [{}]", cm.span_to_string(s))
|
||||
|
|
|
@ -23,7 +23,7 @@ use ty;
|
|||
use std::fmt;
|
||||
use std::mem;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax::codemap;
|
||||
use syntax::source_map;
|
||||
use syntax::ast;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use ty::TyCtxt;
|
||||
|
@ -943,11 +943,15 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
|
|||
// scopes, meaning that temporaries cannot outlive them.
|
||||
// This ensures fixed size stacks.
|
||||
|
||||
hir::ExprKind::Binary(codemap::Spanned { node: hir::BinOpKind::And, .. }, _, ref r) |
|
||||
hir::ExprKind::Binary(codemap::Spanned { node: hir::BinOpKind::Or, .. }, _, ref r) => {
|
||||
// For shortcircuiting operators, mark the RHS as a terminating
|
||||
// scope since it only executes conditionally.
|
||||
terminating(r.hir_id.local_id);
|
||||
hir::ExprKind::Binary(
|
||||
source_map::Spanned { node: hir::BinOpKind::And, .. },
|
||||
_, ref r) |
|
||||
hir::ExprKind::Binary(
|
||||
source_map::Spanned { node: hir::BinOpKind::Or, .. },
|
||||
_, ref r) => {
|
||||
// For shortcircuiting operators, mark the RHS as a terminating
|
||||
// scope since it only executes conditionally.
|
||||
terminating(r.hir_id.local_id);
|
||||
}
|
||||
|
||||
hir::ExprKind::If(ref expr, ref then, Some(ref otherwise)) => {
|
||||
|
@ -1310,7 +1314,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
|
|||
|
||||
debug!("visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})",
|
||||
owner_id,
|
||||
self.tcx.sess.codemap().span_to_string(body.value.span),
|
||||
self.tcx.sess.source_map().span_to_string(body.value.span),
|
||||
body_id,
|
||||
self.cx.parent);
|
||||
|
||||
|
|
|
@ -2457,7 +2457,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
"insert_lifetime: {} resolved to {:?} span={:?}",
|
||||
self.tcx.hir.node_to_string(lifetime_ref.id),
|
||||
def,
|
||||
self.tcx.sess.codemap().span_to_string(lifetime_ref.span)
|
||||
self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
|
||||
);
|
||||
self.map.defs.insert(lifetime_ref.id, def);
|
||||
|
||||
|
|
|
@ -685,7 +685,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
|
||||
let msp: MultiSpan = span.into();
|
||||
let cm = &self.sess.parse_sess.codemap();
|
||||
let cm = &self.sess.parse_sess.source_map();
|
||||
let span_key = msp.primary_span().and_then(|sp: Span|
|
||||
if !sp.is_dummy() {
|
||||
let file = cm.lookup_char_pos(sp.lo()).file;
|
||||
|
|
|
@ -22,7 +22,7 @@ use lint;
|
|||
use middle::cstore;
|
||||
|
||||
use syntax::ast::{self, IntTy, UintTy};
|
||||
use syntax::codemap::{FileName, FilePathMapping};
|
||||
use syntax::source_map::{FileName, FilePathMapping};
|
||||
use syntax::edition::{Edition, EDITION_NAME_LIST, DEFAULT_EDITION};
|
||||
use syntax::parse::token;
|
||||
use syntax::parse;
|
||||
|
|
|
@ -35,7 +35,7 @@ use syntax::json::JsonEmitter;
|
|||
use syntax::feature_gate;
|
||||
use syntax::parse;
|
||||
use syntax::parse::ParseSess;
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::{ast, source_map};
|
||||
use syntax::feature_gate::AttributeType;
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
use util::profiling::SelfProfiler;
|
||||
|
@ -484,8 +484,8 @@ impl Session {
|
|||
);
|
||||
}
|
||||
|
||||
pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
|
||||
self.parse_sess.codemap()
|
||||
pub fn source_map<'a>(&'a self) -> &'a source_map::SourceMap {
|
||||
self.parse_sess.source_map()
|
||||
}
|
||||
pub fn verbose(&self) -> bool {
|
||||
self.opts.debugging_opts.verbose
|
||||
|
@ -980,20 +980,20 @@ 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,
|
||||
Lrc::new(codemap::CodeMap::new(file_path_mapping)),
|
||||
Lrc::new(source_map::SourceMap::new(file_path_mapping)),
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
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<codemap::CodeMap>,
|
||||
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<codemap::CodeMap>,
|
||||
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()),
|
||||
|
|
|
@ -528,12 +528,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
let msg = "impl has stricter requirements than trait";
|
||||
let sp = self.tcx.sess.codemap().def_span(error_span);
|
||||
let sp = self.tcx.sess.source_map().def_span(error_span);
|
||||
|
||||
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
|
||||
|
||||
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
|
||||
let span = self.tcx.sess.codemap().def_span(trait_item_span);
|
||||
let span = self.tcx.sess.source_map().def_span(trait_item_span);
|
||||
err.span_label(span, format!("definition of `{}` from trait", item_name));
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap();
|
||||
let closure_span = self.tcx.sess.codemap()
|
||||
let closure_span = self.tcx.sess.source_map()
|
||||
.def_span(self.tcx.hir.span_if_local(closure_def_id).unwrap());
|
||||
let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap();
|
||||
let mut err = struct_span_err!(
|
||||
|
@ -792,7 +792,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
let found_span = found_did.and_then(|did| {
|
||||
self.tcx.hir.span_if_local(did)
|
||||
}).map(|sp| self.tcx.sess.codemap().def_span(sp)); // the sp could be an fn def
|
||||
}).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def
|
||||
|
||||
let found = match found_trait_ref.skip_binder().substs.type_at(1).sty {
|
||||
ty::TyTuple(ref tys) => tys.iter()
|
||||
|
@ -867,7 +867,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
if let Some(hir::map::NodeLocal(ref local)) = self.tcx.hir.find(parent_node) {
|
||||
if let Some(ref expr) = local.init {
|
||||
if let hir::ExprKind::Index(_, _) = expr.node {
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
|
||||
err.span_suggestion_with_applicability(
|
||||
expr.span,
|
||||
"consider borrowing here",
|
||||
|
@ -890,7 +890,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let trait_ref = trait_ref.skip_binder();
|
||||
let span = obligation.cause.span;
|
||||
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
let refs_number = snippet.chars()
|
||||
.filter(|c| !c.is_whitespace())
|
||||
.take_while(|c| *c == '&')
|
||||
|
@ -909,7 +909,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
new_trait_ref.to_predicate());
|
||||
|
||||
if self.predicate_may_hold(&new_obligation) {
|
||||
let sp = self.tcx.sess.codemap()
|
||||
let sp = self.tcx.sess.source_map()
|
||||
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
|
||||
|
||||
let remove_refs = refs_remaining + 1;
|
||||
|
@ -938,7 +938,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
node: hir::ExprKind::Closure(_, ref _decl, id, span, _),
|
||||
..
|
||||
}) => {
|
||||
(self.tcx.sess.codemap().def_span(span), self.tcx.hir.body(id).arguments.iter()
|
||||
(self.tcx.sess.source_map().def_span(span), self.tcx.hir.body(id).arguments.iter()
|
||||
.map(|arg| {
|
||||
if let hir::Pat {
|
||||
node: hir::PatKind::Tuple(args, _),
|
||||
|
@ -948,13 +948,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
ArgKind::Tuple(
|
||||
Some(span),
|
||||
args.iter().map(|pat| {
|
||||
let snippet = self.tcx.sess.codemap()
|
||||
let snippet = self.tcx.sess.source_map()
|
||||
.span_to_snippet(pat.span).unwrap();
|
||||
(snippet, "_".to_owned())
|
||||
}).collect::<Vec<_>>(),
|
||||
)
|
||||
} else {
|
||||
let name = self.tcx.sess.codemap()
|
||||
let name = self.tcx.sess.source_map()
|
||||
.span_to_snippet(arg.pat.span).unwrap();
|
||||
ArgKind::Arg(name, "_".to_owned())
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
..
|
||||
}) => {
|
||||
(self.tcx.sess.codemap().def_span(span), decl.inputs.iter()
|
||||
(self.tcx.sess.source_map().def_span(span), decl.inputs.iter()
|
||||
.map(|arg| match arg.clone().node {
|
||||
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
|
||||
Some(arg.span),
|
||||
|
@ -995,13 +995,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
},
|
||||
..
|
||||
}) => {
|
||||
(self.tcx.sess.codemap().def_span(span),
|
||||
(self.tcx.sess.source_map().def_span(span),
|
||||
fields.iter().map(|field| {
|
||||
ArgKind::Arg(field.ident.to_string(), "_".to_string())
|
||||
}).collect::<Vec<_>>())
|
||||
}
|
||||
hir::map::NodeStructCtor(ref variant_data) => {
|
||||
(self.tcx.sess.codemap().def_span(self.tcx.hir.span(variant_data.id())),
|
||||
(self.tcx.sess.source_map().def_span(self.tcx.hir.span(variant_data.id())),
|
||||
variant_data.fields()
|
||||
.iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned()))
|
||||
.collect())
|
||||
|
@ -1192,7 +1192,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
{
|
||||
assert!(type_def_id.is_local());
|
||||
let span = self.hir.span_if_local(type_def_id).unwrap();
|
||||
let span = self.sess.codemap().def_span(span);
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
let mut err = struct_span_err!(self.sess, span, E0072,
|
||||
"recursive type `{}` has infinite size",
|
||||
self.item_path_str(type_def_id));
|
||||
|
@ -1210,7 +1210,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
let trait_str = self.item_path_str(trait_def_id);
|
||||
let span = self.sess.codemap().def_span(span);
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
let mut err = struct_span_err!(
|
||||
self.sess, span, E0038,
|
||||
"the trait `{}` cannot be made into an object",
|
||||
|
@ -1438,7 +1438,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let item_name = tcx.item_path_str(item_def_id);
|
||||
let msg = format!("required by `{}`", item_name);
|
||||
if let Some(sp) = tcx.hir.span_if_local(item_def_id) {
|
||||
let sp = tcx.sess.codemap().def_span(sp);
|
||||
let sp = tcx.sess.source_map().def_span(sp);
|
||||
err.span_note(sp, &msg);
|
||||
} else {
|
||||
err.note(&msg);
|
||||
|
|
|
@ -142,7 +142,7 @@ impl<'tcx> ObligationCause<'tcx> {
|
|||
ObligationCauseCode::CompareImplMethodObligation { .. } |
|
||||
ObligationCauseCode::MainFunctionType |
|
||||
ObligationCauseCode::StartFunctionType => {
|
||||
tcx.sess.codemap().def_span(self.span)
|
||||
tcx.sess.source_map().def_span(self.span)
|
||||
}
|
||||
_ => self.span,
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use infer::at::At;
|
|||
use infer::InferOk;
|
||||
use rustc_data_structures::small_vec::SmallVec;
|
||||
use std::iter::FromIterator;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use ty::subst::Kind;
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use infer::InferCtxt;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use rustc_data_structures::small_vec::SmallVec;
|
||||
use traits::{FulfillmentContext, ObligationCause, TraitEngine, TraitEngineExt};
|
||||
use traits::query::NoSolution;
|
||||
|
|
|
@ -15,7 +15,7 @@ use traits::query::Fallible;
|
|||
use infer::canonical::query_result;
|
||||
use infer::canonical::QueryRegionConstraint;
|
||||
use std::rc::Rc;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::source_map::DUMMY_SP;
|
||||
use traits::{ObligationCause, TraitEngine, TraitEngineExt};
|
||||
|
||||
pub struct CustomTypeOp<F, G> {
|
||||
|
|
|
@ -344,7 +344,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
|
|||
}),
|
||||
if used_to_be_allowed { " (E0119)" } else { "" }
|
||||
);
|
||||
let impl_span = tcx.sess.codemap().def_span(
|
||||
let impl_span = tcx.sess.source_map().def_span(
|
||||
tcx.span_of_impl(impl_def_id).unwrap()
|
||||
);
|
||||
let mut err = if used_to_be_allowed {
|
||||
|
@ -363,7 +363,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
|
|||
|
||||
match tcx.span_of_impl(overlap.with_impl) {
|
||||
Ok(span) => {
|
||||
err.span_label(tcx.sess.codemap().def_span(span),
|
||||
err.span_label(tcx.sess.source_map().def_span(span),
|
||||
"first implementation here".to_string());
|
||||
err.span_label(impl_span,
|
||||
format!("conflicting implementation{}",
|
||||
|
|
|
@ -73,7 +73,7 @@ use std::sync::Arc;
|
|||
use rustc_target::spec::abi;
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::MultiSpan;
|
||||
use syntax::source_map::MultiSpan;
|
||||
use syntax::edition::Edition;
|
||||
use syntax::feature_gate;
|
||||
use syntax::symbol::{Symbol, keywords, InternedString};
|
||||
|
@ -1818,7 +1818,7 @@ pub mod tls {
|
|||
/// in librustc otherwise
|
||||
fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
with(|tcx| {
|
||||
write!(f, "{}", tcx.sess.codemap().span_to_string(span))
|
||||
write!(f, "{}", tcx.sess.source_map().span_to_string(span))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
match (&values.found.sty, &values.expected.sty) { // Issue #53280
|
||||
(ty::TyInfer(ty::IntVar(_)), ty::TyFloat(_)) => {
|
||||
if let Ok(snippet) = self.sess.codemap().span_to_snippet(sp) {
|
||||
if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) {
|
||||
if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') {
|
||||
db.span_suggestion_with_applicability(
|
||||
sp,
|
||||
|
|
|
@ -336,7 +336,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
self.push_item_path(buffer, parent_def_id);
|
||||
let node_id = self.hir.as_local_node_id(impl_def_id).unwrap();
|
||||
let item = self.hir.expect_item(node_id);
|
||||
let span_str = self.sess.codemap().span_to_string(item.span);
|
||||
let span_str = self.sess.source_map().span_to_string(item.span);
|
||||
buffer.push(&format!("<impl at {}>", span_str));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use hir;
|
|||
use hir::def_id::{CrateNum, DefIndex, DefId, LocalDefId,
|
||||
RESERVED_FOR_INCR_COMP_CACHE, LOCAL_CRATE};
|
||||
use hir::map::definitions::DefPathHash;
|
||||
use ich::{CachingCodemapView, Fingerprint};
|
||||
use ich::{CachingSourceMapView, Fingerprint};
|
||||
use mir::{self, interpret};
|
||||
use mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -26,8 +26,8 @@ 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_pos::{BytePos, Span, DUMMY_SP, FileMap};
|
||||
use syntax::source_map::{SourceMap, StableFilemapId};
|
||||
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
|
||||
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
|
||||
use ty;
|
||||
use ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
|
||||
|
@ -62,11 +62,11 @@ pub struct OnDiskCache<'sess> {
|
|||
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
|
||||
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
|
||||
|
||||
codemap: &'sess CodeMap,
|
||||
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
|
||||
source_map: &'sess SourceMap,
|
||||
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
|
||||
|
||||
// These two fields caches that are populated lazily during decoding.
|
||||
file_index_to_file: Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
|
||||
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
|
||||
synthetic_expansion_infos: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
|
||||
|
||||
// A map from dep-node to the position of the cached query result in
|
||||
|
@ -83,7 +83,7 @@ pub struct OnDiskCache<'sess> {
|
|||
// This type is used only for (de-)serialization.
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
struct Footer {
|
||||
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
|
||||
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
|
||||
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
|
||||
query_result_index: EncodedQueryResultIndex,
|
||||
diagnostics_index: EncodedQueryResultIndex,
|
||||
|
@ -96,7 +96,7 @@ type EncodedDiagnosticsIndex = Vec<(SerializedDepNodeIndex, AbsoluteBytePos)>;
|
|||
type EncodedDiagnostics = Vec<Diagnostic>;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
|
||||
struct FileMapIndex(u32);
|
||||
struct SourceFileIndex(u32);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
struct AbsoluteBytePos(u32);
|
||||
|
@ -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.codemap(),
|
||||
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 CodeMap) -> 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(),
|
||||
|
@ -173,14 +173,14 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
{
|
||||
// Serializing the DepGraph should not modify it:
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
// Allocate FileMapIndices
|
||||
// Allocate SourceFileIndices
|
||||
let (file_to_file_index, file_index_to_stable_id) = {
|
||||
let mut file_to_file_index = FxHashMap();
|
||||
let mut file_index_to_stable_id = FxHashMap();
|
||||
|
||||
for (index, file) in tcx.sess.codemap().files().iter().enumerate() {
|
||||
let index = FileMapIndex(index as u32);
|
||||
let file_ptr: *const FileMap = &**file as *const _;
|
||||
for (index, file) in tcx.sess.source_map().files().iter().enumerate() {
|
||||
let index = SourceFileIndex(index as u32);
|
||||
let file_ptr: *const SourceFile = &**file as *const _;
|
||||
file_to_file_index.insert(file_ptr, index);
|
||||
file_index_to_stable_id.insert(index, StableFilemapId::new(&file));
|
||||
}
|
||||
|
@ -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.codemap()),
|
||||
source_map: CachingSourceMapView::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,27 +475,27 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
struct CacheDecoder<'a, 'tcx: 'a, 'x> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
opaque: opaque::Decoder<'x>,
|
||||
codemap: &'x CodeMap,
|
||||
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<FileMapIndex, Lrc<FileMap>>>,
|
||||
file_index_to_stable_id: &'x FxHashMap<FileMapIndex, StableFilemapId>,
|
||||
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
|
||||
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>,
|
||||
alloc_decoding_session: AllocDecodingSession<'x>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
|
||||
fn file_index_to_file(&self, index: FileMapIndex) -> Lrc<FileMap> {
|
||||
fn file_index_to_file(&self, index: SourceFileIndex) -> Lrc<SourceFile> {
|
||||
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.filemap_by_stable_id(stable_id)
|
||||
.expect("Failed to lookup FileMap in new context.")
|
||||
source_map.source_file_by_stable_id(stable_id)
|
||||
.expect("Failed to lookup SourceFile in new context.")
|
||||
}).clone()
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
|
|||
debug_assert_eq!(tag, TAG_VALID_SPAN);
|
||||
}
|
||||
|
||||
let file_lo_index = FileMapIndex::decode(self)?;
|
||||
let file_lo_index = SourceFileIndex::decode(self)?;
|
||||
let line_lo = usize::decode(self)?;
|
||||
let col_lo = BytePos::decode(self)?;
|
||||
let len = BytePos::decode(self)?;
|
||||
|
@ -770,15 +770,15 @@ 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>,
|
||||
file_to_file_index: FxHashMap<*const FileMap, FileMapIndex>,
|
||||
source_map: CachingSourceMapView<'tcx>,
|
||||
file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>,
|
||||
}
|
||||
|
||||
impl<'enc, 'a, 'tcx, E> CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
fn filemap_index(&mut self, filemap: Lrc<FileMap>) -> FileMapIndex {
|
||||
self.file_to_file_index[&(&*filemap as *const FileMap)]
|
||||
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
|
||||
self.file_to_file_index[&(&*source_file as *const SourceFile)]
|
||||
}
|
||||
|
||||
/// Encode something with additional information that allows to do some
|
||||
|
@ -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 => {
|
||||
|
@ -850,10 +850,10 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'enc, 'a, 'tcx
|
|||
|
||||
let len = span_data.hi - span_data.lo;
|
||||
|
||||
let filemap_index = self.filemap_index(file_lo);
|
||||
let source_file_index = self.source_file_index(file_lo);
|
||||
|
||||
TAG_VALID_SPAN.encode(self)?;
|
||||
filemap_index.encode(self)?;
|
||||
source_file_index.encode(self)?;
|
||||
line_lo.encode(self)?;
|
||||
col_lo.encode(self)?;
|
||||
len.encode(self)?;
|
||||
|
|
|
@ -32,7 +32,7 @@ use std::mem;
|
|||
use std::ptr;
|
||||
use std::collections::hash_map::Entry;
|
||||
use syntax_pos::Span;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::source_map::DUMMY_SP;
|
||||
|
||||
pub struct QueryCache<'tcx, D: QueryConfig<'tcx> + ?Sized> {
|
||||
pub(super) results: FxHashMap<D::Key, QueryValue<D::Value>>,
|
||||
|
@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
assert!(!stack.is_empty());
|
||||
|
||||
let fix_span = |span: Span, query: &Query<'gcx>| {
|
||||
self.sess.codemap().def_span(query.default_span(self, span))
|
||||
self.sess.source_map().def_span(query.default_span(self, span))
|
||||
};
|
||||
|
||||
// Disable naming impls with types in this path, since that
|
||||
|
@ -299,7 +299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
i,
|
||||
query.info.query.name(),
|
||||
query.info.query.describe(icx.tcx)));
|
||||
db.set_span(icx.tcx.sess.codemap().def_span(query.info.span));
|
||||
db.set_span(icx.tcx.sess.source_map().def_span(query.info.span));
|
||||
icx.tcx.sess.diagnostic().force_print_db(db);
|
||||
|
||||
current_query = query.parent.clone();
|
||||
|
|
|
@ -17,7 +17,7 @@ use syntax::{
|
|||
Mac, Mod, Mutability, Ty, TyKind, Unsafety, VisibilityKind,
|
||||
},
|
||||
attr,
|
||||
codemap::{
|
||||
source_map::{
|
||||
respan, ExpnInfo, MacroAttribute,
|
||||
},
|
||||
ext::{
|
||||
|
|
|
@ -594,7 +594,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
// 3. Where does old loan expire.
|
||||
|
||||
let previous_end_span =
|
||||
Some(self.tcx().sess.codemap().end_point(
|
||||
Some(self.tcx().sess.source_map().end_point(
|
||||
old_loan.kill_scope.span(self.tcx(), &self.bccx.region_scope_tree)));
|
||||
|
||||
let mut err = match (new_loan.kind, old_loan.kind) {
|
||||
|
|
|
@ -79,7 +79,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr
|
|||
// see `get_pattern_source()` for details
|
||||
let initializer =
|
||||
e.init.as_ref().expect("should have an initializer to get an error");
|
||||
if let Ok(snippet) = bccx.tcx.sess.codemap().span_to_snippet(initializer.span) {
|
||||
if let Ok(snippet) = bccx.tcx.sess.source_map().span_to_snippet(initializer.span) {
|
||||
err.span_suggestion(initializer.span,
|
||||
"consider using a reference instead",
|
||||
format!("&{}", snippet));
|
||||
|
|
|
@ -848,7 +848,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
let sp = self.tcx.hir.span(node_id);
|
||||
let fn_closure_msg = "`Fn` closures cannot capture their enclosing \
|
||||
environment for modifications";
|
||||
match (self.tcx.sess.codemap().span_to_snippet(sp), &err.cmt.cat) {
|
||||
match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) {
|
||||
(_, &Categorization::Upvar(mc::Upvar {
|
||||
kind: ty::ClosureKind::Fn, ..
|
||||
})) => {
|
||||
|
@ -1160,13 +1160,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
ref ty
|
||||
}) = pty.node {
|
||||
// Account for existing lifetimes when generating the message
|
||||
let pointee_snippet = match self.tcx.sess.codemap().span_to_snippet(ty.span) {
|
||||
let pointee_snippet = match self.tcx.sess.source_map().span_to_snippet(ty.span) {
|
||||
Ok(snippet) => snippet,
|
||||
_ => return None
|
||||
};
|
||||
|
||||
let lifetime_snippet = if !lifetime.is_elided() {
|
||||
format!("{} ", match self.tcx.sess.codemap().span_to_snippet(lifetime.span) {
|
||||
format!("{} ", match self.tcx.sess.source_map().span_to_snippet(lifetime.span) {
|
||||
Ok(lifetime_snippet) => lifetime_snippet,
|
||||
_ => return None
|
||||
})
|
||||
|
@ -1277,7 +1277,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
binding_node_id: ast::NodeId) {
|
||||
let let_span = self.tcx.hir.span(binding_node_id);
|
||||
if let ty::BindByValue(..) = self.local_binding_mode(binding_node_id) {
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(let_span) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
|
||||
let (ty, is_implicit_self) = self.local_ty(binding_node_id);
|
||||
if is_implicit_self && snippet != "self" {
|
||||
// avoid suggesting `mut &self`.
|
||||
|
@ -1315,7 +1315,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
let cmt_path_or_string = self.cmt_to_path_or_string(&err.cmt);
|
||||
|
||||
let suggestion =
|
||||
match self.tcx.sess.codemap().span_to_snippet(err.span) {
|
||||
match self.tcx.sess.source_map().span_to_snippet(err.span) {
|
||||
Ok(string) => format!("move {}", string),
|
||||
Err(_) => "move |<args>| <body>".to_string()
|
||||
};
|
||||
|
@ -1337,7 +1337,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
fn region_end_span(&self, region: ty::Region<'tcx>) -> Option<Span> {
|
||||
match *region {
|
||||
ty::ReScope(scope) => {
|
||||
Some(self.tcx.sess.codemap().end_point(
|
||||
Some(self.tcx.sess.source_map().end_point(
|
||||
scope.span(self.tcx, &self.region_scope_tree)))
|
||||
}
|
||||
_ => None
|
||||
|
@ -1368,7 +1368,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
db.span_label(*error_span, "cannot borrow as mutable");
|
||||
} else if let Categorization::Local(local_id) = err.cmt.cat {
|
||||
let span = self.tcx.hir.span(local_id);
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
|
||||
db.span_label(*error_span, "cannot reborrow mutably");
|
||||
db.span_label(*error_span, "try removing `&mut` here");
|
||||
|
|
|
@ -75,7 +75,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let (hir_id, span) = ids[0];
|
||||
let mut_span = tcx.sess.codemap().span_until_non_whitespace(span);
|
||||
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
|
||||
|
||||
// Ok, every name wasn't used mutably, so issue a warning that this
|
||||
// didn't need to be mutable.
|
||||
|
|
|
@ -1745,7 +1745,7 @@ pub fn create_global_var_metadata(
|
|||
pub fn extend_scope_to_file(
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
scope_metadata: &'ll DIScope,
|
||||
file: &syntax_pos::FileMap,
|
||||
file: &syntax_pos::SourceFile,
|
||||
defining_crate: CrateNum,
|
||||
) -> &'ll DILexicalBlock {
|
||||
let file_metadata = file_metadata(cx, &file.name, defining_crate);
|
||||
|
|
|
@ -40,7 +40,7 @@ pub fn set_source_location(
|
|||
};
|
||||
|
||||
let dbg_loc = if function_debug_context.source_locations_enabled.get() {
|
||||
debug!("set_source_location: {}", bx.sess().codemap().span_to_string(span));
|
||||
debug!("set_source_location: {}", bx.sess().source_map().span_to_string(span));
|
||||
let loc = span_start(bx.cx, span);
|
||||
InternalDebugLocation::new(scope.unwrap(), loc.line, loc.col.to_usize())
|
||||
} else {
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn create_DIArray(
|
|||
|
||||
/// Return syntax_pos::Loc corresponding to the beginning of the span
|
||||
pub fn span_start(cx: &CodegenCx, span: Span) -> syntax_pos::Loc {
|
||||
cx.sess().codemap().lookup_char_pos(span.lo())
|
||||
cx.sess().source_map().lookup_char_pos(span.lo())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -359,7 +359,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
self.set_debug_loc(&bx, terminator.source_info);
|
||||
|
||||
// Get the location information.
|
||||
let loc = bx.sess().codemap().lookup_char_pos(span.lo());
|
||||
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
|
||||
let filename = Symbol::intern(&loc.file.name.to_string()).as_str();
|
||||
let filename = C_str_slice(bx.cx, filename);
|
||||
let line = C_u32(bx.cx, loc.line as u32);
|
||||
|
|
|
@ -25,7 +25,7 @@ use consts;
|
|||
use type_of::LayoutLlvmExt;
|
||||
use type_::Type;
|
||||
use syntax::ast::Mutability;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use value::Value;
|
||||
|
||||
use super::super::callee;
|
||||
|
|
|
@ -166,7 +166,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
let scope_metadata = self.scopes[scope_id].scope_metadata;
|
||||
if pos < self.scopes[scope_id].file_start_pos ||
|
||||
pos >= self.scopes[scope_id].file_end_pos {
|
||||
let cm = self.cx.sess().codemap();
|
||||
let cm = self.cx.sess().source_map();
|
||||
let defining_crate = self.debug_context.get_ref(DUMMY_SP).defining_crate;
|
||||
Some(debuginfo::extend_scope_to_file(self.cx,
|
||||
scope_metadata.unwrap(),
|
||||
|
|
|
@ -695,7 +695,7 @@ pub fn phase_1_parse_input<'a>(
|
|||
if sess.opts.debugging_opts.input_stats {
|
||||
println!(
|
||||
"Lines of code: {}",
|
||||
sess.codemap().count_lines()
|
||||
sess.source_map().count_lines()
|
||||
);
|
||||
println!("Pre-expansion node count: {}", count_nodes(&krate));
|
||||
}
|
||||
|
@ -1462,7 +1462,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[Pa
|
|||
let result = (|| -> io::Result<()> {
|
||||
// Build a list of files used to compile the output and
|
||||
// write Makefile-compatible dependency rules
|
||||
let files: Vec<String> = sess.codemap()
|
||||
let files: Vec<String> = sess.source_map()
|
||||
.files()
|
||||
.iter()
|
||||
.filter(|fmap| fmap.is_real_file())
|
||||
|
|
|
@ -107,7 +107,7 @@ use std::sync::{Once, ONCE_INIT};
|
|||
use std::thread;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
|
||||
use syntax::source_map::{SourceMap, FileLoader, RealFileLoader};
|
||||
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
|
||||
use syntax::parse::{self, PResult};
|
||||
use syntax_pos::{DUMMY_SP, MultiSpan, FileName};
|
||||
|
@ -522,9 +522,9 @@ 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 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 {
|
||||
|
|
|
@ -915,8 +915,8 @@ pub fn fold_crate(sess: &Session, krate: ast::Crate, ppm: PpMode) -> ast::Crate
|
|||
|
||||
fn get_source(input: &Input, sess: &Session) -> (Vec<u8>, FileName) {
|
||||
let src_name = driver::source_name(input);
|
||||
let src = sess.codemap()
|
||||
.get_filemap(&src_name)
|
||||
let src = sess.source_map()
|
||||
.get_source_file(&src_name)
|
||||
.unwrap()
|
||||
.src
|
||||
.as_ref()
|
||||
|
@ -954,7 +954,7 @@ pub fn print_after_parsing(sess: &Session,
|
|||
s.call_with_pp_support(sess, None, move |annotation| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust::print_crate(sess.codemap(),
|
||||
pprust::print_crate(sess.source_map(),
|
||||
&sess.parse_sess,
|
||||
krate,
|
||||
src_name,
|
||||
|
@ -1011,7 +1011,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
|||
s.call_with_pp_support(sess, Some(hir_map), move |annotation| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust::print_crate(sess.codemap(),
|
||||
pprust::print_crate(sess.source_map(),
|
||||
&sess.parse_sess,
|
||||
krate,
|
||||
src_name,
|
||||
|
@ -1035,7 +1035,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
|||
move |annotation, krate| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust_hir::print_crate(sess.codemap(),
|
||||
pprust_hir::print_crate(sess.source_map(),
|
||||
&sess.parse_sess,
|
||||
krate,
|
||||
src_name,
|
||||
|
@ -1076,7 +1076,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
|||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
let hir_map = annotation.hir_map().expect("-Z unpretty missing HIR map");
|
||||
let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(),
|
||||
let mut pp_state = pprust_hir::State::new_from_input(sess.source_map(),
|
||||
&sess.parse_sess,
|
||||
src_name,
|
||||
&mut rdr,
|
||||
|
|
|
@ -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::source_map::{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 {
|
||||
|
@ -162,7 +162,7 @@ fn test_env_with_pool<F>(
|
|||
&arenas,
|
||||
resolutions,
|
||||
hir_map,
|
||||
OnDiskCache::new_empty(sess.codemap()),
|
||||
OnDiskCache::new_empty(sess.source_map()),
|
||||
"test_crate",
|
||||
tx,
|
||||
&outputs,
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
use self::Destination::*;
|
||||
|
||||
use syntax_pos::{FileMap, Span, MultiSpan};
|
||||
use syntax_pos::{SourceFile, 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,21 +120,21 @@ impl ColorConfig {
|
|||
|
||||
pub struct EmitterWriter {
|
||||
dst: Destination,
|
||||
cm: Option<Lrc<CodeMapperDyn>>,
|
||||
cm: Option<Lrc<SourceMapperDyn>>,
|
||||
short_message: bool,
|
||||
teach: bool,
|
||||
ui_testing: bool,
|
||||
}
|
||||
|
||||
struct FileWithAnnotatedLines {
|
||||
file: Lrc<FileMap>,
|
||||
file: Lrc<SourceFile>,
|
||||
lines: Vec<Line>,
|
||||
multiline_depth: usize,
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -177,7 +177,7 @@ impl EmitterWriter {
|
|||
|
||||
fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> {
|
||||
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
|
||||
file: Lrc<FileMap>,
|
||||
file: Lrc<SourceFile>,
|
||||
line_index: usize,
|
||||
ann: Annotation) {
|
||||
|
||||
|
@ -307,7 +307,7 @@ impl EmitterWriter {
|
|||
|
||||
fn render_source_line(&self,
|
||||
buffer: &mut StyledBuffer,
|
||||
file: Lrc<FileMap>,
|
||||
file: Lrc<SourceFile>,
|
||||
line: &Line,
|
||||
width_offset: usize,
|
||||
code_offset: usize) -> Vec<(usize, Style)> {
|
||||
|
@ -1021,7 +1021,7 @@ impl EmitterWriter {
|
|||
// Print out the annotate source lines that correspond with the error
|
||||
for annotated_file in annotated_files {
|
||||
// we can't annotate anything if the source is unavailable.
|
||||
if !cm.ensure_filemap_source_present(annotated_file.file.clone()) {
|
||||
if !cm.ensure_source_file_source_present(annotated_file.file.clone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,14 @@ pub mod registry;
|
|||
mod styled_buffer;
|
||||
mod lock;
|
||||
|
||||
use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION};
|
||||
use syntax_pos::{BytePos,
|
||||
Loc,
|
||||
FileLinesResult,
|
||||
SourceFile,
|
||||
FileName,
|
||||
MultiSpan,
|
||||
Span,
|
||||
NO_EXPANSION};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub enum Applicability {
|
||||
|
@ -111,22 +118,22 @@ 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;
|
||||
fn span_to_filename(&self, sp: Span) -> FileName;
|
||||
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
|
||||
fn call_span_if_macro(&self, sp: Span) -> Span;
|
||||
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool;
|
||||
fn ensure_source_file_source_present(&self, file_map: Lrc<SourceFile>) -> bool;
|
||||
fn doctest_offset_line(&self, line: usize) -> usize;
|
||||
}
|
||||
|
||||
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 +328,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 +341,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));
|
||||
|
|
|
@ -207,11 +207,11 @@ pub fn load_dep_graph(sess: &Session) ->
|
|||
pub fn load_query_result_cache<'sess>(sess: &'sess Session) -> OnDiskCache<'sess> {
|
||||
if sess.opts.incremental.is_none() ||
|
||||
!sess.opts.debugging_opts.incremental_queries {
|
||||
return OnDiskCache::new_empty(sess.codemap());
|
||||
return OnDiskCache::new_empty(sess.source_map());
|
||||
}
|
||||
|
||||
match load_data(sess.opts.debugging_opts.incremental_info, &query_cache_path(sess)) {
|
||||
LoadResult::Ok{ data: (bytes, start_pos) } => OnDiskCache::new(sess, bytes, start_pos),
|
||||
_ => OnDiskCache::new_empty(sess.codemap())
|
||||
_ => OnDiskCache::new_empty(sess.source_map())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ use rustc::util::nodemap::FxHashSet;
|
|||
use syntax::tokenstream::{TokenTree, TokenStream};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::edition::Edition;
|
||||
use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
|
||||
use syntax_pos::{BytePos, Span, SyntaxContext};
|
||||
|
@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue {
|
|||
if let ast::LitKind::Bool(true) = lit.node {
|
||||
if lit.span.ctxt() == SyntaxContext::empty() {
|
||||
let msg = "denote infinite loops with `loop { ... }`";
|
||||
let condition_span = cx.tcx.sess.codemap().def_span(e.span);
|
||||
let condition_span = cx.tcx.sess.source_map().def_span(e.span);
|
||||
let mut err = cx.struct_span_lint(WHILE_TRUE, condition_span, msg);
|
||||
err.span_suggestion_short_with_applicability(
|
||||
condition_span,
|
||||
|
@ -195,7 +195,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
|
|||
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
|
||||
fieldpat.span,
|
||||
&format!("the `{}:` in this pattern is redundant", ident));
|
||||
let subspan = cx.tcx.sess.codemap().span_through_char(fieldpat.span, ':');
|
||||
let subspan = cx.tcx.sess.source_map().span_through_char(fieldpat.span,
|
||||
':');
|
||||
err.span_suggestion_short_with_applicability(
|
||||
subspan,
|
||||
"remove this",
|
||||
|
@ -367,7 +368,7 @@ impl MissingDoc {
|
|||
let has_doc = attrs.iter().any(|a| has_doc(a));
|
||||
if !has_doc {
|
||||
cx.span_lint(MISSING_DOCS,
|
||||
cx.tcx.sess.codemap().def_span(sp),
|
||||
cx.tcx.sess.source_map().def_span(sp),
|
||||
&format!("missing documentation for {}", desc));
|
||||
}
|
||||
}
|
||||
|
@ -651,7 +652,7 @@ impl EarlyLintPass for AnonymousParameters {
|
|||
if ident.name == keywords::Invalid.name() {
|
||||
let ty_snip = cx
|
||||
.sess
|
||||
.codemap()
|
||||
.source_map()
|
||||
.span_to_snippet(arg.ty.span);
|
||||
|
||||
let (ty_snip, appl) = if let Ok(snip) = ty_snip {
|
||||
|
@ -958,7 +959,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
|||
// no break */ }`) shouldn't be linted unless it actually
|
||||
// recurs.
|
||||
if !reached_exit_without_self_call && !self_call_spans.is_empty() {
|
||||
let sp = cx.tcx.sess.codemap().def_span(sp);
|
||||
let sp = cx.tcx.sess.source_map().def_span(sp);
|
||||
let mut db = cx.struct_span_lint(UNCONDITIONAL_RECURSION,
|
||||
sp,
|
||||
"function cannot return without recurring");
|
||||
|
@ -1278,7 +1279,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
|
|||
let mut err = cx.struct_span_lint(NO_MANGLE_CONST_ITEMS, it.span, msg);
|
||||
|
||||
// account for "pub const" (#45562)
|
||||
let start = cx.tcx.sess.codemap().span_to_snippet(it.span)
|
||||
let start = cx.tcx.sess.source_map().span_to_snippet(it.span)
|
||||
.map(|snippet| snippet.find("const").unwrap_or(0))
|
||||
.unwrap_or(0) as u32;
|
||||
// `const` is 5 chars
|
||||
|
@ -1440,7 +1441,7 @@ impl UnreachablePub {
|
|||
if span.ctxt().outer().expn_info().is_some() {
|
||||
applicability = Applicability::MaybeIncorrect;
|
||||
}
|
||||
let def_span = cx.tcx.sess.codemap().def_span(span);
|
||||
let def_span = cx.tcx.sess.source_map().def_span(span);
|
||||
let mut err = cx.struct_span_lint(UNREACHABLE_PUB, def_span,
|
||||
&format!("unreachable `pub` {}", what));
|
||||
let replacement = if cx.tcx.features().crate_visibility_modifier {
|
||||
|
|
|
@ -25,7 +25,7 @@ use syntax::{ast, attr};
|
|||
use syntax::errors::Applicability;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax_pos::Span;
|
||||
use syntax::codemap;
|
||||
use syntax::source_map;
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
|||
}
|
||||
|
||||
fn rev_binop(binop: hir::BinOp) -> hir::BinOp {
|
||||
codemap::respan(binop.span,
|
||||
source_map::respan(binop.span,
|
||||
match binop.node {
|
||||
hir::BinOpKind::Lt => hir::BinOpKind::Gt,
|
||||
hir::BinOpKind::Le => hir::BinOpKind::Ge,
|
||||
|
@ -300,7 +300,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
|||
}
|
||||
|
||||
fn get_bin_hex_repr(cx: &LateContext, lit: &ast::Lit) -> Option<String> {
|
||||
let src = cx.sess().codemap().span_to_snippet(lit.span).ok()?;
|
||||
let src = cx.sess().source_map().span_to_snippet(lit.span).ok()?;
|
||||
let firstch = src.chars().next()?;
|
||||
|
||||
if firstch == '0' {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -41,15 +41,15 @@ pub use rustc_data_structures::sync::MetadataRef;
|
|||
|
||||
pub struct MetadataBlob(pub MetadataRef);
|
||||
|
||||
/// Holds information about a syntax_pos::FileMap imported from another crate.
|
||||
/// See `imported_filemaps()` for more information.
|
||||
pub struct ImportedFileMap {
|
||||
/// This FileMap's byte-offset within the codemap of its original crate
|
||||
/// 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 source_map of its original crate
|
||||
pub original_start_pos: syntax_pos::BytePos,
|
||||
/// The end of this FileMap 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 FileMap's representation within the local codemap
|
||||
pub translated_filemap: Lrc<syntax_pos::FileMap>,
|
||||
/// The imported SourceFile's representation within the local source_map
|
||||
pub translated_source_file: Lrc<syntax_pos::SourceFile>,
|
||||
}
|
||||
|
||||
pub struct CrateMetadata {
|
||||
|
@ -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<ImportedFileMap>>,
|
||||
pub source_map_import_info: RwLock<Vec<ImportedSourceFile>>,
|
||||
|
||||
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
|
||||
pub alloc_decoding_state: AllocDecodingState,
|
||||
|
|
|
@ -38,9 +38,9 @@ use std::sync::Arc;
|
|||
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap;
|
||||
use syntax::source_map;
|
||||
use syntax::edition::Edition;
|
||||
use syntax::parse::filemap_to_stream;
|
||||
use syntax::parse::source_file_to_stream;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{Span, NO_EXPANSION, FileName};
|
||||
use rustc_data_structures::indexed_set::IdxSetBuf;
|
||||
|
@ -463,9 +463,9 @@ impl cstore::CStore {
|
|||
let (name, def) = data.get_macro(id.index);
|
||||
let source_name = FileName::Macros(name.to_string());
|
||||
|
||||
let filemap = sess.parse_sess.codemap().new_filemap(source_name, def.body);
|
||||
let local_span = Span::new(filemap.start_pos, filemap.end_pos, NO_EXPANSION);
|
||||
let body = filemap_to_stream(&sess.parse_sess, filemap, None);
|
||||
let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
|
||||
let local_span = Span::new(source_file.start_pos, source_file.end_pos, NO_EXPANSION);
|
||||
let body = source_file_to_stream(&sess.parse_sess, source_file, None);
|
||||
|
||||
// Mark the attrs as used
|
||||
let attrs = data.get_item_attrs(id.index, sess);
|
||||
|
@ -487,7 +487,7 @@ impl cstore::CStore {
|
|||
tokens: body.into(),
|
||||
legacy: def.legacy,
|
||||
}),
|
||||
vis: codemap::respan(local_span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||
vis: source_map::respan(local_span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||
tokens: None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ use std::u32;
|
|||
use rustc_serialize::{Decodable, Decoder, SpecializedDecoder, opaque};
|
||||
use syntax::attr;
|
||||
use syntax::ast::{self, Ident};
|
||||
use syntax::codemap;
|
||||
use syntax::source_map;
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::ext::base::MacroKind;
|
||||
use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION};
|
||||
|
@ -50,8 +50,8 @@ pub struct DecodeContext<'a, 'tcx: 'a> {
|
|||
sess: Option<&'a Session>,
|
||||
tcx: Option<TyCtxt<'a, 'tcx, 'tcx>>,
|
||||
|
||||
// Cache the last used filemap for translating spans as an optimization.
|
||||
last_filemap_index: usize,
|
||||
// Cache the last used source_file for translating spans as an optimization.
|
||||
last_source_file_index: usize,
|
||||
|
||||
lazy_state: LazyState,
|
||||
|
||||
|
@ -73,7 +73,7 @@ pub trait Metadata<'a, 'tcx>: Copy {
|
|||
cdata: self.cdata(),
|
||||
sess: self.sess().or(tcx.map(|tcx| tcx.sess)),
|
||||
tcx,
|
||||
last_filemap_index: 0,
|
||||
last_source_file_index: 0,
|
||||
lazy_state: LazyState::NoNode,
|
||||
alloc_decoding_session: self.cdata().map(|cdata| {
|
||||
cdata.alloc_decoding_state.new_decoding_session()
|
||||
|
@ -314,43 +314,45 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
|
|||
bug!("Cannot decode Span without Session.")
|
||||
};
|
||||
|
||||
let imported_filemaps = self.cdata().imported_filemaps(&sess.codemap());
|
||||
let filemap = {
|
||||
let imported_source_files = self.cdata().imported_source_files(&sess.source_map());
|
||||
let source_file = {
|
||||
// Optimize for the case that most spans within a translated item
|
||||
// originate from the same filemap.
|
||||
let last_filemap = &imported_filemaps[self.last_filemap_index];
|
||||
// originate from the same source_file.
|
||||
let last_source_file = &imported_source_files[self.last_source_file_index];
|
||||
|
||||
if lo >= last_filemap.original_start_pos &&
|
||||
lo <= last_filemap.original_end_pos {
|
||||
last_filemap
|
||||
if lo >= last_source_file.original_start_pos &&
|
||||
lo <= last_source_file.original_end_pos {
|
||||
last_source_file
|
||||
} else {
|
||||
let mut a = 0;
|
||||
let mut b = imported_filemaps.len();
|
||||
let mut b = imported_source_files.len();
|
||||
|
||||
while b - a > 1 {
|
||||
let m = (a + b) / 2;
|
||||
if imported_filemaps[m].original_start_pos > lo {
|
||||
if imported_source_files[m].original_start_pos > lo {
|
||||
b = m;
|
||||
} else {
|
||||
a = m;
|
||||
}
|
||||
}
|
||||
|
||||
self.last_filemap_index = a;
|
||||
&imported_filemaps[a]
|
||||
self.last_source_file_index = a;
|
||||
&imported_source_files[a]
|
||||
}
|
||||
};
|
||||
|
||||
// Make sure our binary search above is correct.
|
||||
debug_assert!(lo >= filemap.original_start_pos &&
|
||||
lo <= filemap.original_end_pos);
|
||||
debug_assert!(lo >= source_file.original_start_pos &&
|
||||
lo <= source_file.original_end_pos);
|
||||
|
||||
// Make sure we correctly filtered out invalid spans during encoding
|
||||
debug_assert!(hi >= filemap.original_start_pos &&
|
||||
hi <= filemap.original_end_pos);
|
||||
debug_assert!(hi >= source_file.original_start_pos &&
|
||||
hi <= source_file.original_end_pos);
|
||||
|
||||
let lo = (lo + filemap.translated_filemap.start_pos) - filemap.original_start_pos;
|
||||
let hi = (hi + filemap.translated_filemap.start_pos) - filemap.original_start_pos;
|
||||
let lo = (lo + source_file.translated_source_file.start_pos)
|
||||
- source_file.original_start_pos;
|
||||
let hi = (hi + source_file.translated_source_file.start_pos)
|
||||
- source_file.original_start_pos;
|
||||
|
||||
Ok(Span::new(lo, hi, NO_EXPANSION))
|
||||
}
|
||||
|
@ -1094,52 +1096,52 @@ 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 FileMap in the external codemap an 'inline' copy is created in the
|
||||
/// local codemap. The correspondence relation between external and local
|
||||
/// FileMaps is recorded in the `ImportedFileMap` objects returned from this
|
||||
/// 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 FileMaps already
|
||||
/// existing in the local codemap. For example, even if the FileMap of some
|
||||
/// The import algorithm in the function below will reuse SourceFiles already
|
||||
/// 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 FileMap object for the corresponding file in the local codemap.
|
||||
/// one SourceFile object for the corresponding file in the local source_map.
|
||||
///
|
||||
/// Note that imported FileMaps do not actually contain the source code of the
|
||||
/// 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_filemaps(&'a self,
|
||||
local_codemap: &codemap::CodeMap)
|
||||
-> ReadGuard<'a, Vec<cstore::ImportedFileMap>> {
|
||||
pub fn imported_source_files(&'a self,
|
||||
local_source_map: &source_map::SourceMap)
|
||||
-> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> {
|
||||
{
|
||||
let filemaps = self.codemap_import_info.borrow();
|
||||
if !filemaps.is_empty() {
|
||||
return filemaps;
|
||||
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_filemaps = external_codemap.map(|filemap_to_import| {
|
||||
// We can't reuse an existing FileMap, so allocate a new one
|
||||
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::FileMap { name,
|
||||
let syntax_pos::SourceFile { name,
|
||||
name_was_remapped,
|
||||
src_hash,
|
||||
start_pos,
|
||||
|
@ -1148,15 +1150,15 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
mut multibyte_chars,
|
||||
mut non_narrow_chars,
|
||||
name_hash,
|
||||
.. } = filemap_to_import;
|
||||
.. } = source_file_to_import;
|
||||
|
||||
let source_length = (end_pos - start_pos).to_usize();
|
||||
|
||||
// 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_source_file()` will then translate those
|
||||
// coordinates to their new global frame of reference when the
|
||||
// offset of the FileMap is known.
|
||||
// offset of the SourceFile is known.
|
||||
for pos in &mut lines {
|
||||
*pos = *pos - start_pos;
|
||||
}
|
||||
|
@ -1167,7 +1169,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
*swc = *swc - start_pos;
|
||||
}
|
||||
|
||||
let local_version = local_codemap.new_imported_filemap(name,
|
||||
let local_version = local_source_map.new_imported_source_file(name,
|
||||
name_was_remapped,
|
||||
self.cnum.as_u32(),
|
||||
src_hash,
|
||||
|
@ -1176,23 +1178,23 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
lines,
|
||||
multibyte_chars,
|
||||
non_narrow_chars);
|
||||
debug!("CrateMetaData::imported_filemaps alloc \
|
||||
filemap {:?} original (start_pos {:?} end_pos {:?}) \
|
||||
debug!("CrateMetaData::imported_source_files alloc \
|
||||
source_file {:?} original (start_pos {:?} end_pos {:?}) \
|
||||
translated (start_pos {:?} end_pos {:?})",
|
||||
local_version.name, start_pos, end_pos,
|
||||
local_version.start_pos, local_version.end_pos);
|
||||
|
||||
cstore::ImportedFileMap {
|
||||
cstore::ImportedSourceFile {
|
||||
original_start_pos: start_pos,
|
||||
original_end_pos: end_pos,
|
||||
translated_filemap: local_version,
|
||||
translated_source_file: local_version,
|
||||
}
|
||||
}).collect();
|
||||
|
||||
*codemap_import_info = imported_filemaps;
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ use rustc_data_structures::sync::Lrc;
|
|||
use std::u32;
|
||||
use syntax::ast::{self, CRATE_NODE_ID};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::{self, hygiene, FileName, FileMap, Span};
|
||||
use syntax_pos::{self, hygiene, FileName, SourceFile, Span};
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
@ -62,7 +62,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
|
|||
interpret_allocs_inverse: Vec<interpret::AllocId>,
|
||||
|
||||
// This is used to speed up Span encoding.
|
||||
filemap_cache: Lrc<FileMap>,
|
||||
source_file_cache: Lrc<SourceFile>,
|
||||
}
|
||||
|
||||
macro_rules! encoder_methods {
|
||||
|
@ -157,13 +157,13 @@ impl<'a, 'tcx> SpecializedEncoder<Span> for EncodeContext<'a, 'tcx> {
|
|||
// The Span infrastructure should make sure that this invariant holds:
|
||||
debug_assert!(span.lo <= span.hi);
|
||||
|
||||
if !self.filemap_cache.contains(span.lo) {
|
||||
let codemap = self.tcx.sess.codemap();
|
||||
let filemap_index = codemap.lookup_filemap_idx(span.lo);
|
||||
self.filemap_cache = codemap.files()[filemap_index].clone();
|
||||
if !self.source_file_cache.contains(span.lo) {
|
||||
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.filemap_cache.contains(span.hi) {
|
||||
if !self.source_file_cache.contains(span.hi) {
|
||||
// Unfortunately, macro expansion still sometimes generates Spans
|
||||
// that malformed in this way.
|
||||
return TAG_INVALID_SPAN.encode(self)
|
||||
|
@ -337,36 +337,36 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
self.lazy(definitions.def_path_table())
|
||||
}
|
||||
|
||||
fn encode_codemap(&mut self) -> LazySeq<syntax_pos::FileMap> {
|
||||
let codemap = self.tcx.sess.codemap();
|
||||
let all_filemaps = codemap.files();
|
||||
fn encode_source_map(&mut self) -> LazySeq<syntax_pos::SourceFile> {
|
||||
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();
|
||||
|
||||
let adapted = all_filemaps.iter()
|
||||
.filter(|filemap| {
|
||||
// No need to re-export imported filemaps, as any downstream
|
||||
let adapted = all_source_files.iter()
|
||||
.filter(|source_file| {
|
||||
// No need to re-export imported source_files, as any downstream
|
||||
// crate will import them from their original source.
|
||||
!filemap.is_imported()
|
||||
!source_file.is_imported()
|
||||
})
|
||||
.map(|filemap| {
|
||||
// When exporting FileMaps, we expand all paths to absolute
|
||||
.map(|source_file| {
|
||||
// When exporting SourceFiles, we expand all paths to absolute
|
||||
// paths because any relative paths are potentially relative to
|
||||
// a wrong directory.
|
||||
// However, if a path has been modified via
|
||||
// `--remap-path-prefix` we assume the user has already set
|
||||
// things up the way they want and don't touch the path values
|
||||
// anymore.
|
||||
match filemap.name {
|
||||
match source_file.name {
|
||||
FileName::Real(ref name) => {
|
||||
if filemap.name_was_remapped ||
|
||||
if source_file.name_was_remapped ||
|
||||
(name.is_relative() && working_dir_was_remapped) {
|
||||
// This path of this FileMap has been modified by
|
||||
// This path of this SourceFile has been modified by
|
||||
// path-remapping, so we use it verbatim (and avoid cloning
|
||||
// the whole map in the process).
|
||||
filemap.clone()
|
||||
source_file.clone()
|
||||
} else {
|
||||
let mut adapted = (**filemap).clone();
|
||||
let mut adapted = (**source_file).clone();
|
||||
adapted.name = Path::new(&working_dir).join(name).into();
|
||||
adapted.name_hash = {
|
||||
let mut hasher: StableHasher<u128> = StableHasher::new();
|
||||
|
@ -377,7 +377,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
}
|
||||
},
|
||||
// expanded code, not from a file
|
||||
_ => filemap.clone(),
|
||||
_ => source_file.clone(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -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_codemap();
|
||||
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);
|
||||
|
@ -1842,7 +1842,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
lazy_state: LazyState::NoNode,
|
||||
type_shorthands: Default::default(),
|
||||
predicate_shorthands: Default::default(),
|
||||
filemap_cache: tcx.sess.codemap().files()[0].clone(),
|
||||
source_file_cache: tcx.sess.source_map().files()[0].clone(),
|
||||
interpret_allocs: Default::default(),
|
||||
interpret_allocs_inverse: Default::default(),
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc::ty::TyCtxt;
|
|||
use rustc::util::nodemap::FxHashSet;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use syntax::feature_gate::{self, GateIssue};
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
|
|
|
@ -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::FileMap>,
|
||||
pub source_map: LazySeq<syntax_pos::SourceFile>,
|
||||
pub def_path_table: Lazy<hir::map::definitions::DefPathTable>,
|
||||
pub impls: LazySeq<TraitImpls>,
|
||||
pub exported_symbols: EncodedExportedSymbols,
|
||||
|
|
|
@ -316,7 +316,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||
}
|
||||
|
||||
let span = local_decl.source_info.span;
|
||||
let mut_span = tcx.sess.codemap().span_until_non_whitespace(span);
|
||||
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
|
||||
|
||||
let mut err = tcx.struct_span_lint_node(
|
||||
UNUSED_MUT,
|
||||
|
@ -1509,7 +1509,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
debug!("check_for_invalidation_at_exit({:?}): INVALID", place);
|
||||
// FIXME: should be talking about the region lifetime instead
|
||||
// of just a span here.
|
||||
let span = self.tcx.sess.codemap().end_point(span);
|
||||
let span = self.tcx.sess.source_map().end_point(span);
|
||||
self.report_borrowed_value_does_not_live_long_enough(
|
||||
context,
|
||||
borrow,
|
||||
|
|
|
@ -332,7 +332,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
|||
err: &mut DiagnosticBuilder<'a>,
|
||||
span: Span,
|
||||
) {
|
||||
let snippet = self.tcx.sess.codemap().span_to_snippet(span).unwrap();
|
||||
let snippet = self.tcx.sess.source_map().span_to_snippet(span).unwrap();
|
||||
match error {
|
||||
GroupedMoveError::MovesFromPlace {
|
||||
mut binds_to,
|
||||
|
@ -394,7 +394,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
|||
}))
|
||||
) = bind_to.is_user_variable {
|
||||
let pat_snippet = self
|
||||
.tcx.sess.codemap()
|
||||
.tcx.sess.source_map()
|
||||
.span_to_snippet(pat_span)
|
||||
.unwrap();
|
||||
if pat_snippet.starts_with('&') {
|
||||
|
|
|
@ -268,7 +268,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
|||
// a local variable, then just suggest the user remove it.
|
||||
Place::Local(_)
|
||||
if {
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
snippet.starts_with("&mut ")
|
||||
} else {
|
||||
false
|
||||
|
@ -406,7 +406,7 @@ fn suggest_ampmut_self<'cx, 'gcx, 'tcx>(
|
|||
local_decl: &mir::LocalDecl<'tcx>,
|
||||
) -> (Span, String) {
|
||||
let sp = local_decl.source_info.span;
|
||||
(sp, match tcx.sess.codemap().span_to_snippet(sp) {
|
||||
(sp, match tcx.sess.source_map().span_to_snippet(sp) {
|
||||
Ok(snippet) => {
|
||||
let lt_pos = snippet.find('\'');
|
||||
if let Some(lt_pos) = lt_pos {
|
||||
|
@ -444,7 +444,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
|
|||
let locations = mir.find_assignments(local);
|
||||
if locations.len() > 0 {
|
||||
let assignment_rhs_span = mir.source_info(locations[0]).span;
|
||||
if let Ok(src) = tcx.sess.codemap().span_to_snippet(assignment_rhs_span) {
|
||||
if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) {
|
||||
if let (true, Some(ws_pos)) = (
|
||||
src.starts_with("&'"),
|
||||
src.find(|c: char| -> bool { c.is_whitespace() }),
|
||||
|
@ -469,7 +469,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
|
|||
None => local_decl.source_info.span,
|
||||
};
|
||||
|
||||
if let Ok(src) = tcx.sess.codemap().span_to_snippet(highlight_span) {
|
||||
if let Ok(src) = tcx.sess.source_map().span_to_snippet(highlight_span) {
|
||||
if let (true, Some(ws_pos)) = (
|
||||
src.starts_with("&'"),
|
||||
src.find(|c: char| -> bool { c.is_whitespace() }),
|
||||
|
|
|
@ -189,7 +189,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
name: &InternedString,
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
let cm = tcx.sess.codemap();
|
||||
let cm = tcx.sess.source_map();
|
||||
|
||||
let scope = error_region.free_region_binding_scope(tcx);
|
||||
let node = tcx.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
|
||||
|
@ -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.codemap();
|
||||
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,
|
||||
|
@ -593,7 +593,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
= tcx.hir.expect_expr(mir_node_id).node
|
||||
{
|
||||
(
|
||||
tcx.sess.codemap().end_point(span),
|
||||
tcx.sess.source_map().end_point(span),
|
||||
if gen_move.is_some() { " of generator" } else { " of closure" }
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -13,7 +13,7 @@ use borrow_check::nll::ToRegionVid;
|
|||
use rustc::mir::{Local, Mir};
|
||||
use rustc::ty::{RegionVid, TyCtxt};
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use syntax_pos::symbol::Symbol;
|
||||
|
||||
impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
|
|
|
@ -732,7 +732,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
let region_scope_span = region_scope.span(self.hir.tcx(),
|
||||
&self.hir.region_scope_tree);
|
||||
// Attribute scope exit drops to scope's closing brace.
|
||||
let scope_end = self.hir.tcx().sess.codemap().end_point(region_scope_span);
|
||||
let scope_end = self.hir.tcx().sess.source_map().end_point(region_scope_span);
|
||||
|
||||
scope.drops.push(DropData {
|
||||
span: scope_end,
|
||||
|
|
|
@ -10,8 +10,8 @@ use rustc::ty::subst::Subst;
|
|||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
|
||||
use syntax::ast::Mutability;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::source_map::Span;
|
||||
use syntax::source_map::DUMMY_SP;
|
||||
|
||||
use rustc::mir::interpret::{
|
||||
EvalResult, EvalError, EvalErrorKind, GlobalId,
|
||||
|
|
|
@ -18,7 +18,7 @@ use rustc::mir::interpret::{
|
|||
ScalarMaybeUndef,
|
||||
};
|
||||
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax::source_map::{self, Span};
|
||||
use syntax::ast::Mutability;
|
||||
|
||||
use super::{Place, PlaceExtra, Memory,
|
||||
|
@ -91,7 +91,7 @@ pub struct Frame<'mir, 'tcx: 'mir> {
|
|||
pub instance: ty::Instance<'tcx>,
|
||||
|
||||
/// The span of the call site.
|
||||
pub span: codemap::Span,
|
||||
pub span: source_map::Span,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return place and locals
|
||||
|
@ -545,7 +545,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
|||
pub fn push_stack_frame(
|
||||
&mut self,
|
||||
instance: ty::Instance<'tcx>,
|
||||
span: codemap::Span,
|
||||
span: source_map::Span,
|
||||
mir: &'mir mir::Mir<'tcx>,
|
||||
return_place: Place,
|
||||
return_to_block: StackPopCleanup,
|
||||
|
|
|
@ -10,7 +10,7 @@ use super::{EvalContext, Place, ValTy, Memory};
|
|||
use rustc::mir;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::ty::layout::Size;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use syntax::ast::Mutability;
|
||||
|
||||
/// Methods of this trait signifies a point where CTFE evaluation would fail
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc::mir::BasicBlock;
|
||||
use rustc::ty::{self, Ty};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
|
||||
use rustc::mir::interpret::{EvalResult, Value};
|
||||
use interpret::{Machine, ValTy, EvalContext, Place, PlaceExtra};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use rustc::mir;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::ty::layout::{LayoutOf, Size};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use rustc::mir::interpret::{EvalResult, Scalar, Value};
|
||||
|
|
|
@ -26,7 +26,7 @@ use std::fmt::{self, Write};
|
|||
use std::iter;
|
||||
use rustc::mir::mono::Linkage;
|
||||
use syntax_pos::symbol::Symbol;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
pub use rustc::mir::mono::MonoItem;
|
||||
|
||||
/// Describes how a monomorphization will be instantiated in object files.
|
||||
|
|
|
@ -424,12 +424,12 @@ fn is_enclosed(tcx: TyCtxt,
|
|||
}
|
||||
|
||||
fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet<ast::NodeId>, id: ast::NodeId) {
|
||||
let span = tcx.sess.codemap().def_span(tcx.hir.span(id));
|
||||
let span = tcx.sess.source_map().def_span(tcx.hir.span(id));
|
||||
let msg = "unnecessary `unsafe` block";
|
||||
let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg);
|
||||
db.span_label(span, msg);
|
||||
if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) {
|
||||
db.span_label(tcx.sess.codemap().def_span(tcx.hir.span(id)),
|
||||
db.span_label(tcx.sess.source_map().def_span(tcx.hir.span(id)),
|
||||
format!("because it's nested under this `unsafe` {}", kind));
|
||||
}
|
||||
db.emit();
|
||||
|
|
|
@ -24,7 +24,7 @@ use interpret::EvalContext;
|
|||
use interpret::CompileTimeEvaluator;
|
||||
use interpret::{eval_promoted, mk_borrowck_eval_cx, ValTy};
|
||||
use transform::{MirPass, MirSource};
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::source_map::{Span, DUMMY_SP};
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
use rustc::ty::ParamEnv;
|
||||
|
|
|
@ -33,7 +33,7 @@ pub fn suggest_ref_mut<'cx, 'gcx, 'tcx>(
|
|||
tcx: ty::TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
binding_span: Span,
|
||||
) -> Option<(String)> {
|
||||
let hi_src = tcx.sess.codemap().span_to_snippet(binding_span).unwrap();
|
||||
let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).unwrap();
|
||||
if hi_src.starts_with("ref")
|
||||
&& hi_src["ref".len()..].starts_with(Pattern_White_Space)
|
||||
{
|
||||
|
|
|
@ -441,7 +441,7 @@ fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String {
|
|||
format!(
|
||||
"scope {} at {}",
|
||||
scope.index(),
|
||||
tcx.sess.codemap().span_to_string(span)
|
||||
tcx.sess.source_map().span_to_string(span)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use rustc::lint;
|
|||
use rustc::session::Session;
|
||||
use syntax::ast::*;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax_pos::Span;
|
||||
|
|
|
@ -175,7 +175,7 @@ pub fn check_crate(resolver: &mut Resolver, krate: &ast::Crate) {
|
|||
let ms = MultiSpan::from_spans(spans.clone());
|
||||
let mut span_snippets = spans.iter()
|
||||
.filter_map(|s| {
|
||||
match visitor.session.codemap().span_to_snippet(*s) {
|
||||
match visitor.session.source_map().span_to_snippet(*s) {
|
||||
Ok(s) => Some(format!("`{}`", s)),
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
@ -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::source_map::SourceMap;
|
||||
use syntax::ext::hygiene::{Mark, Transparency, SyntaxContext};
|
||||
use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy};
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
|
@ -195,7 +195,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
|||
"can't use type parameters from outer function");
|
||||
err.span_label(span, "use of type variable from outer function");
|
||||
|
||||
let cm = resolver.session.codemap();
|
||||
let cm = resolver.session.source_map();
|
||||
match outer_def {
|
||||
Def::SelfTy(_, maybe_impl_defid) => {
|
||||
if let Some(impl_span) = maybe_impl_defid.map_or(None,
|
||||
|
@ -414,8 +414,8 @@ 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 {
|
||||
/// 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);
|
||||
impl_span
|
||||
|
@ -3085,7 +3085,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
// parser issue where a struct literal is being used on an expression
|
||||
// where a brace being opened means a block is being started. Look
|
||||
// ahead for the next text to see if `span` is followed by a `{`.
|
||||
let cm = this.session.codemap();
|
||||
let cm = this.session.source_map();
|
||||
let mut sp = span;
|
||||
loop {
|
||||
sp = cm.next_point(sp);
|
||||
|
@ -3212,7 +3212,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
err: &mut DiagnosticBuilder,
|
||||
base_span: Span) {
|
||||
debug!("type_ascription_suggetion {:?}", base_span);
|
||||
let cm = self.session.codemap();
|
||||
let cm = self.session.source_map();
|
||||
debug!("self.current_type_ascription {:?}", self.current_type_ascription);
|
||||
if let Some(sp) = self.current_type_ascription.last() {
|
||||
let mut sp = *sp;
|
||||
|
@ -4527,7 +4527,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
false => "defined",
|
||||
};
|
||||
|
||||
let (name, span) = (ident.name, self.session.codemap().def_span(new_binding.span));
|
||||
let (name, span) = (ident.name, self.session.source_map().def_span(new_binding.span));
|
||||
|
||||
if let Some(s) = self.name_already_seen.get(&name) {
|
||||
if s == &span {
|
||||
|
@ -4566,7 +4566,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
|
||||
err.span_label(span, format!("`{}` re{} here", name, new_participle));
|
||||
if !old_binding.span.is_dummy() {
|
||||
err.span_label(self.session.codemap().def_span(old_binding.span),
|
||||
err.span_label(self.session.source_map().def_span(old_binding.span),
|
||||
format!("previous {} of the {} `{}` here", old_noun, old_kind, name));
|
||||
}
|
||||
|
||||
|
@ -4578,7 +4578,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
old_binding
|
||||
};
|
||||
|
||||
let cm = self.session.codemap();
|
||||
let cm = self.session.source_map();
|
||||
let rename_msg = "You can use `as` to change the binding name of the import";
|
||||
|
||||
if let (Ok(snippet), false) = (cm.span_to_snippet(binding.span),
|
||||
|
|
|
@ -1205,8 +1205,8 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
|
|||
let enum_span = enum_resolution.borrow()
|
||||
.binding.expect("binding should exist")
|
||||
.span;
|
||||
let enum_def_span = self.session.codemap().def_span(enum_span);
|
||||
let enum_def_snippet = self.session.codemap()
|
||||
let enum_def_span = self.session.source_map().def_span(enum_span);
|
||||
let enum_def_snippet = self.session.source_map()
|
||||
.span_to_snippet(enum_def_span).expect("snippet should exist");
|
||||
// potentially need to strip extant `crate`/`pub(path)` for suggestion
|
||||
let after_vis_index = enum_def_snippet.find("enum")
|
||||
|
|
|
@ -41,7 +41,7 @@ use syntax::print::pprust::{
|
|||
ty_to_string
|
||||
};
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap::{Spanned, DUMMY_SP, respan};
|
||||
use syntax::source_map::{Spanned, DUMMY_SP, respan};
|
||||
use syntax_pos::*;
|
||||
|
||||
use {escape, generated_code, lower_attributes, PathCollector, SaveContext};
|
||||
|
@ -1368,7 +1368,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
|
|||
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(id));
|
||||
|
||||
let cm = self.tcx.sess.codemap();
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let filename = cm.span_to_filename(span);
|
||||
let data_id = ::id_from_node_id(id, &self.save_ctxt);
|
||||
let children = m.items
|
||||
|
|
|
@ -56,14 +56,14 @@ use std::fs::File;
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use syntax::ast::{self, Attribute, NodeId, PatKind};
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::parse::lexer::comments::strip_doc_comment_decoration;
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax::print::pprust::{arg_to_string, ty_to_string};
|
||||
use syntax::codemap::MacroAttribute;
|
||||
use syntax::source_map::MacroAttribute;
|
||||
use syntax_pos::*;
|
||||
|
||||
use json_dumper::JsonDumper;
|
||||
|
@ -95,7 +95,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
fn span_from_span(&self, span: Span) -> SpanData {
|
||||
use rls_span::{Column, Row};
|
||||
|
||||
let cm = self.tcx.sess.codemap();
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let start = cm.lookup_char_pos(span.lo());
|
||||
let end = cm.lookup_char_pos(span.hi());
|
||||
|
||||
|
@ -122,7 +122,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
continue;
|
||||
}
|
||||
};
|
||||
let lo_loc = self.span_utils.sess.codemap().lookup_char_pos(span.lo());
|
||||
let lo_loc = self.span_utils.sess.source_map().lookup_char_pos(span.lo());
|
||||
result.push(ExternalCrateData {
|
||||
// FIXME: change file_name field to PathBuf in rls-data
|
||||
// https://github.com/nrc/rls-data/issues/7
|
||||
|
@ -268,7 +268,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
ast::ItemKind::Mod(ref m) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
|
||||
let cm = self.tcx.sess.codemap();
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let filename = cm.span_to_filename(m.inner);
|
||||
|
||||
let sub_span = self.span_utils
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a> SpanUtils<'a> {
|
|||
}
|
||||
|
||||
pub fn snippet(&self, span: Span) -> String {
|
||||
match self.sess.codemap().span_to_snippet(span) {
|
||||
match self.sess.source_map().span_to_snippet(span) {
|
||||
Ok(s) => s,
|
||||
Err(_) => String::new(),
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ impl<'a> SpanUtils<'a> {
|
|||
}
|
||||
#[cfg(debug_assertions)] {
|
||||
if angle_count != 0 || bracket_count != 0 {
|
||||
let loc = self.sess.codemap().lookup_char_pos(span.lo());
|
||||
let loc = self.sess.source_map().lookup_char_pos(span.lo());
|
||||
span_bug!(
|
||||
span,
|
||||
"Mis-counted brackets when breaking path? Parsing '{}' \
|
||||
|
@ -276,9 +276,9 @@ impl<'a> SpanUtils<'a> {
|
|||
None => return true,
|
||||
};
|
||||
|
||||
//If the span comes from a fake filemap, filter it.
|
||||
//If the span comes from a fake source_file, filter it.
|
||||
if !self.sess
|
||||
.codemap()
|
||||
.source_map()
|
||||
.lookup_char_pos(parent.lo())
|
||||
.file
|
||||
.is_real_file()
|
||||
|
|
|
@ -18,7 +18,7 @@ use rustc::ty::subst::{Subst, Substs};
|
|||
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::source_map::{Span, DUMMY_SP};
|
||||
|
||||
crate fn provide(p: &mut Providers) {
|
||||
*p = Providers {
|
||||
|
|
|
@ -13,7 +13,7 @@ use rustc::traits::{EvaluationResult, Obligation, ObligationCause,
|
|||
use rustc::traits::query::CanonicalPredicateGoal;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{ParamEnvAnd, TyCtxt};
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::source_map::DUMMY_SP;
|
||||
|
||||
crate fn provide(p: &mut Providers) {
|
||||
*p = Providers {
|
||||
|
|
|
@ -21,7 +21,7 @@ use rustc::ty::outlives::Component;
|
|||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::wf;
|
||||
use syntax::ast::DUMMY_NODE_ID;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::source_map::DUMMY_SP;
|
||||
use rustc::traits::FulfillmentContext;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
|
|
@ -22,7 +22,7 @@ use util::nodemap::FxHashMap;
|
|||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::cmp;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::Span;
|
||||
|
||||
|
@ -350,7 +350,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
if let Some(mut err) = err {
|
||||
if is_arg {
|
||||
if let PatKind::Binding(..) = inner.node {
|
||||
if let Ok(snippet) = tcx.sess.codemap()
|
||||
if let Ok(snippet) = tcx.sess.source_map()
|
||||
.span_to_snippet(pat.span)
|
||||
{
|
||||
err.help(&format!("did you mean `{}: &{}`?",
|
||||
|
|
|
@ -221,7 +221,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
|||
format!("cannot cast `{}` as `{}`",
|
||||
fcx.ty_to_string(self.expr_ty),
|
||||
cast_ty));
|
||||
if let Ok(snippet) = fcx.sess().codemap().span_to_snippet(self.expr.span) {
|
||||
if let Ok(snippet) = fcx.sess().source_map().span_to_snippet(self.expr.span) {
|
||||
err.span_help(self.expr.span,
|
||||
&format!("did you mean `*{}`?", snippet));
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
|||
hir::MutImmutable => "",
|
||||
};
|
||||
if self.cast_ty.is_trait() {
|
||||
match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) {
|
||||
match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) {
|
||||
Ok(s) => {
|
||||
err.span_suggestion(self.cast_span,
|
||||
"try casting to a reference instead",
|
||||
|
@ -344,7 +344,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
|||
}
|
||||
}
|
||||
ty::TyAdt(def, ..) if def.is_box() => {
|
||||
match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) {
|
||||
match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) {
|
||||
Ok(s) => {
|
||||
err.span_suggestion(self.cast_span,
|
||||
"try casting to a `Box` instead",
|
||||
|
|
|
@ -24,7 +24,7 @@ use rustc::ty::subst::Substs;
|
|||
use std::cmp;
|
||||
use std::iter;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::source_map::Span;
|
||||
use rustc::hir;
|
||||
|
||||
/// What signature do we *expect* the closure to have from context?
|
||||
|
|
|
@ -40,7 +40,7 @@ pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
debug!("compare_impl_method(impl_trait_ref={:?})",
|
||||
impl_trait_ref);
|
||||
|
||||
let impl_m_span = tcx.sess.codemap().def_span(impl_m_span);
|
||||
let impl_m_span = tcx.sess.source_map().def_span(impl_m_span);
|
||||
|
||||
if let Err(ErrorReported) = compare_self_type(tcx,
|
||||
impl_m,
|
||||
|
@ -319,7 +319,8 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
trait_m.ident);
|
||||
if let TypeError::Mutability = terr {
|
||||
if let Some(trait_err_span) = trait_err_span {
|
||||
if let Ok(trait_err_str) = tcx.sess.codemap().span_to_snippet(trait_err_span) {
|
||||
if let Ok(trait_err_str) = tcx.sess.source_map().
|
||||
span_to_snippet(trait_err_span) {
|
||||
diag.span_suggestion(
|
||||
impl_err_span,
|
||||
"consider change the type to match the mutability in trait",
|
||||
|
@ -386,7 +387,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// are zero. Since I don't quite know how to phrase things at
|
||||
// the moment, give a kind of vague error message.
|
||||
if trait_params != impl_params {
|
||||
let def_span = tcx.sess.codemap().def_span(span);
|
||||
let def_span = tcx.sess.source_map().def_span(span);
|
||||
let span = tcx.hir.get_generics_span(impl_m.def_id).unwrap_or(def_span);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
|
@ -397,7 +398,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
);
|
||||
err.span_label(span, "lifetimes do not match method in trait");
|
||||
if let Some(sp) = tcx.hir.span_if_local(trait_m.def_id) {
|
||||
let def_sp = tcx.sess.codemap().def_span(sp);
|
||||
let def_sp = tcx.sess.source_map().def_span(sp);
|
||||
let sp = tcx.hir.get_generics_span(trait_m.def_id).unwrap_or(def_sp);
|
||||
err.span_label(sp, "lifetimes in impl do not match this method in trait");
|
||||
}
|
||||
|
@ -770,7 +771,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// as another generic argument
|
||||
let new_name = tcx
|
||||
.sess
|
||||
.codemap()
|
||||
.source_map()
|
||||
.span_to_snippet(trait_span)
|
||||
.ok()?;
|
||||
let trait_m = tcx.hir.as_local_node_id(trait_m.def_id)?;
|
||||
|
@ -783,7 +784,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// and the opening paren of the argument list
|
||||
let new_generics_span = tcx
|
||||
.sess
|
||||
.codemap()
|
||||
.source_map()
|
||||
.generate_fn_name_span(impl_span)?
|
||||
.shrink_to_hi();
|
||||
// in case there are generics, just replace them
|
||||
|
@ -794,7 +795,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// replace with the generics from the trait
|
||||
let new_generics = tcx
|
||||
.sess
|
||||
.codemap()
|
||||
.source_map()
|
||||
.span_to_snippet(trait_m.generics.span)
|
||||
.ok()?;
|
||||
|
||||
|
@ -865,7 +866,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
let bounds = bounds.first()?.span().to(bounds.last()?.span());
|
||||
let bounds = tcx
|
||||
.sess
|
||||
.codemap()
|
||||
.source_map()
|
||||
.span_to_snippet(bounds)
|
||||
.ok()?;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
checked_ty: Ty<'tcx>,
|
||||
expected: Ty<'tcx>)
|
||||
-> Option<(Span, &'static str, String)> {
|
||||
let cm = self.sess().codemap();
|
||||
let cm = self.sess().source_map();
|
||||
// Use the callsite's span if this is a macro call. #41858
|
||||
let sp = cm.call_span_if_macro(expr.span);
|
||||
if !cm.span_to_filename(sp).is_real() {
|
||||
|
@ -405,7 +405,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
let needs_paren = expr.precedence().order() < (PREC_POSTFIX as i8);
|
||||
|
||||
if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
|
||||
if let Ok(src) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
|
||||
let msg = format!("you can cast an `{}` to `{}`", checked_ty, expected_ty);
|
||||
let cast_suggestion = format!("{}{}{} as {}",
|
||||
if needs_paren { "(" } else { "" },
|
||||
|
|
|
@ -132,7 +132,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
if let Some(note_span) = note_span {
|
||||
// We have a span pointing to the method. Show note with snippet.
|
||||
err.span_note(self.tcx.sess.codemap().def_span(note_span), ¬e_str);
|
||||
err.span_note(self.tcx.sess.source_map().def_span(note_span),
|
||||
¬e_str);
|
||||
} else {
|
||||
err.note(¬e_str);
|
||||
}
|
||||
|
@ -141,7 +142,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let item = self
|
||||
.associated_item(trait_did, item_name, Namespace::Value)
|
||||
.unwrap();
|
||||
let item_span = self.tcx.sess.codemap()
|
||||
let item_span = self.tcx.sess.source_map()
|
||||
.def_span(self.tcx.def_span(item.def_id));
|
||||
if sources.len() > 1 {
|
||||
span_note!(err,
|
||||
|
@ -246,7 +247,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
match expr.node {
|
||||
hir::ExprKind::Lit(ref lit) => { // numeric literal
|
||||
let snippet = tcx.sess.codemap().span_to_snippet(lit.span)
|
||||
let snippet = tcx.sess.source_map().span_to_snippet(lit.span)
|
||||
.unwrap_or("<numeric literal>".to_string());
|
||||
|
||||
err.span_suggestion(lit.span,
|
||||
|
@ -261,9 +262,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
if let &hir::QPath::Resolved(_, ref path) = &qpath {
|
||||
if let hir::def::Def::Local(node_id) = path.def {
|
||||
let span = tcx.hir.span(node_id);
|
||||
let snippet = tcx.sess.codemap().span_to_snippet(span)
|
||||
let snippet = tcx.sess.source_map().span_to_snippet(span)
|
||||
.unwrap();
|
||||
let filename = tcx.sess.codemap().span_to_filename(span);
|
||||
let filename = tcx.sess.source_map().span_to_filename(span);
|
||||
|
||||
let parent_node = self.tcx.hir.get(
|
||||
self.tcx.hir.get_parent_node(node_id),
|
||||
|
@ -320,7 +321,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
if let Some(def) = actual.ty_adt_def() {
|
||||
if let Some(full_sp) = tcx.hir.span_if_local(def.did) {
|
||||
let def_sp = tcx.sess.codemap().def_span(full_sp);
|
||||
let def_sp = tcx.sess.source_map().def_span(full_sp);
|
||||
err.span_label(def_sp, format!("{} `{}` not found {}",
|
||||
item_kind,
|
||||
item_name,
|
||||
|
@ -341,7 +342,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let variant = &def.non_enum_variant();
|
||||
if let Some(index) = self.tcx.find_field_index(item_name, variant) {
|
||||
let field = &variant.fields[index];
|
||||
let snippet = tcx.sess.codemap().span_to_snippet(expr.span);
|
||||
let snippet = tcx.sess.source_map().span_to_snippet(expr.span);
|
||||
let expr_string = match snippet {
|
||||
Ok(expr_string) => expr_string,
|
||||
_ => "s".into(), // Default to a generic placeholder for the
|
||||
|
@ -387,7 +388,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
if let Some(expr) = rcvr_expr {
|
||||
if let Ok(expr_string) = tcx.sess.codemap().span_to_snippet(expr.span) {
|
||||
if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) {
|
||||
report_function!(expr.span, expr_string);
|
||||
} else if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) =
|
||||
expr.node
|
||||
|
|
|
@ -122,7 +122,7 @@ use std::ops::{self, Deref};
|
|||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::original_sp;
|
||||
use syntax::source_map::original_sp;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax::ptr::P;
|
||||
use syntax::symbol::{Symbol, LocalInternedString, keywords};
|
||||
|
@ -1447,7 +1447,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
impl_id: DefId,
|
||||
impl_trait_ref: ty::TraitRef<'tcx>,
|
||||
impl_item_refs: &[hir::ImplItemRef]) {
|
||||
let impl_span = tcx.sess.codemap().def_span(impl_span);
|
||||
let impl_span = tcx.sess.source_map().def_span(impl_span);
|
||||
|
||||
// If the trait reference itself is erroneous (so the compilation is going
|
||||
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
|
||||
|
@ -2668,11 +2668,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
if arg_count == 1 {" was"} else {"s were"}),
|
||||
DiagnosticId::Error(error_code.to_owned()));
|
||||
|
||||
if let Some(def_s) = def_span.map(|sp| tcx.sess.codemap().def_span(sp)) {
|
||||
if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().def_span(sp)) {
|
||||
err.span_label(def_s, "defined here");
|
||||
}
|
||||
if sugg_unit {
|
||||
let sugg_span = tcx.sess.codemap().end_point(expr_sp);
|
||||
let sugg_span = tcx.sess.source_map().end_point(expr_sp);
|
||||
// remove closing `)` from the span
|
||||
let sugg_span = sugg_span.shrink_to_lo();
|
||||
err.span_suggestion(
|
||||
|
@ -2937,8 +2937,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
(ExpectIfCondition, &hir::ExprKind::Assign(ref lhs, ref rhs)) => {
|
||||
let msg = "try comparing for equality";
|
||||
if let (Ok(left), Ok(right)) = (
|
||||
self.tcx.sess.codemap().span_to_snippet(lhs.span),
|
||||
self.tcx.sess.codemap().span_to_snippet(rhs.span))
|
||||
self.tcx.sess.source_map().span_to_snippet(lhs.span),
|
||||
self.tcx.sess.source_map().span_to_snippet(rhs.span))
|
||||
{
|
||||
err.span_suggestion(expr.span, msg, format!("{} == {}", left, right));
|
||||
} else {
|
||||
|
@ -4232,7 +4232,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
if let hir::ExprKind::Lit(ref lit) = idx.node {
|
||||
if let ast::LitKind::Int(i,
|
||||
ast::LitIntType::Unsuffixed) = lit.node {
|
||||
let snip = tcx.sess.codemap().span_to_snippet(base.span);
|
||||
let snip = tcx.sess.source_map().span_to_snippet(base.span);
|
||||
if let Ok(snip) = snip {
|
||||
err.span_suggestion(expr.span,
|
||||
"to access tuple elements, use",
|
||||
|
@ -4629,7 +4629,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
err.span_suggestion(sp, msg, suggestion);
|
||||
} else if !self.check_for_cast(err, expr, found, expected) {
|
||||
let methods = self.get_conversion_methods(expr.span, expected, found);
|
||||
if let Ok(expr_text) = self.sess().codemap().span_to_snippet(expr.span) {
|
||||
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
|
||||
let suggestions = iter::repeat(expr_text).zip(methods.iter())
|
||||
.filter_map(|(receiver, method)| {
|
||||
let method_call = format!(".{}()", method.ident);
|
||||
|
@ -4673,7 +4673,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
hir::ExprKind::Loop(..) |
|
||||
hir::ExprKind::Match(..) |
|
||||
hir::ExprKind::Block(..) => {
|
||||
let sp = self.tcx.sess.codemap().next_point(cause_span);
|
||||
let sp = self.tcx.sess.source_map().next_point(cause_span);
|
||||
err.span_suggestion(sp,
|
||||
"try adding a semicolon",
|
||||
";".to_string());
|
||||
|
|
|
@ -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.codemap();
|
||||
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.codemap();
|
||||
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) => {
|
||||
|
|
|
@ -71,7 +71,7 @@ impl<'a, 'tcx> CheckVisitor<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
let msg = if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
|
||||
let msg = if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
format!("unused import: `{}`", snippet)
|
||||
} else {
|
||||
"unused import".to_string()
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue