@@ -33,12 +33,6 @@ pub trait Qualif {
3333 /// of the type.
3434 fn in_any_value_of_ty ( _cx : & ConstCx < ' _ , ' tcx > , _ty : Ty < ' tcx > ) -> bool ;
3535
36- fn in_static ( cx : & ConstCx < ' _ , ' tcx > , def_id : DefId ) -> bool {
37- // `mir_const_qualif` does return the qualifs in the final value of a `static`, so we could
38- // use value-based qualification here, but we shouldn't do this without a good reason.
39- Self :: in_any_value_of_ty ( cx, cx. tcx . type_of ( def_id) )
40- }
41-
4236 fn in_projection_structurally (
4337 cx : & ConstCx < ' _ , ' tcx > ,
4438 per_local : & impl Fn ( Local ) -> bool ,
@@ -108,8 +102,14 @@ pub trait Qualif {
108102 Operand :: Move ( ref place) => Self :: in_place ( cx, per_local, place. as_ref ( ) ) ,
109103
110104 Operand :: Constant ( ref constant) => {
111- if let Some ( static_) = constant. check_static_ptr ( cx. tcx ) {
112- Self :: in_static ( cx, static_)
105+ if constant. check_static_ptr ( cx. tcx ) . is_some ( ) {
106+ // `mir_const_qualif` does return the qualifs in the final value of a `static`,
107+ // so we could use value-based qualification here, but we shouldn't do this
108+ // without a good reason.
109+ //
110+ // Note: this uses `constant.literal.ty` which is a reference or pointer to the
111+ // type of the actual `static` item.
112+ Self :: in_any_value_of_ty ( cx, constant. literal . ty )
113113 } else if let ty:: ConstKind :: Unevaluated ( def_id, _) = constant. literal . val {
114114 // Don't peek inside trait associated constants.
115115 if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
0 commit comments