@@ -249,28 +249,30 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
249
249
if let ( PlaceBase :: Local ( local) , [ ] ) = ( & place. base , proj_base) {
250
250
let decl = & self . body . local_decls [ * local] ;
251
251
if decl. internal {
252
- // Internal locals are used in the `move_val_init` desugaring.
253
- // We want to check unsafety against the source info of the
254
- // desugaring, rather than the source info of the RHS.
255
- self . source_info = self . body . local_decls [ * local] . source_info ;
256
- } else if let LocalInfo :: StaticRef { def_id, .. } = decl. local_info {
257
- if self . tcx . is_mutable_static ( def_id) {
258
- self . require_unsafe (
259
- "use of mutable static" ,
260
- "mutable statics can be mutated by multiple threads: aliasing \
261
- violations or data races will cause undefined behavior",
262
- UnsafetyViolationKind :: General ,
263
- ) ;
264
- return ;
265
- } else if self . tcx . is_foreign_item ( def_id) {
266
- self . require_unsafe (
267
- "use of extern static" ,
268
- "extern statics are not controlled by the Rust type system: \
269
- invalid data, aliasing violations or data races will cause \
270
- undefined behavior",
271
- UnsafetyViolationKind :: General ,
272
- ) ;
273
- return ;
252
+ if let LocalInfo :: StaticRef { def_id, .. } = decl. local_info {
253
+ if self . tcx . is_mutable_static ( def_id) {
254
+ self . require_unsafe (
255
+ "use of mutable static" ,
256
+ "mutable statics can be mutated by multiple threads: aliasing \
257
+ violations or data races will cause undefined behavior",
258
+ UnsafetyViolationKind :: General ,
259
+ ) ;
260
+ return ;
261
+ } else if self . tcx . is_foreign_item ( def_id) {
262
+ self . require_unsafe (
263
+ "use of extern static" ,
264
+ "extern statics are not controlled by the Rust type system: \
265
+ invalid data, aliasing violations or data races will cause \
266
+ undefined behavior",
267
+ UnsafetyViolationKind :: General ,
268
+ ) ;
269
+ return ;
270
+ }
271
+ } else {
272
+ // Internal locals are used in the `move_val_init` desugaring.
273
+ // We want to check unsafety against the source info of the
274
+ // desugaring, rather than the source info of the RHS.
275
+ self . source_info = self . body . local_decls [ * local] . source_info ;
274
276
}
275
277
}
276
278
}
0 commit comments