Skip to content

Commit f332b16

Browse files
committed
mv codemap() source_map()
1 parent 96ac200 commit f332b16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+209
-209
lines changed

src/libproc_macro/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ pub mod __internal {
11861186
use super::{TokenStream, LexError, Span};
11871187

11881188
pub fn lookup_char_pos(pos: BytePos) -> Loc {
1189-
with_sess(|sess, _| sess.codemap().lookup_char_pos(pos))
1189+
with_sess(|sess, _| sess.source_map().lookup_char_pos(pos))
11901190
}
11911191

11921192
pub fn new_token_stream(item: P<ast::Item>) -> TokenStream {

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3621,7 +3621,7 @@ impl<'a> LoweringContext<'a> {
36213621
let tail = block.expr.take().map_or_else(
36223622
|| {
36233623
let LoweredNodeId { node_id, hir_id } = this.next_id();
3624-
let span = this.sess.codemap().end_point(unstable_span);
3624+
let span = this.sess.source_map().end_point(unstable_span);
36253625
hir::Expr {
36263626
id: node_id,
36273627
span,

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ pub fn map_crate<'hir>(sess: &::session::Session,
12021202
let cmdline_args = sess.opts.dep_tracking_hash();
12031203
collector.finalize_and_compute_crate_hash(crate_disambiguator,
12041204
cstore,
1205-
sess.codemap(),
1205+
sess.source_map(),
12061206
cmdline_args)
12071207
};
12081208

src/librustc/ich/hcx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> StableHashingContext<'a> {
101101
definitions,
102102
cstore,
103103
caching_codemap: None,
104-
raw_codemap: sess.codemap(),
104+
raw_codemap: sess.source_map(),
105105
hash_spans: hash_spans_initial,
106106
hash_bodies: true,
107107
node_id_hashing_mode: NodeIdHashingMode::HashDefPath,
@@ -169,7 +169,7 @@ impl<'a> StableHashingContext<'a> {
169169
}
170170

171171
#[inline]
172-
pub fn codemap(&mut self) -> &mut CachingCodemapView<'a> {
172+
pub fn source_map(&mut self) -> &mut CachingCodemapView<'a> {
173173
match self.caching_codemap {
174174
Some(ref mut cm) => {
175175
cm
@@ -340,7 +340,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
340340
return std_hash::Hash::hash(&TAG_INVALID_SPAN, hasher);
341341
}
342342

343-
let (file_lo, line_lo, col_lo) = match hcx.codemap()
343+
let (file_lo, line_lo, col_lo) = match hcx.source_map()
344344
.byte_pos_to_line_and_col(span.lo) {
345345
Some(pos) => pos,
346346
None => {

src/librustc/infer/error_reporting/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
189189
self,
190190
region: ty::Region<'tcx>,
191191
) -> (String, Option<Span>) {
192-
let cm = self.sess.codemap();
192+
let cm = self.sess.source_map();
193193

194194
let scope = region.free_region_binding_scope(self);
195195
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> {
286286
}
287287

288288
fn explain_span(self, heading: &str, span: Span) -> (String, Option<Span>) {
289-
let lo = self.sess.codemap().lookup_char_pos_adj(span.lo());
289+
let lo = self.sess.source_map().lookup_char_pos_adj(span.lo());
290290
(
291291
format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
292292
Some(span),
@@ -502,14 +502,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
502502
ObligationCauseCode::MatchExpressionArm { arm_span, source } => match source {
503503
hir::MatchSource::IfLetDesugar { .. } => {
504504
let msg = "`if let` arm with an incompatible type";
505-
if self.tcx.sess.codemap().is_multiline(arm_span) {
505+
if self.tcx.sess.source_map().is_multiline(arm_span) {
506506
err.span_note(arm_span, msg);
507507
} else {
508508
err.span_label(arm_span, msg);
509509
}
510510
},
511511
hir::MatchSource::TryDesugar => { // Issue #51632
512-
if let Ok(try_snippet) = self.tcx.sess.codemap().span_to_snippet(arm_span) {
512+
if let Ok(try_snippet) = self.tcx.sess.source_map().span_to_snippet(arm_span) {
513513
err.span_suggestion_with_applicability(
514514
arm_span,
515515
"try wrapping with a success variant",
@@ -520,7 +520,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
520520
},
521521
_ => {
522522
let msg = "match arm with an incompatible type";
523-
if self.tcx.sess.codemap().is_multiline(arm_span) {
523+
if self.tcx.sess.source_map().is_multiline(arm_span) {
524524
err.span_note(arm_span, msg);
525525
} else {
526526
err.span_label(arm_span, msg);
@@ -1136,8 +1136,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11361136
let sp = if has_bounds {
11371137
sp.to(self.tcx
11381138
.sess
1139-
.codemap()
1140-
.next_point(self.tcx.sess.codemap().next_point(sp)))
1139+
.source_map()
1140+
.next_point(self.tcx.sess.source_map().next_point(sp)))
11411141
} else {
11421142
sp
11431143
};

src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
6060
}) => name.to_string(),
6161
_ => "'_".to_owned(),
6262
};
63-
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(return_sp) {
63+
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(return_sp) {
6464
err.span_suggestion(
6565
return_sp,
6666
&format!(

src/librustc/lint/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl BuiltinLintDiagnostics {
420420
match self {
421421
BuiltinLintDiagnostics::Normal => (),
422422
BuiltinLintDiagnostics::BareTraitObject(span, is_global) => {
423-
let (sugg, app) = match sess.codemap().span_to_snippet(span) {
423+
let (sugg, app) = match sess.source_map().span_to_snippet(span) {
424424
Ok(ref s) if is_global => (format!("dyn ({})", s),
425425
Applicability::MachineApplicable),
426426
Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable),
@@ -429,7 +429,7 @@ impl BuiltinLintDiagnostics {
429429
db.span_suggestion_with_applicability(span, "use `dyn`", sugg, app);
430430
}
431431
BuiltinLintDiagnostics::AbsPathWithModule(span) => {
432-
let (sugg, app) = match sess.codemap().span_to_snippet(span) {
432+
let (sugg, app) = match sess.source_map().span_to_snippet(span) {
433433
Ok(ref s) => {
434434
// FIXME(Manishearth) ideally the emitting code
435435
// can tell us whether or not this is global
@@ -462,7 +462,7 @@ impl BuiltinLintDiagnostics {
462462
// When possible, prefer a suggestion that replaces the whole
463463
// `Path<T>` expression with `Path<'_, T>`, rather than inserting `'_, `
464464
// at a point (which makes for an ugly/confusing label)
465-
if let Ok(snippet) = sess.codemap().span_to_snippet(path_span) {
465+
if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) {
466466
// But our spans can get out of whack due to macros; if the place we think
467467
// we want to insert `'_` isn't even within the path expression's span, we
468468
// should bail out of making any suggestion rather than panicking on a

src/librustc/lint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
754754
None => return true,
755755
};
756756

757-
match sess.codemap().span_to_snippet(def_site) {
757+
match sess.source_map().span_to_snippet(def_site) {
758758
Ok(code) => !code.starts_with("macro_rules"),
759759
// no snippet = external macro or compiler-builtin expansion
760760
Err(_) => true,

src/librustc/middle/dead.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
551551
hir::ItemKind::Struct(..) |
552552
hir::ItemKind::Union(..) |
553553
hir::ItemKind::Trait(..) |
554-
hir::ItemKind::Impl(..) => self.tcx.sess.codemap().def_span(item.span),
554+
hir::ItemKind::Impl(..) => self.tcx.sess.source_map().def_span(item.span),
555555
_ => item.span,
556556
};
557557
let participle = match item.node {
@@ -612,7 +612,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
612612
}
613613
hir::ImplItemKind::Method(_, body_id) => {
614614
if !self.symbol_is_live(impl_item.id, None) {
615-
let span = self.tcx.sess.codemap().def_span(impl_item.span);
615+
let span = self.tcx.sess.source_map().def_span(impl_item.span);
616616
self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used");
617617
}
618618
self.visit_nested_body(body_id)

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ enum LiveNodeKind {
157157
}
158158

159159
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt) -> String {
160-
let cm = tcx.sess.codemap();
160+
let cm = tcx.sess.source_map();
161161
match lnk {
162162
FreeVarNode(s) => {
163163
format!("Free var node [{}]", cm.span_to_string(s))

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
13141314

13151315
debug!("visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})",
13161316
owner_id,
1317-
self.tcx.sess.codemap().span_to_string(body.value.span),
1317+
self.tcx.sess.source_map().span_to_string(body.value.span),
13181318
body_id,
13191319
self.cx.parent);
13201320

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
24612461
"insert_lifetime: {} resolved to {:?} span={:?}",
24622462
self.tcx.hir.node_to_string(lifetime_ref.id),
24632463
def,
2464-
self.tcx.sess.codemap().span_to_string(lifetime_ref.span)
2464+
self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
24652465
);
24662466
self.map.defs.insert(lifetime_ref.id, def);
24672467

src/librustc/middle/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
685685
};
686686

687687
let msp: MultiSpan = span.into();
688-
let cm = &self.sess.parse_sess.codemap();
688+
let cm = &self.sess.parse_sess.source_map();
689689
let span_key = msp.primary_span().and_then(|sp: Span|
690690
if !sp.is_dummy() {
691691
let file = cm.lookup_char_pos(sp.lo()).file;

src/librustc/session/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ impl Session {
482482
);
483483
}
484484

485-
pub fn codemap<'a>(&'a self) -> &'a source_map::SourceMap {
486-
self.parse_sess.codemap()
485+
pub fn source_map<'a>(&'a self) -> &'a source_map::SourceMap {
486+
self.parse_sess.source_map()
487487
}
488488
pub fn verbose(&self) -> bool {
489489
self.opts.debugging_opts.verbose

src/librustc/traits/error_reporting.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
528528
-> DiagnosticBuilder<'tcx>
529529
{
530530
let msg = "impl has stricter requirements than trait";
531-
let sp = self.tcx.sess.codemap().def_span(error_span);
531+
let sp = self.tcx.sess.source_map().def_span(error_span);
532532

533533
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
534534

535535
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
536-
let span = self.tcx.sess.codemap().def_span(trait_item_span);
536+
let span = self.tcx.sess.source_map().def_span(trait_item_span);
537537
err.span_label(span, format!("definition of `{}` from trait", item_name));
538538
}
539539

@@ -715,7 +715,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
715715

716716
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
717717
let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap();
718-
let closure_span = self.tcx.sess.codemap()
718+
let closure_span = self.tcx.sess.source_map()
719719
.def_span(self.tcx.hir.span_if_local(closure_def_id).unwrap());
720720
let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap();
721721
let mut err = struct_span_err!(
@@ -792,7 +792,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
792792
};
793793
let found_span = found_did.and_then(|did| {
794794
self.tcx.hir.span_if_local(did)
795-
}).map(|sp| self.tcx.sess.codemap().def_span(sp)); // the sp could be an fn def
795+
}).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def
796796

797797
let found = match found_trait_ref.skip_binder().substs.type_at(1).sty {
798798
ty::TyTuple(ref tys) => tys.iter()
@@ -867,7 +867,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
867867
if let Some(hir::map::NodeLocal(ref local)) = self.tcx.hir.find(parent_node) {
868868
if let Some(ref expr) = local.init {
869869
if let hir::ExprKind::Index(_, _) = expr.node {
870-
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
870+
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
871871
err.span_suggestion_with_applicability(
872872
expr.span,
873873
"consider borrowing here",
@@ -890,7 +890,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
890890
let trait_ref = trait_ref.skip_binder();
891891
let span = obligation.cause.span;
892892

893-
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
893+
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
894894
let refs_number = snippet.chars()
895895
.filter(|c| !c.is_whitespace())
896896
.take_while(|c| *c == '&')
@@ -909,7 +909,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
909909
new_trait_ref.to_predicate());
910910

911911
if self.predicate_may_hold(&new_obligation) {
912-
let sp = self.tcx.sess.codemap()
912+
let sp = self.tcx.sess.source_map()
913913
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
914914

915915
let remove_refs = refs_remaining + 1;
@@ -938,7 +938,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
938938
node: hir::ExprKind::Closure(_, ref _decl, id, span, _),
939939
..
940940
}) => {
941-
(self.tcx.sess.codemap().def_span(span), self.tcx.hir.body(id).arguments.iter()
941+
(self.tcx.sess.source_map().def_span(span), self.tcx.hir.body(id).arguments.iter()
942942
.map(|arg| {
943943
if let hir::Pat {
944944
node: hir::PatKind::Tuple(args, _),
@@ -948,13 +948,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
948948
ArgKind::Tuple(
949949
Some(span),
950950
args.iter().map(|pat| {
951-
let snippet = self.tcx.sess.codemap()
951+
let snippet = self.tcx.sess.source_map()
952952
.span_to_snippet(pat.span).unwrap();
953953
(snippet, "_".to_owned())
954954
}).collect::<Vec<_>>(),
955955
)
956956
} else {
957-
let name = self.tcx.sess.codemap()
957+
let name = self.tcx.sess.source_map()
958958
.span_to_snippet(arg.pat.span).unwrap();
959959
ArgKind::Arg(name, "_".to_owned())
960960
}
@@ -976,7 +976,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
976976
node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
977977
..
978978
}) => {
979-
(self.tcx.sess.codemap().def_span(span), decl.inputs.iter()
979+
(self.tcx.sess.source_map().def_span(span), decl.inputs.iter()
980980
.map(|arg| match arg.clone().node {
981981
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
982982
Some(arg.span),
@@ -995,13 +995,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
995995
},
996996
..
997997
}) => {
998-
(self.tcx.sess.codemap().def_span(span),
998+
(self.tcx.sess.source_map().def_span(span),
999999
fields.iter().map(|field| {
10001000
ArgKind::Arg(field.ident.to_string(), "_".to_string())
10011001
}).collect::<Vec<_>>())
10021002
}
10031003
hir::map::NodeStructCtor(ref variant_data) => {
1004-
(self.tcx.sess.codemap().def_span(self.tcx.hir.span(variant_data.id())),
1004+
(self.tcx.sess.source_map().def_span(self.tcx.hir.span(variant_data.id())),
10051005
variant_data.fields()
10061006
.iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned()))
10071007
.collect())
@@ -1192,7 +1192,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11921192
{
11931193
assert!(type_def_id.is_local());
11941194
let span = self.hir.span_if_local(type_def_id).unwrap();
1195-
let span = self.sess.codemap().def_span(span);
1195+
let span = self.sess.source_map().def_span(span);
11961196
let mut err = struct_span_err!(self.sess, span, E0072,
11971197
"recursive type `{}` has infinite size",
11981198
self.item_path_str(type_def_id));
@@ -1210,7 +1210,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12101210
-> DiagnosticBuilder<'tcx>
12111211
{
12121212
let trait_str = self.item_path_str(trait_def_id);
1213-
let span = self.sess.codemap().def_span(span);
1213+
let span = self.sess.source_map().def_span(span);
12141214
let mut err = struct_span_err!(
12151215
self.sess, span, E0038,
12161216
"the trait `{}` cannot be made into an object",
@@ -1438,7 +1438,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
14381438
let item_name = tcx.item_path_str(item_def_id);
14391439
let msg = format!("required by `{}`", item_name);
14401440
if let Some(sp) = tcx.hir.span_if_local(item_def_id) {
1441-
let sp = tcx.sess.codemap().def_span(sp);
1441+
let sp = tcx.sess.source_map().def_span(sp);
14421442
err.span_note(sp, &msg);
14431443
} else {
14441444
err.note(&msg);

src/librustc/traits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'tcx> ObligationCause<'tcx> {
142142
ObligationCauseCode::CompareImplMethodObligation { .. } |
143143
ObligationCauseCode::MainFunctionType |
144144
ObligationCauseCode::StartFunctionType => {
145-
tcx.sess.codemap().def_span(self.span)
145+
tcx.sess.source_map().def_span(self.span)
146146
}
147147
_ => self.span,
148148
}

0 commit comments

Comments
 (0)