@@ -94,32 +94,31 @@ pub trait Qualif {
94
94
}
95
95
96
96
Operand :: Constant ( ref constant) => {
97
- if constant. check_static_ptr ( cx. tcx ) . is_some ( ) {
98
- // `mir_const_qualif` does return the qualifs in the final value of a `static`,
99
- // so we could use value-based qualification here, but we shouldn't do this
100
- // without a good reason.
101
- //
102
- // Note: this uses `constant.literal.ty` which is a reference or pointer to the
103
- // type of the actual `static` item.
104
- Self :: in_any_value_of_ty ( cx, constant. literal . ty )
105
- } else if let ty:: ConstKind :: Unevaluated ( def_id, _, promoted) = constant. literal . val
106
- {
97
+ // Check the qualifs of the value of `const` items.
98
+ if let ty:: ConstKind :: Unevaluated ( def_id, _, promoted) = constant. literal . val {
107
99
assert ! ( promoted. is_none( ) ) ;
108
100
// Don't peek inside trait associated constants.
109
- if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
110
- Self :: in_any_value_of_ty ( cx, constant. literal . ty )
111
- } else {
101
+ if cx. tcx . trait_of_item ( def_id) . is_none ( ) {
112
102
let qualifs = cx. tcx . at ( constant. span ) . mir_const_qualif ( def_id) ;
113
- let qualif = Self :: in_qualifs ( & qualifs) ;
103
+ if !Self :: in_qualifs ( & qualifs) {
104
+ return false ;
105
+ }
114
106
115
107
// Just in case the type is more specific than
116
108
// the definition, e.g., impl associated const
117
109
// with type parameters, take it into account.
118
- qualif && Self :: in_any_value_of_ty ( cx, constant. literal . ty )
119
110
}
120
- } else {
121
- false
122
111
}
112
+ // Otherwise use the qualifs of the type.
113
+ //
114
+ // We could use value-based qualification if this is a
115
+ // pointer to a static, but we shouldn't do that without a
116
+ // good reason.
117
+ //
118
+ // Note: If this is a pointer to a static, this uses
119
+ // `constant.literal.ty` which is a reference or pointer to
120
+ // the type of the actual static item.
121
+ Self :: in_any_value_of_ty ( cx, constant. literal . ty )
123
122
}
124
123
}
125
124
}
0 commit comments