3
3
//! See the `Qualif` trait for more info.
4
4
5
5
use rustc_middle:: mir:: * ;
6
- use rustc_middle:: ty:: { self , AdtDef , Ty } ;
6
+ use rustc_middle:: ty:: { self , subst :: SubstsRef , AdtDef , Ty } ;
7
7
use rustc_span:: DUMMY_SP ;
8
8
9
9
use super :: ConstCx ;
@@ -53,7 +53,11 @@ pub trait Qualif {
53
53
/// with a custom `Drop` impl is inherently `NeedsDrop`.
54
54
///
55
55
/// 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 ;
57
61
}
58
62
59
63
/// Constant containing interior mutability (`UnsafeCell<T>`).
@@ -74,7 +78,7 @@ impl Qualif for HasMutInterior {
74
78
!ty. is_freeze ( cx. tcx , cx. param_env , DUMMY_SP )
75
79
}
76
80
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 {
78
82
// Exactly one type, `UnsafeCell`, has the `HasMutInterior` qualif inherently.
79
83
// It arises structurally for all other types.
80
84
Some ( adt. did ) == cx. tcx . lang_items ( ) . unsafe_cell_type ( )
@@ -99,7 +103,7 @@ impl Qualif for NeedsDrop {
99
103
ty. needs_drop ( cx. tcx , cx. param_env )
100
104
}
101
105
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 {
103
107
adt. has_dtor ( cx. tcx )
104
108
}
105
109
}
@@ -147,8 +151,8 @@ where
147
151
Rvalue :: Aggregate ( kind, operands) => {
148
152
// Return early if we know that the struct or enum being constructed is always
149
153
// 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 ) {
152
156
return true ;
153
157
}
154
158
}
0 commit comments