@@ -58,9 +58,11 @@ bitflags::bitflags! {
5858
5959impl < ' a , ' tcx > Qualif {
6060 /// 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 {
6466 let mut qualif = Self :: empty ( ) ;
6567 if !ty. is_freeze ( tcx, param_env, DUMMY_SP ) {
6668 qualif = qualif | Qualif :: MUTABLE_INTERIOR ;
@@ -72,10 +74,13 @@ impl<'a, 'tcx> Qualif {
7274 }
7375
7476 /// 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) ;
7984 if !ty_qualif. contains ( Qualif :: MUTABLE_INTERIOR ) {
8085 * self = * self - Qualif :: MUTABLE_INTERIOR ;
8186 }
@@ -117,8 +122,8 @@ struct Qualifier<'a, 'tcx> {
117122}
118123
119124impl < ' 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 )
122127 }
123128
124129 fn qualify_local ( & self , local : Local ) -> Qualif {
@@ -217,7 +222,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx> {
217222 if let ty:: LazyConst :: Unevaluated ( def_id, _) = constant. literal {
218223 // Don't peek inside trait associated constants.
219224 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 )
221226 } else {
222227 let ( bits, _) = self . tcx . at ( constant. span ) . mir_const_qualif ( * def_id) ;
223228
@@ -348,7 +353,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx> {
348353 if let AggregateKind :: Adt ( def, ..) = * * kind {
349354 if Some ( def. did ) == self . tcx . lang_items ( ) . unsafe_cell_type ( ) {
350355 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) ;
352357 assert ! ( qualif. contains( Qualif :: MUTABLE_INTERIOR ) ) ;
353358 }
354359
@@ -444,7 +449,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx> {
444449 }
445450
446451 // 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) ;
448453 if !is_promotable_const_fn && self . mode == Mode :: Fn {
449454 qualif | Qualif :: NOT_PROMOTABLE
450455 } else {
@@ -491,7 +496,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
491496
492497 let mut local_qualif = IndexVec :: from_elem ( None , & mir. local_decls ) ;
493498 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) ;
495500 local_qualif[ arg] = Some ( Qualif :: NOT_PROMOTABLE | qualif) ;
496501 }
497502
@@ -661,7 +666,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
661666 // Account for errors in consts by using the
662667 // conservative type qualification instead.
663668 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 ( ) ) ;
665670 }
666671
667672
0 commit comments