@@ -29,16 +29,8 @@ pub trait Qualif {
29
29
const IS_CLEARED_ON_MOVE : bool = false ;
30
30
31
31
/// Return the qualification that is (conservatively) correct for any value
32
- /// of the type, or `None` if the qualification is not value/type-based.
33
- fn in_any_value_of_ty ( _cx : & ConstCx < ' _ , ' tcx > , _ty : Ty < ' tcx > ) -> Option < bool > {
34
- None
35
- }
36
-
37
- /// Return a mask for the qualification, given a type. This is `false` iff
38
- /// no value of that type can have the qualification.
39
- fn mask_for_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> bool {
40
- Self :: in_any_value_of_ty ( cx, ty) . unwrap_or ( true )
41
- }
32
+ /// of the type.
33
+ fn in_any_value_of_ty ( _cx : & ConstCx < ' _ , ' tcx > , _ty : Ty < ' tcx > ) -> bool ;
42
34
43
35
fn in_static ( _cx : & ConstCx < ' _ , ' tcx > , _static : & Static < ' tcx > ) -> bool {
44
36
// FIXME(eddyb) should we do anything here for value properties?
@@ -55,7 +47,7 @@ pub trait Qualif {
55
47
base : place. base ,
56
48
projection : proj_base,
57
49
} ) ;
58
- let qualif = base_qualif && Self :: mask_for_ty (
50
+ let qualif = base_qualif && Self :: in_any_value_of_ty (
59
51
cx,
60
52
Place :: ty_from ( place. base , proj_base, cx. body , cx. tcx )
61
53
. projection_ty ( cx. tcx , elem)
@@ -126,7 +118,7 @@ pub trait Qualif {
126
118
if let ConstValue :: Unevaluated ( def_id, _) = constant. literal . val {
127
119
// Don't peek inside trait associated constants.
128
120
if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
129
- Self :: in_any_value_of_ty ( cx, constant. literal . ty ) . unwrap_or ( false )
121
+ Self :: in_any_value_of_ty ( cx, constant. literal . ty )
130
122
} else {
131
123
let ( bits, _) = cx. tcx . at ( constant. span ) . mir_const_qualif ( def_id) ;
132
124
@@ -135,7 +127,7 @@ pub trait Qualif {
135
127
// Just in case the type is more specific than
136
128
// the definition, e.g., impl associated const
137
129
// with type parameters, take it into account.
138
- qualif && Self :: mask_for_ty ( cx, constant. literal . ty )
130
+ qualif && Self :: in_any_value_of_ty ( cx, constant. literal . ty )
139
131
}
140
132
} else {
141
133
false
@@ -200,7 +192,7 @@ pub trait Qualif {
200
192
return_ty : Ty < ' tcx > ,
201
193
) -> bool {
202
194
// Be conservative about the returned value of a const fn.
203
- Self :: in_any_value_of_ty ( cx, return_ty) . unwrap_or ( false )
195
+ Self :: in_any_value_of_ty ( cx, return_ty)
204
196
}
205
197
}
206
198
@@ -214,8 +206,8 @@ pub struct HasMutInterior;
214
206
impl Qualif for HasMutInterior {
215
207
const IDX : usize = 0 ;
216
208
217
- fn in_any_value_of_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> Option < bool > {
218
- Some ( !ty. is_freeze ( cx. tcx , cx. param_env , DUMMY_SP ) )
209
+ fn in_any_value_of_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> bool {
210
+ !ty. is_freeze ( cx. tcx , cx. param_env , DUMMY_SP )
219
211
}
220
212
221
213
fn in_rvalue ( cx : & ConstCx < ' _ , ' tcx > , per_local : & BitSet < Local > , rvalue : & Rvalue < ' tcx > ) -> bool {
@@ -249,7 +241,7 @@ impl Qualif for HasMutInterior {
249
241
if let AggregateKind :: Adt ( def, ..) = * * kind {
250
242
if Some ( def. did ) == cx. tcx . lang_items ( ) . unsafe_cell_type ( ) {
251
243
let ty = rvalue. ty ( cx. body , cx. tcx ) ;
252
- assert_eq ! ( Self :: in_any_value_of_ty( cx, ty) , Some ( true ) ) ;
244
+ assert_eq ! ( Self :: in_any_value_of_ty( cx, ty) , true ) ;
253
245
return true ;
254
246
}
255
247
}
@@ -272,8 +264,8 @@ impl Qualif for NeedsDrop {
272
264
const IDX : usize = 1 ;
273
265
const IS_CLEARED_ON_MOVE : bool = true ;
274
266
275
- fn in_any_value_of_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> Option < bool > {
276
- Some ( ty. needs_drop ( cx. tcx , cx. param_env ) )
267
+ fn in_any_value_of_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> bool {
268
+ ty. needs_drop ( cx. tcx , cx. param_env )
277
269
}
278
270
279
271
fn in_rvalue ( cx : & ConstCx < ' _ , ' tcx > , per_local : & BitSet < Local > , rvalue : & Rvalue < ' tcx > ) -> bool {
0 commit comments