@@ -58,9 +58,11 @@ bitflags::bitflags! {
58
58
59
59
impl < ' a , ' tcx > Qualif {
60
60
/// Compute the qualifications for the given type.
61
- fn for_ty ( ty : Ty < ' tcx > ,
62
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
63
- param_env : ty:: ParamEnv < ' tcx > ) -> Self {
61
+ fn any_value_of_ty (
62
+ ty : Ty < ' tcx > ,
63
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
64
+ param_env : ty:: ParamEnv < ' tcx > ,
65
+ ) -> Self {
64
66
let mut qualif = Self :: empty ( ) ;
65
67
if !ty. is_freeze ( tcx, param_env, DUMMY_SP ) {
66
68
qualif = qualif | Qualif :: MUTABLE_INTERIOR ;
@@ -72,10 +74,13 @@ impl<'a, 'tcx> Qualif {
72
74
}
73
75
74
76
/// Remove flags which are impossible for the given type.
75
- fn restrict ( & mut self , ty : Ty < ' tcx > ,
76
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
77
- param_env : ty:: ParamEnv < ' tcx > ) {
78
- let ty_qualif = Self :: for_ty ( ty, tcx, param_env) ;
77
+ fn restrict (
78
+ & mut self ,
79
+ ty : Ty < ' tcx > ,
80
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
81
+ param_env : ty:: ParamEnv < ' tcx > ,
82
+ ) {
83
+ let ty_qualif = Self :: any_value_of_ty ( ty, tcx, param_env) ;
79
84
if !ty_qualif. contains ( Qualif :: MUTABLE_INTERIOR ) {
80
85
* self = * self - Qualif :: MUTABLE_INTERIOR ;
81
86
}
@@ -117,8 +122,8 @@ struct Qualifier<'a, 'tcx> {
117
122
}
118
123
119
124
impl < ' a , ' tcx > Qualifier < ' a , ' tcx > {
120
- fn qualif_for_ty ( & self , ty : Ty < ' tcx > ) -> Qualif {
121
- Qualif :: for_ty ( ty, self . tcx , self . param_env )
125
+ fn qualify_any_value_of_ty ( & self , ty : Ty < ' tcx > ) -> Qualif {
126
+ Qualif :: any_value_of_ty ( ty, self . tcx , self . param_env )
122
127
}
123
128
124
129
fn qualify_local ( & self , local : Local ) -> Qualif {
@@ -217,7 +222,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx> {
217
222
if let ty:: LazyConst :: Unevaluated ( def_id, _) = constant. literal {
218
223
// Don't peek inside trait associated constants.
219
224
if self . tcx . trait_of_item ( * def_id) . is_some ( ) {
220
- self . qualif_for_ty ( constant. ty )
225
+ self . qualify_any_value_of_ty ( constant. ty )
221
226
} else {
222
227
let ( bits, _) = self . tcx . at ( constant. span ) . mir_const_qualif ( * def_id) ;
223
228
@@ -348,7 +353,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx> {
348
353
if let AggregateKind :: Adt ( def, ..) = * * kind {
349
354
if Some ( def. did ) == self . tcx . lang_items ( ) . unsafe_cell_type ( ) {
350
355
let ty = rvalue. ty ( self . mir , self . tcx ) ;
351
- qualif = qualif | self . qualif_for_ty ( ty) ;
356
+ qualif = qualif | self . qualify_any_value_of_ty ( ty) ;
352
357
assert ! ( qualif. contains( Qualif :: MUTABLE_INTERIOR ) ) ;
353
358
}
354
359
@@ -444,7 +449,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx> {
444
449
}
445
450
446
451
// Be conservative about the returned value of a const fn.
447
- let qualif = self . qualif_for_ty ( return_ty) ;
452
+ let qualif = self . qualify_any_value_of_ty ( return_ty) ;
448
453
if !is_promotable_const_fn && self . mode == Mode :: Fn {
449
454
qualif | Qualif :: NOT_PROMOTABLE
450
455
} else {
@@ -491,7 +496,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
491
496
492
497
let mut local_qualif = IndexVec :: from_elem ( None , & mir. local_decls ) ;
493
498
for arg in mir. args_iter ( ) {
494
- let qualif = Qualif :: for_ty ( mir. local_decls [ arg] . ty , tcx, param_env) ;
499
+ let qualif = Qualif :: any_value_of_ty ( mir. local_decls [ arg] . ty , tcx, param_env) ;
495
500
local_qualif[ arg] = Some ( Qualif :: NOT_PROMOTABLE | qualif) ;
496
501
}
497
502
@@ -661,7 +666,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
661
666
// Account for errors in consts by using the
662
667
// conservative type qualification instead.
663
668
if qualif. intersects ( Qualif :: CONST_ERROR ) {
664
- qualif = self . qualifier ( ) . qualif_for_ty ( mir. return_ty ( ) ) ;
669
+ qualif = self . qualifier ( ) . qualify_any_value_of_ty ( mir. return_ty ( ) ) ;
665
670
}
666
671
667
672
0 commit comments