@@ -233,28 +233,30 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
233
233
if let ( local, [ ] ) = ( & place. local , proj_base) {
234
234
let decl = & self . body . local_decls [ * local] ;
235
235
if decl. internal {
236
- // Internal locals are used in the `move_val_init` desugaring.
237
- // We want to check unsafety against the source info of the
238
- // desugaring, rather than the source info of the RHS.
239
- self . source_info = self . body . local_decls [ * local] . source_info ;
240
- } else if let LocalInfo :: StaticRef { def_id, .. } = decl. local_info {
241
- if self . tcx . is_mutable_static ( def_id) {
242
- self . require_unsafe (
243
- "use of mutable static" ,
244
- "mutable statics can be mutated by multiple threads: aliasing \
245
- violations or data races will cause undefined behavior",
246
- UnsafetyViolationKind :: General ,
247
- ) ;
248
- return ;
249
- } else if self . tcx . is_foreign_item ( def_id) {
250
- self . require_unsafe (
251
- "use of extern static" ,
252
- "extern statics are not controlled by the Rust type system: \
253
- invalid data, aliasing violations or data races will cause \
254
- undefined behavior",
255
- UnsafetyViolationKind :: General ,
256
- ) ;
257
- return ;
236
+ if let LocalInfo :: StaticRef { def_id, .. } = decl. local_info {
237
+ if self . tcx . is_mutable_static ( def_id) {
238
+ self . require_unsafe (
239
+ "use of mutable static" ,
240
+ "mutable statics can be mutated by multiple threads: aliasing \
241
+ violations or data races will cause undefined behavior",
242
+ UnsafetyViolationKind :: General ,
243
+ ) ;
244
+ return ;
245
+ } else if self . tcx . is_foreign_item ( def_id) {
246
+ self . require_unsafe (
247
+ "use of extern static" ,
248
+ "extern statics are not controlled by the Rust type system: \
249
+ invalid data, aliasing violations or data races will cause \
250
+ undefined behavior",
251
+ UnsafetyViolationKind :: General ,
252
+ ) ;
253
+ return ;
254
+ }
255
+ } else {
256
+ // Internal locals are used in the `move_val_init` desugaring.
257
+ // We want to check unsafety against the source info of the
258
+ // desugaring, rather than the source info of the RHS.
259
+ self . source_info = self . body . local_decls [ * local] . source_info ;
258
260
}
259
261
}
260
262
}
0 commit comments