Skip to content

Commit 433686d

Browse files
committed
Wrap def_span query to return a SpanId.
1 parent d738c3c commit 433686d

File tree

60 files changed

+225
-186
lines changed

Some content is hidden

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

60 files changed

+225
-186
lines changed

src/librustc_codegen_llvm/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl CodegenCx<'ll, 'tcx> {
260260
debug!("get_static: sym={} item_attr={:?}", sym, self.tcx.item_attrs(def_id));
261261

262262
let attrs = self.tcx.codegen_fn_attrs(def_id);
263-
let span = self.tcx.def_span(def_id);
263+
let span = self.tcx.real_def_span(def_id);
264264
let g = check_and_apply_linkage(&self, &attrs, ty, sym, span);
265265

266266
// Thread-local statics in some other crate need to *always* be linked

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
23132313
// We may want to remove the namespace scope if we're in an extern block (see
23142314
// https://github.com/rust-lang/rust/pull/46457#issuecomment-351750952).
23152315
let var_scope = get_namespace_for_item(cx, def_id);
2316-
let span = tcx.def_span(def_id);
2316+
let span = tcx.real_def_span(def_id);
23172317

23182318
let (file_metadata, line_number) = if !span.is_dummy() {
23192319
let loc = cx.lookup_debug_loc(span.lo());

src/librustc_codegen_ssa/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
4545
use rustc_session::cgu_reuse_tracker::CguReuse;
4646
use rustc_session::config::{self, EntryFnType};
4747
use rustc_session::Session;
48-
use rustc_span::Span;
48+
use rustc_span::SpanId;
4949
use rustc_symbol_mangling::test as symbol_names_test;
5050
use rustc_target::abi::{Abi, Align, LayoutOf, Scalar, VariantIdx};
5151

@@ -414,7 +414,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
414414

415415
fn create_entry_fn<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
416416
cx: &'a Bx::CodegenCx,
417-
sp: Span,
417+
sp: SpanId,
418418
rust_main: Bx::Value,
419419
rust_main_def_id: LocalDefId,
420420
use_start_lang_item: bool,

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14671467
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
14681468
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
14691469
if let Some((kind, def_id)) = TyCategory::from_ty(t) {
1470-
let span = self.tcx.def_span(def_id);
1470+
let span = self.tcx.real_def_span(def_id);
14711471
// Avoid cluttering the output when the "found" and error span overlap:
14721472
//
14731473
// error[E0308]: mismatched types
@@ -1543,7 +1543,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15431543
self.tcx
15441544
.sess
15451545
.source_map()
1546-
.mk_substr_filename(self.tcx.def_span(*def_id)),
1546+
.mk_substr_filename(self.tcx.real_def_span(*def_id)),
15471547
),
15481548
(true, _) => format!(" ({})", ty.sort_string(self.tcx)),
15491549
(false, _) => "".to_string(),

src/librustc_infer/infer/error_reporting/nice_region_error/trait_impl_difference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::infer::{Subtype, ValuePairs};
66
use crate::traits::ObligationCauseCode::CompareImplMethodObligation;
77
use rustc_errors::ErrorReported;
88
use rustc_middle::ty::Ty;
9-
use rustc_span::Span;
9+
use rustc_span::{Span, SpanId};
1010

1111
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
1212
/// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`.
@@ -47,7 +47,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
4747
None
4848
}
4949

50-
fn emit_err(&self, sp: Span, expected: Ty<'tcx>, found: Ty<'tcx>, impl_sp: Span) {
50+
fn emit_err(&self, sp: Span, expected: Ty<'tcx>, found: Ty<'tcx>, impl_sp: SpanId) {
5151
let mut err = self
5252
.tcx()
5353
.sess

src/librustc_infer/infer/lexical_region_resolve/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
664664
.iter()
665665
.map(|&choice_region| var_data.normalize(self.tcx(), choice_region));
666666
if !choice_regions.clone().any(|choice_region| member_region == choice_region) {
667-
let span = self.tcx().def_span(member_constraint.opaque_type_def_id);
667+
let span = self.tcx().real_def_span(member_constraint.opaque_type_def_id);
668668
errors.push(RegionResolutionError::MemberConstraintFailure {
669669
span,
670670
hidden_ty: member_constraint.hidden_ty,

src/librustc_infer/infer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt};
3333
use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid};
3434
use rustc_session::config::BorrowckMode;
3535
use rustc_span::symbol::Symbol;
36-
use rustc_span::Span;
36+
use rustc_span::{Span, SpanId};
3737

3838
use std::cell::{Cell, Ref, RefCell};
3939
use std::collections::BTreeMap;
@@ -1579,7 +1579,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15791579
def_id: DefId,
15801580
substs: SubstsRef<'tcx>,
15811581
promoted: Option<mir::Promoted>,
1582-
span: Option<Span>,
1582+
span: Option<SpanId>,
15831583
) -> ConstEvalResult<'tcx> {
15841584
let mut original_values = OriginalQueryValues::default();
15851585
let canonical = self.canonicalize_query(&(param_env, substs), &mut original_values);

src/librustc_interface/callbacks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ fn track_diagnostic(diagnostic: Diagnostic) -> RealDiagnostic {
3535
let mut diagnostics = diagnostics.lock();
3636
diagnostics.extend(Some(diagnostic.clone()));
3737
}
38-
diagnostic.map_span(|s| match s {
39-
rustc_span::SpanId::Span(s) => s,
40-
rustc_span::SpanId::DefId(d) => icx.tcx.def_span(d),
41-
})
38+
39+
// Ignore dependencies when reifying spans.
40+
let icx = tls::ImplicitCtxt { task_deps: None, ..icx.clone() };
41+
tls::enter_context(&icx, |icx| diagnostic.map_span(|s| icx.tcx.reify_span(s)))
4242
} else {
4343
diagnostic.map_span(|s| match s {
4444
rustc_span::SpanId::Span(s) => s,

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
19771977
if span.is_none() {
19781978
// Point to this field, should be helpful for figuring
19791979
// out where the source of the error is.
1980-
let span = tcx.def_span(field.did);
1980+
let span = tcx.real_def_span(field.did);
19811981
write!(
19821982
&mut msg,
19831983
" (in this {} field)",

src/librustc_macros/src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
496496
force_query::<crate::ty::query::queries::#name<'_>, _>(
497497
$tcx,
498498
key,
499-
DUMMY_SP,
499+
DUMMY_SPID,
500500
*$dep_node
501501
);
502502
return true;

0 commit comments

Comments
 (0)