33//! See the `Qualif` trait for more info.
44
55use rustc_middle:: mir:: * ;
6- use rustc_middle:: ty:: { self , AdtDef , Ty } ;
6+ use rustc_middle:: ty:: { self , subst :: SubstsRef , AdtDef , Ty } ;
77use rustc_span:: DUMMY_SP ;
88
99use 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