diff --git a/compiler/rustc_codegen_cranelift/src/main_shim.rs b/compiler/rustc_codegen_cranelift/src/main_shim.rs index 6535c3a367b..1abfded8b11 100644 --- a/compiler/rustc_codegen_cranelift/src/main_shim.rs +++ b/compiler/rustc_codegen_cranelift/src/main_shim.rs @@ -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); diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index bc3d62f2679..8f643c7db72 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -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()); diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index d1f32087908..37c690a0128 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -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) { diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 1a3c70cedd0..5cba14a5dda 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -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( - cx.tcx(), - ty::ParamEnv::reveal_all(), - start_def_id, - cx.tcx().mk_args(&[main_ret_ty.into()]), - ) - .unwrap() - .unwrap(), - ); + 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()]), + )); let i8_ty = cx.type_i8(); let arg_sigpipe = bx.const_u8(sigpipe); diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 6736fc749c0..f104b836716 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -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() { diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 32f823a5ac6..a18448eabf3 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -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)); }