@@ -94,32 +94,23 @@ pub trait Qualif {
9494 }
9595
9696 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 {
10799 assert ! ( promoted. is_none( ) ) ;
108100 // 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 ( ) {
112102 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+ }
114106
115107 // Just in case the type is more specific than
116108 // the definition, e.g., impl associated const
117109 // with type parameters, take it into account.
118- qualif && Self :: in_any_value_of_ty ( cx, constant. literal . ty )
119110 }
120- } else {
121- false
122111 }
112+ // Otherwise use the qualifs of the type.
113+ Self :: in_any_value_of_ty ( cx, constant. literal . ty )
123114 }
124115 }
125116 }
0 commit comments