@@ -33,12 +33,6 @@ pub trait Qualif {
33
33
/// of the type.
34
34
fn in_any_value_of_ty ( _cx : & ConstCx < ' _ , ' tcx > , _ty : Ty < ' tcx > ) -> bool ;
35
35
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
-
42
36
fn in_projection_structurally (
43
37
cx : & ConstCx < ' _ , ' tcx > ,
44
38
per_local : & impl Fn ( Local ) -> bool ,
@@ -108,8 +102,14 @@ pub trait Qualif {
108
102
Operand :: Move ( ref place) => Self :: in_place ( cx, per_local, place. as_ref ( ) ) ,
109
103
110
104
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 )
113
113
} else if let ty:: ConstKind :: Unevaluated ( def_id, _) = constant. literal . val {
114
114
// Don't peek inside trait associated constants.
115
115
if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
0 commit comments