@@ -8,7 +8,7 @@ use rustc::ty::cast::CastTy;
88use rustc:: hir;
99use rustc:: hir:: Node ;
1010use rustc:: hir:: def_id:: DefId ;
11- use rustc:: lint:: builtin:: { SAFE_EXTERN_STATICS , SAFE_PACKED_BORROWS , UNUSED_UNSAFE } ;
11+ use rustc:: lint:: builtin:: { SAFE_PACKED_BORROWS , UNUSED_UNSAFE } ;
1212use rustc:: mir:: * ;
1313use rustc:: mir:: visit:: { PlaceContext , Visitor , MutatingUseContext } ;
1414
@@ -208,23 +208,20 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
208208 }
209209 PlaceBase :: Static ( box Static { kind : StaticKind :: Static , def_id, .. } ) => {
210210 if self . tcx . is_mutable_static ( def_id) {
211- self . require_unsafe ( "use of mutable static" ,
211+ self . require_unsafe (
212+ "use of mutable static" ,
212213 "mutable statics can be mutated by multiple threads: aliasing \
213- violations or data races will cause undefined behavior",
214- UnsafetyViolationKind :: General ) ;
214+ violations or data races will cause undefined behavior",
215+ UnsafetyViolationKind :: General ,
216+ ) ;
215217 } else if self . tcx . is_foreign_item ( def_id) {
216- let source_info = self . source_info ;
217- let lint_root =
218- self . source_scope_local_data [ source_info. scope ] . lint_root ;
219- self . register_violations ( & [ UnsafetyViolation {
220- source_info,
221- description : Symbol :: intern ( "use of extern static" ) ,
222- details : Symbol :: intern (
223- "extern statics are not controlled by the Rust type system: \
224- invalid data, aliasing violations or data races will cause \
225- undefined behavior") ,
226- kind : UnsafetyViolationKind :: ExternStatic ( lint_root)
227- } ] , & [ ] ) ;
218+ self . require_unsafe (
219+ "use of extern static" ,
220+ "extern statics are not controlled by the Rust type system: \
221+ invalid data, aliasing violations or data races will cause \
222+ undefined behavior",
223+ UnsafetyViolationKind :: General ,
224+ ) ;
228225 }
229226 }
230227 }
@@ -351,8 +348,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
351348 match violation. kind {
352349 UnsafetyViolationKind :: GeneralAndConstFn |
353350 UnsafetyViolationKind :: General => { } ,
354- UnsafetyViolationKind :: BorrowPacked ( _) |
355- UnsafetyViolationKind :: ExternStatic ( _) => if self . min_const_fn {
351+ UnsafetyViolationKind :: BorrowPacked ( _) => if self . min_const_fn {
356352 // const fns don't need to be backwards compatible and can
357353 // emit these violations as a hard error instead of a backwards
358354 // compat lint
@@ -380,8 +376,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
380376 UnsafetyViolationKind :: GeneralAndConstFn => { } ,
381377 // these things are forbidden in const fns
382378 UnsafetyViolationKind :: General |
383- UnsafetyViolationKind :: BorrowPacked ( _) |
384- UnsafetyViolationKind :: ExternStatic ( _) => {
379+ UnsafetyViolationKind :: BorrowPacked ( _) => {
385380 let mut violation = violation. clone ( ) ;
386381 // const fns don't need to be backwards compatible and can
387382 // emit these violations as a hard error instead of a backwards
@@ -646,14 +641,6 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
646641 . note ( & details. as_str ( ) )
647642 . emit ( ) ;
648643 }
649- UnsafetyViolationKind :: ExternStatic ( lint_hir_id) => {
650- tcx. lint_node_note ( SAFE_EXTERN_STATICS ,
651- lint_hir_id,
652- source_info. span ,
653- & format ! ( "{} is unsafe and requires unsafe function or block \
654- (error E0133)", description) ,
655- & details. as_str ( ) ) ;
656- }
657644 UnsafetyViolationKind :: BorrowPacked ( lint_hir_id) => {
658645 if let Some ( impl_def_id) = builtin_derive_def_id ( tcx, def_id) {
659646 tcx. unsafe_derive_on_repr_packed ( impl_def_id) ;
0 commit comments