@@ -8,7 +8,7 @@ use rustc::ty::cast::CastTy;
8
8
use rustc:: hir;
9
9
use rustc:: hir:: Node ;
10
10
use 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 } ;
12
12
use rustc:: mir:: * ;
13
13
use rustc:: mir:: visit:: { PlaceContext , Visitor , MutatingUseContext } ;
14
14
@@ -208,23 +208,20 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
208
208
}
209
209
PlaceBase :: Static ( box Static { kind : StaticKind :: Static , def_id, .. } ) => {
210
210
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" ,
212
213
"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
+ ) ;
215
217
} 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
+ ) ;
228
225
}
229
226
}
230
227
}
@@ -351,8 +348,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
351
348
match violation. kind {
352
349
UnsafetyViolationKind :: GeneralAndConstFn |
353
350
UnsafetyViolationKind :: General => { } ,
354
- UnsafetyViolationKind :: BorrowPacked ( _) |
355
- UnsafetyViolationKind :: ExternStatic ( _) => if self . min_const_fn {
351
+ UnsafetyViolationKind :: BorrowPacked ( _) => if self . min_const_fn {
356
352
// const fns don't need to be backwards compatible and can
357
353
// emit these violations as a hard error instead of a backwards
358
354
// compat lint
@@ -380,8 +376,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
380
376
UnsafetyViolationKind :: GeneralAndConstFn => { } ,
381
377
// these things are forbidden in const fns
382
378
UnsafetyViolationKind :: General |
383
- UnsafetyViolationKind :: BorrowPacked ( _) |
384
- UnsafetyViolationKind :: ExternStatic ( _) => {
379
+ UnsafetyViolationKind :: BorrowPacked ( _) => {
385
380
let mut violation = violation. clone ( ) ;
386
381
// const fns don't need to be backwards compatible and can
387
382
// emit these violations as a hard error instead of a backwards
@@ -646,14 +641,6 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
646
641
. note ( & details. as_str ( ) )
647
642
. emit ( ) ;
648
643
}
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
- }
657
644
UnsafetyViolationKind :: BorrowPacked ( lint_hir_id) => {
658
645
if let Some ( impl_def_id) = builtin_derive_def_id ( tcx, def_id) {
659
646
tcx. unsafe_derive_on_repr_packed ( impl_def_id) ;
0 commit comments