@@ -29,16 +29,8 @@ pub trait Qualif {
2929 const IS_CLEARED_ON_MOVE : bool = false ;
3030
3131 /// 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 ;
4234
4335 fn in_static ( _cx : & ConstCx < ' _ , ' tcx > , _static : & Static < ' tcx > ) -> bool {
4436 // FIXME(eddyb) should we do anything here for value properties?
@@ -55,7 +47,7 @@ pub trait Qualif {
5547 base : place. base ,
5648 projection : proj_base,
5749 } ) ;
58- let qualif = base_qualif && Self :: mask_for_ty (
50+ let qualif = base_qualif && Self :: in_any_value_of_ty (
5951 cx,
6052 Place :: ty_from ( place. base , proj_base, cx. body , cx. tcx )
6153 . projection_ty ( cx. tcx , elem)
@@ -126,7 +118,7 @@ pub trait Qualif {
126118 if let ConstValue :: Unevaluated ( def_id, _) = constant. literal . val {
127119 // Don't peek inside trait associated constants.
128120 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 )
130122 } else {
131123 let ( bits, _) = cx. tcx . at ( constant. span ) . mir_const_qualif ( def_id) ;
132124
@@ -135,7 +127,7 @@ pub trait Qualif {
135127 // Just in case the type is more specific than
136128 // the definition, e.g., impl associated const
137129 // 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 )
139131 }
140132 } else {
141133 false
@@ -200,7 +192,7 @@ pub trait Qualif {
200192 return_ty : Ty < ' tcx > ,
201193 ) -> bool {
202194 // 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)
204196 }
205197}
206198
@@ -214,8 +206,8 @@ pub struct HasMutInterior;
214206impl Qualif for HasMutInterior {
215207 const IDX : usize = 0 ;
216208
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 )
219211 }
220212
221213 fn in_rvalue ( cx : & ConstCx < ' _ , ' tcx > , per_local : & BitSet < Local > , rvalue : & Rvalue < ' tcx > ) -> bool {
@@ -249,7 +241,7 @@ impl Qualif for HasMutInterior {
249241 if let AggregateKind :: Adt ( def, ..) = * * kind {
250242 if Some ( def. did ) == cx. tcx . lang_items ( ) . unsafe_cell_type ( ) {
251243 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 ) ;
253245 return true ;
254246 }
255247 }
@@ -272,8 +264,8 @@ impl Qualif for NeedsDrop {
272264 const IDX : usize = 1 ;
273265 const IS_CLEARED_ON_MOVE : bool = true ;
274266
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 )
277269 }
278270
279271 fn in_rvalue ( cx : & ConstCx < ' _ , ' tcx > , per_local : & BitSet < Local > , rvalue : & Rvalue < ' tcx > ) -> bool {
0 commit comments