Skip to content

Commit 2176e3a

Browse files
committed
Auto merge of #105592 - matthiaskrgr:rollup-1cazogq, r=matthiaskrgr
Rollup of 2 pull requests Successful merges: - #104997 (Move tests) - #105569 (`bug!` with a better error message for failing `Instance::resolve`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2cd2070 + 5877a3f commit 2176e3a

39 files changed

+35
-34
lines changed

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
349349

350350
// Handle special calls like intrinsics and empty drop glue.
351351
let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() {
352-
let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs)
353-
.unwrap()
354-
.unwrap()
355-
.polymorphize(fx.tcx);
352+
let instance =
353+
ty::Instance::expect_resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs)
354+
.polymorphize(fx.tcx);
356355

357356
if fx.tcx.symbol_name(instance).name.starts_with("llvm.") {
358357
crate::intrinsics::codegen_llvm_intrinsic_call(

compiler/rustc_codegen_ssa/src/mir/block.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
751751
let (instance, mut llfn) = match *callee.layout.ty.kind() {
752752
ty::FnDef(def_id, substs) => (
753753
Some(
754-
ty::Instance::resolve(bx.tcx(), ty::ParamEnv::reveal_all(), def_id, substs)
755-
.unwrap()
756-
.unwrap()
757-
.polymorphize(bx.tcx()),
754+
ty::Instance::expect_resolve(
755+
bx.tcx(),
756+
ty::ParamEnv::reveal_all(),
757+
def_id,
758+
substs,
759+
)
760+
.polymorphize(bx.tcx()),
758761
),
759762
None,
760763
),

compiler/rustc_middle/src/ty/instance.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,21 @@ impl<'tcx> Instance<'tcx> {
385385
)
386386
}
387387

388+
pub fn expect_resolve(
389+
tcx: TyCtxt<'tcx>,
390+
param_env: ty::ParamEnv<'tcx>,
391+
def_id: DefId,
392+
substs: SubstsRef<'tcx>,
393+
) -> Instance<'tcx> {
394+
match ty::Instance::resolve(tcx, param_env, def_id, substs) {
395+
Ok(Some(instance)) => instance,
396+
_ => bug!(
397+
"failed to resolve instance for {}",
398+
tcx.def_path_str_with_substs(def_id, substs)
399+
),
400+
}
401+
}
402+
388403
// This should be kept up to date with `resolve`.
389404
pub fn resolve_opt_const_arg(
390405
tcx: TyCtxt<'tcx>,
@@ -525,7 +540,7 @@ impl<'tcx> Instance<'tcx> {
525540
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
526541
let def_id = tcx.require_lang_item(LangItem::DropInPlace, None);
527542
let substs = tcx.intern_substs(&[ty.into()]);
528-
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap().unwrap()
543+
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs)
529544
}
530545

531546
#[instrument(level = "debug", skip(tcx), ret)]

compiler/rustc_monomorphize/src/collector.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -931,10 +931,13 @@ fn visit_fn_use<'tcx>(
931931
) {
932932
if let ty::FnDef(def_id, substs) = *ty.kind() {
933933
let instance = if is_direct_call {
934-
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap().unwrap()
934+
ty::Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs)
935935
} else {
936-
ty::Instance::resolve_for_fn_ptr(tcx, ty::ParamEnv::reveal_all(), def_id, substs)
937-
.unwrap()
936+
match ty::Instance::resolve_for_fn_ptr(tcx, ty::ParamEnv::reveal_all(), def_id, substs)
937+
{
938+
Some(instance) => instance,
939+
_ => bug!("failed to resolve instance for {ty}"),
940+
}
938941
};
939942
visit_instance_use(tcx, instance, is_direct_call, source, output);
940943
}
@@ -1369,9 +1372,8 @@ fn create_mono_items_for_default_impls<'tcx>(
13691372
trait_ref.substs[param.index as usize]
13701373
}
13711374
});
1372-
let instance = ty::Instance::resolve(tcx, param_env, method.def_id, substs)
1373-
.unwrap()
1374-
.unwrap();
1375+
let instance =
1376+
ty::Instance::expect_resolve(tcx, param_env, method.def_id, substs);
13751377

13761378
let mono_item = create_fn_mono_item(tcx, instance, DUMMY_SP);
13771379
if mono_item.node.is_instantiable(tcx) && should_codegen_locally(tcx, &instance)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/test/ui/issues/issue-5353.rs

-18
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::path::Path;
1010
const ENTRY_LIMIT: usize = 1000;
1111
// FIXME: The following limits should be reduced eventually.
1212
const ROOT_ENTRY_LIMIT: usize = 939;
13-
const ISSUES_ENTRY_LIMIT: usize = 2070;
13+
const ISSUES_ENTRY_LIMIT: usize = 2040;
1414

1515
fn check_entries(path: &Path, bad: &mut bool) {
1616
for dir in Walk::new(&path.join("test/ui")) {

0 commit comments

Comments
 (0)