Rollup merge of #122286 - RalfJung:resolve, r=compiler-errors

use Instance::expect_resolve() instead of unwraping Instance::resolve()
This commit is contained in:
Matthias Krüger 2024-03-10 22:16:43 +01:00 committed by GitHub
commit b02f2a0e76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 33 deletions

View File

@ -115,14 +115,12 @@ pub(crate) fn maybe_create_entry_wrapper(
termination_trait,
)
.unwrap();
let report = Instance::resolve(
let report = Instance::expect_resolve(
tcx,
ParamEnv::reveal_all(),
report.def_id,
tcx.mk_args(&[GenericArg::from(main_ret_ty)]),
)
.unwrap()
.unwrap()
.polymorphize(tcx);
let report_name = tcx.symbol_name(report).name;
@ -142,14 +140,12 @@ pub(crate) fn maybe_create_entry_wrapper(
}
} else if is_main_fn {
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
let start_instance = Instance::resolve(
let start_instance = Instance::expect_resolve(
tcx,
ParamEnv::reveal_all(),
start_def_id,
tcx.mk_args(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap()
.polymorphize(tcx);
let start_func_id = import_function(tcx, m, start_instance);

View File

@ -473,14 +473,12 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
let tcx = self.tcx;
let func = match tcx.lang_items().eh_personality() {
Some(def_id) if !wants_msvc_seh(self.sess()) => {
let instance = ty::Instance::resolve(
let instance = ty::Instance::expect_resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
ty::List::empty(),
)
.unwrap()
.unwrap();
);
let symbol_name = tcx.symbol_name(instance).name;
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());

View File

@ -558,11 +558,12 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let tcx = self.tcx;
let llfn = match tcx.lang_items().eh_personality() {
Some(def_id) if name.is_none() => self.get_fn_addr(
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, ty::List::empty())
.unwrap()
.unwrap(),
),
Some(def_id) if name.is_none() => self.get_fn_addr(ty::Instance::expect_resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
ty::List::empty(),
)),
_ => {
let name = name.unwrap_or("rust_eh_personality");
if let Some(llfn) = self.get_declared_value(name) {

View File

@ -467,16 +467,12 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let (start_fn, start_ty, args) = if let EntryFnType::Main { sigpipe } = entry_type {
let start_def_id = cx.tcx().require_lang_item(LangItem::Start, None);
let start_fn = cx.get_fn_addr(
ty::Instance::resolve(
let start_fn = cx.get_fn_addr(ty::Instance::expect_resolve(
cx.tcx(),
ty::ParamEnv::reveal_all(),
start_def_id,
cx.tcx().mk_args(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap(),
);
));
let i8_ty = cx.type_i8();
let arg_sigpipe = bx.const_u8(sigpipe);

View File

@ -243,14 +243,12 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
} else if Some(def_id) == self.tcx.lang_items().panic_fmt() {
// For panic_fmt, call const_panic_fmt instead.
let const_def_id = self.tcx.require_lang_item(LangItem::ConstPanicFmt, None);
let new_instance = ty::Instance::resolve(
let new_instance = ty::Instance::expect_resolve(
*self.tcx,
ty::ParamEnv::reveal_all(),
const_def_id,
instance.args,
)
.unwrap()
.unwrap();
);
return Ok(Some(new_instance));
} else if Some(def_id) == self.tcx.lang_items().align_offset_fn() {

View File

@ -1339,14 +1339,12 @@ impl<'v> RootCollector<'_, 'v> {
main_ret_ty.no_bound_vars().unwrap(),
);
let start_instance = Instance::resolve(
let start_instance = Instance::expect_resolve(
self.tcx,
ty::ParamEnv::reveal_all(),
start_def_id,
self.tcx.mk_args(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap();
);
self.output.push(create_fn_mono_item(self.tcx, start_instance, DUMMY_SP));
}