Skip to content

Commit d62c70c

Browse files
Stall computing instance for drop shim until it has no unsubstituted const params
1 parent 5c4798b commit d62c70c

File tree

3 files changed

+11
-262
lines changed

3 files changed

+11
-262
lines changed

compiler/rustc_ty_utils/src/instance.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::query::Providers;
77
use rustc_middle::traits::{BuiltinImplSource, CodegenObligationError};
88
use rustc_middle::ty::util::AsyncDropGlueMorphology;
99
use rustc_middle::ty::GenericArgsRef;
10-
use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitableExt};
10+
use rustc_middle::ty::{self, Instance, TyCtxt, TypeFlags, TypeVisitableExt};
1111
use rustc_span::sym;
1212
use rustc_trait_selection::traits;
1313
use rustc_type_ir::ClosureKind;
@@ -53,6 +53,15 @@ fn resolve_instance<'tcx>(
5353
_ => return Ok(None),
5454
}
5555

56+
// FIXME(#127030): `ConstParamHasTy` has bad interactions with
57+
// the drop shim builder, which does not evaluate predicates in
58+
// the correct param-env for types being dropped. Stall resolving
59+
// the MIR for this instance until all of its const params are
60+
// substituted.
61+
if ty.has_type_flags(TypeFlags::HAS_CT_PARAM) {
62+
return Ok(None);
63+
}
64+
5665
ty::InstanceKind::DropGlue(def_id, Some(ty))
5766
} else {
5867
debug!(" => trivial drop glue");

tests/ui/const-generics/polymorphic-drop-shim.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
//@ compile-flags: -Zinline-mir=yes --crate-type=lib
2-
3-
//@ known-bug: unknown
4-
//@ build-fail
5-
//@ failure-status: 101
2+
//@ build-pass
63

74
use std::mem::ManuallyDrop;
85

0 commit comments

Comments
 (0)