22
33use rustc:: mir:: * ;
44use rustc:: ty:: { self , Ty } ;
5+ use rustc:: hir:: def_id:: DefId ;
56use syntax_pos:: DUMMY_SP ;
67
78use super :: { ConstKind , Item as ConstCx } ;
@@ -32,7 +33,7 @@ pub trait Qualif {
3233 /// of the type.
3334 fn in_any_value_of_ty ( _cx : & ConstCx < ' _ , ' tcx > , _ty : Ty < ' tcx > ) -> bool ;
3435
35- fn in_static ( _cx : & ConstCx < ' _ , ' tcx > , _static : & Static < ' tcx > ) -> bool {
36+ fn in_static ( _cx : & ConstCx < ' _ , ' tcx > , _def_id : DefId ) -> bool {
3637 // FIXME(eddyb) should we do anything here for value properties?
3738 false
3839 }
@@ -86,18 +87,9 @@ pub trait Qualif {
8687 projection : [ ] ,
8788 } => per_local ( * local) ,
8889 PlaceRef {
89- base : PlaceBase :: Static ( box Static {
90- kind : StaticKind :: Promoted ( ..) ,
91- ..
92- } ) ,
90+ base : PlaceBase :: Static ( _) ,
9391 projection : [ ] ,
9492 } => bug ! ( "qualifying already promoted MIR" ) ,
95- PlaceRef {
96- base : PlaceBase :: Static ( static_) ,
97- projection : [ ] ,
98- } => {
99- Self :: in_static ( cx, static_)
100- } ,
10193 PlaceRef {
10294 base : _,
10395 projection : [ .., _] ,
@@ -115,7 +107,9 @@ pub trait Qualif {
115107 Operand :: Move ( ref place) => Self :: in_place ( cx, per_local, place. as_ref ( ) ) ,
116108
117109 Operand :: Constant ( ref constant) => {
118- if let ty:: ConstKind :: Unevaluated ( def_id, _) = constant. literal . val {
110+ if let Some ( static_) = constant. check_static_ptr ( cx. tcx ) {
111+ Self :: in_static ( cx, static_)
112+ } else if let ty:: ConstKind :: Unevaluated ( def_id, _) = constant. literal . val {
119113 // Don't peek inside trait associated constants.
120114 if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
121115 Self :: in_any_value_of_ty ( cx, constant. literal . ty )
0 commit comments