mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Fix spans
This commit is contained in:
parent
0f7f3f4045
commit
3273ccea4b
@ -376,7 +376,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
fn_args,
|
||||
Some(source_info.span),
|
||||
source_info.span,
|
||||
)
|
||||
.polymorphize(fx.tcx);
|
||||
|
||||
|
@ -4,6 +4,7 @@ use rustc_middle::ty::AssocKind;
|
||||
use rustc_middle::ty::GenericArg;
|
||||
use rustc_session::config::{sigpipe, EntryFnType};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
@ -119,7 +120,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
ParamEnv::reveal_all(),
|
||||
report.def_id,
|
||||
tcx.mk_args(&[GenericArg::from(main_ret_ty)]),
|
||||
None,
|
||||
DUMMY_SP,
|
||||
)
|
||||
.polymorphize(tcx);
|
||||
|
||||
@ -145,7 +146,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
ParamEnv::reveal_all(),
|
||||
start_def_id,
|
||||
tcx.mk_args(&[main_ret_ty.into()]),
|
||||
None,
|
||||
DUMMY_SP,
|
||||
)
|
||||
.polymorphize(tcx);
|
||||
let start_func_id = import_function(tcx, m, start_instance);
|
||||
|
@ -17,7 +17,7 @@ use rustc_middle::ty::layout::{
|
||||
};
|
||||
use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::{source_map::respan, Span};
|
||||
use rustc_span::{source_map::respan, Span, DUMMY_SP};
|
||||
use rustc_target::abi::{
|
||||
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
|
||||
};
|
||||
@ -479,7 +479,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
ty::List::empty(),
|
||||
None,
|
||||
DUMMY_SP,
|
||||
);
|
||||
|
||||
let symbol_name = tcx.symbol_name(instance).name;
|
||||
|
@ -28,7 +28,7 @@ use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
|
||||
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::{call::FnAbi, HasDataLayout, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel};
|
||||
use smallvec::SmallVec;
|
||||
@ -580,7 +580,7 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
ty::List::empty(),
|
||||
None,
|
||||
DUMMY_SP,
|
||||
)),
|
||||
_ => {
|
||||
let name = name.unwrap_or("rust_eh_personality");
|
||||
|
@ -37,7 +37,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
use rustc_session::config::{self, CrateType, EntryFnType, OptLevel, OutputType};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::{Symbol, DUMMY_SP};
|
||||
use rustc_target::abi::FIRST_VARIANT;
|
||||
|
||||
use std::cmp;
|
||||
@ -467,7 +467,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
ty::ParamEnv::reveal_all(),
|
||||
start_def_id,
|
||||
cx.tcx().mk_args(&[main_ret_ty.into()]),
|
||||
None,
|
||||
DUMMY_SP,
|
||||
);
|
||||
let start_fn = cx.get_fn_addr(start_instance);
|
||||
|
||||
|
@ -842,7 +842,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
args,
|
||||
Some(fn_span),
|
||||
fn_span,
|
||||
)
|
||||
.polymorphize(bx.tcx()),
|
||||
),
|
||||
|
@ -253,7 +253,7 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
|
||||
ty::ParamEnv::reveal_all(),
|
||||
const_def_id,
|
||||
instance.args,
|
||||
Some(self.find_closest_untracked_caller_location()),
|
||||
self.cur_span(),
|
||||
);
|
||||
|
||||
return Ok(Some(new_instance));
|
||||
|
@ -888,6 +888,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
self.param_env,
|
||||
def_id,
|
||||
instance.args.rebase_onto(tcx, trait_def_id, concrete_trait_ref.args),
|
||||
self.cur_span(),
|
||||
);
|
||||
assert_eq!(fn_inst, concrete_method);
|
||||
}
|
||||
|
@ -547,8 +547,14 @@ impl<'tcx> Instance<'tcx> {
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
def_id: DefId,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
span: Option<Span>,
|
||||
span: Span,
|
||||
) -> Instance<'tcx> {
|
||||
// We compute the span lazily, to avoid unnecessary query calls.
|
||||
// If `span` is a DUMMY_SP, and the def id is local, then use the
|
||||
// def span of the def id.
|
||||
let span_or_local_def_span =
|
||||
|| if span.is_dummy() && def_id.is_local() { tcx.def_span(def_id) } else { span };
|
||||
|
||||
match ty::Instance::resolve(tcx, param_env, def_id, args) {
|
||||
Ok(Some(instance)) => instance,
|
||||
Ok(None) => {
|
||||
@ -567,7 +573,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
// We don't use `def_span(def_id)` so that diagnostics point
|
||||
// to the crate root during mono instead of to foreign items.
|
||||
// This is arguably better.
|
||||
span: span.unwrap_or(DUMMY_SP),
|
||||
span: span_or_local_def_span(),
|
||||
shrunk,
|
||||
was_written,
|
||||
path,
|
||||
@ -575,14 +581,14 @@ impl<'tcx> Instance<'tcx> {
|
||||
});
|
||||
} else {
|
||||
span_bug!(
|
||||
span.unwrap_or(tcx.def_span(def_id)),
|
||||
span_or_local_def_span(),
|
||||
"failed to resolve instance for {}",
|
||||
tcx.def_path_str_with_args(def_id, args)
|
||||
)
|
||||
}
|
||||
}
|
||||
instance => span_bug!(
|
||||
span.unwrap_or(tcx.def_span(def_id)),
|
||||
span_or_local_def_span(),
|
||||
"failed to resolve instance for {}: {instance:#?}",
|
||||
tcx.def_path_str_with_args(def_id, args)
|
||||
),
|
||||
@ -642,6 +648,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
def_id: DefId,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
span: Span,
|
||||
) -> Instance<'tcx> {
|
||||
debug!("resolve_for_vtable(def_id={:?}, args={:?})", def_id, args);
|
||||
let fn_sig = tcx.fn_sig(def_id).instantiate_identity();
|
||||
@ -654,7 +661,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
return Instance { def: InstanceKind::VTableShim(def_id), args };
|
||||
}
|
||||
|
||||
let mut resolved = Instance::expect_resolve(tcx, param_env, def_id, args, None);
|
||||
let mut resolved = Instance::expect_resolve(tcx, param_env, def_id, args, span);
|
||||
|
||||
let reason = tcx.sess.is_sanitizer_kcfi_enabled().then_some(ReifyReason::Vtable);
|
||||
match resolved.def {
|
||||
@ -731,13 +738,13 @@ impl<'tcx> Instance<'tcx> {
|
||||
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
|
||||
let def_id = tcx.require_lang_item(LangItem::DropInPlace, None);
|
||||
let args = tcx.mk_args(&[ty.into()]);
|
||||
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args, None)
|
||||
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args, DUMMY_SP)
|
||||
}
|
||||
|
||||
pub fn resolve_async_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
|
||||
let def_id = tcx.require_lang_item(LangItem::AsyncDropInPlace, None);
|
||||
let args = tcx.mk_args(&[ty.into()]);
|
||||
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args, None)
|
||||
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args, DUMMY_SP)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(tcx), ret)]
|
||||
|
@ -853,13 +853,7 @@ fn visit_fn_use<'tcx>(
|
||||
) {
|
||||
if let ty::FnDef(def_id, args) = *ty.kind() {
|
||||
let instance = if is_direct_call {
|
||||
ty::Instance::expect_resolve(
|
||||
tcx,
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
args,
|
||||
Some(source),
|
||||
)
|
||||
ty::Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args, source)
|
||||
} else {
|
||||
match ty::Instance::resolve_for_fn_ptr(tcx, ty::ParamEnv::reveal_all(), def_id, args) {
|
||||
Some(instance) => instance,
|
||||
@ -1261,13 +1255,8 @@ fn visit_mentioned_item<'tcx>(
|
||||
match *item {
|
||||
MentionedItem::Fn(ty) => {
|
||||
if let ty::FnDef(def_id, args) = *ty.kind() {
|
||||
let instance = Instance::expect_resolve(
|
||||
tcx,
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
args,
|
||||
Some(span),
|
||||
);
|
||||
let instance =
|
||||
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args, span);
|
||||
// `visit_instance_use` was written for "used" item collection but works just as well
|
||||
// for "mentioned" item collection.
|
||||
// We can set `is_direct_call`; that just means we'll skip a bunch of shims that anyway
|
||||
@ -1492,7 +1481,7 @@ impl<'v> RootCollector<'_, 'v> {
|
||||
ty::ParamEnv::reveal_all(),
|
||||
start_def_id,
|
||||
self.tcx.mk_args(&[main_ret_ty.into()]),
|
||||
None,
|
||||
DUMMY_SP,
|
||||
);
|
||||
|
||||
self.output.push(create_fn_mono_item(self.tcx, start_instance, DUMMY_SP));
|
||||
@ -1561,9 +1550,10 @@ fn create_mono_items_for_default_impls<'tcx>(
|
||||
}
|
||||
|
||||
// As mentioned above, the method is legal to eagerly instantiate if it
|
||||
// only has lifetime generic parameters. This is validated by
|
||||
// only has lifetime generic parameters. This is validated by calling
|
||||
// `own_requires_monomorphization` on both the impl and method.
|
||||
let args = trait_ref.args.extend_to(tcx, method.def_id, only_region_params);
|
||||
let instance = ty::Instance::expect_resolve(tcx, param_env, method.def_id, args, None);
|
||||
let instance = ty::Instance::expect_resolve(tcx, param_env, method.def_id, args, DUMMY_SP);
|
||||
|
||||
let mono_item = create_fn_mono_item(tcx, instance, DUMMY_SP);
|
||||
if mono_item.node.is_instantiable(tcx) && should_codegen_locally(tcx, instance) {
|
||||
|
@ -6,7 +6,7 @@ use rustc_middle::bug;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{self, GenericParamDefKind, Ty, TyCtxt, Upcast, VtblEntry};
|
||||
use rustc_middle::ty::{GenericArgs, TypeVisitableExt};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_span::{sym, Span, DUMMY_SP};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use std::fmt::Debug;
|
||||
@ -290,6 +290,7 @@ fn vtable_entries<'tcx>(
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
args,
|
||||
DUMMY_SP,
|
||||
);
|
||||
|
||||
VtblEntry::Method(instance)
|
||||
|
Loading…
Reference in New Issue
Block a user