@@ -14,9 +14,8 @@ use rustc_data_structures::indexed_vec::IndexVec;
1414use rustc:: ty:: maps:: Providers ;
1515use rustc:: ty:: { self , TyCtxt } ;
1616use rustc:: hir;
17- use rustc:: hir:: def:: Def ;
1817use rustc:: hir:: def_id:: DefId ;
19- use rustc:: hir:: map:: { DefPathData , Node } ;
18+ use rustc:: hir:: map:: DefPathData ;
2019use rustc:: lint:: builtin:: { SAFE_EXTERN_STATICS , UNUSED_UNSAFE } ;
2120use rustc:: mir:: * ;
2221use rustc:: mir:: visit:: { LvalueContext , Visitor } ;
@@ -189,7 +188,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
189188 // locals are safe
190189 }
191190 & Lvalue :: Static ( box Static { def_id, ty : _ } ) => {
192- if self . is_static_mut ( def_id) {
191+ if self . tcx . is_static_mut ( def_id) {
193192 self . require_unsafe ( "use of mutable static" ) ;
194193 } else if self . tcx . is_foreign_item ( def_id) {
195194 let source_info = self . source_info ;
@@ -208,24 +207,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
208207}
209208
210209impl < ' a , ' tcx > UnsafetyChecker < ' a , ' tcx > {
211- fn is_static_mut ( & self , def_id : DefId ) -> bool {
212- if let Some ( node) = self . tcx . hir . get_if_local ( def_id) {
213- match node {
214- Node :: NodeItem ( & hir:: Item {
215- node : hir:: ItemStatic ( _, hir:: MutMutable , _) , ..
216- } ) => true ,
217- Node :: NodeForeignItem ( & hir:: ForeignItem {
218- node : hir:: ForeignItemStatic ( _, mutbl) , ..
219- } ) => mutbl,
220- _ => false
221- }
222- } else {
223- match self . tcx . describe_def ( def_id) {
224- Some ( Def :: Static ( _, mutbl) ) => mutbl,
225- _ => false
226- }
227- }
228- }
229210 fn require_unsafe ( & mut self ,
230211 description : & ' static str )
231212 {
0 commit comments