Skip to content

Commit 0850c3b

Browse files
Pass Substs to in_adt_inherently
1 parent d7afaa7 commit 0850c3b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/librustc_mir/transform/check_consts/qualifs.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! See the `Qualif` trait for more info.
44
55
use rustc_middle::mir::*;
6-
use rustc_middle::ty::{self, AdtDef, Ty};
6+
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
77
use rustc_span::DUMMY_SP;
88

99
use super::ConstCx;
@@ -53,7 +53,11 @@ pub trait Qualif {
5353
/// with a custom `Drop` impl is inherently `NeedsDrop`.
5454
///
5555
/// Returning `true` for `in_adt_inherently` but `false` for `in_any_value_of_ty` is unsound.
56-
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &AdtDef) -> bool;
56+
fn in_adt_inherently(
57+
cx: &ConstCx<'_, 'tcx>,
58+
adt: &'tcx AdtDef,
59+
substs: SubstsRef<'tcx>,
60+
) -> bool;
5761
}
5862

5963
/// Constant containing interior mutability (`UnsafeCell<T>`).
@@ -74,7 +78,7 @@ impl Qualif for HasMutInterior {
7478
!ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SP)
7579
}
7680

77-
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &AdtDef) -> bool {
81+
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {
7882
// Exactly one type, `UnsafeCell`, has the `HasMutInterior` qualif inherently.
7983
// It arises structurally for all other types.
8084
Some(adt.did) == cx.tcx.lang_items().unsafe_cell_type()
@@ -99,7 +103,7 @@ impl Qualif for NeedsDrop {
99103
ty.needs_drop(cx.tcx, cx.param_env)
100104
}
101105

102-
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &AdtDef) -> bool {
106+
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {
103107
adt.has_dtor(cx.tcx)
104108
}
105109
}
@@ -147,8 +151,8 @@ where
147151
Rvalue::Aggregate(kind, operands) => {
148152
// Return early if we know that the struct or enum being constructed is always
149153
// qualified.
150-
if let AggregateKind::Adt(def, ..) = **kind {
151-
if Q::in_adt_inherently(cx, def) {
154+
if let AggregateKind::Adt(def, _, substs, ..) = **kind {
155+
if Q::in_adt_inherently(cx, def, substs) {
152156
return true;
153157
}
154158
}

0 commit comments

Comments
 (0)