@@ -74,8 +74,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
74
74
// First we build all the statements in the block.
75
75
let mut let_scope_stack = Vec :: with_capacity ( 8 ) ;
76
76
let outer_source_scope = this. source_scope ;
77
- let outer_push_unsafe_count = this. push_unsafe_count ;
78
- let outer_unpushed_unsafe = this. unpushed_unsafe ;
77
+ let outer_in_scope_unsafe = this. in_scope_unsafe ;
79
78
this. update_source_scope_for_safety_mode ( span, safety_mode) ;
80
79
81
80
let source_info = this. source_info ( span) ;
@@ -206,8 +205,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
206
205
}
207
206
// Restore the original source scope.
208
207
this. source_scope = outer_source_scope;
209
- this. push_unsafe_count = outer_push_unsafe_count;
210
- this. unpushed_unsafe = outer_unpushed_unsafe;
208
+ this. in_scope_unsafe = outer_in_scope_unsafe;
211
209
block. unit ( )
212
210
}
213
211
@@ -217,29 +215,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
217
215
let new_unsafety = match safety_mode {
218
216
BlockSafety :: Safe => None ,
219
217
BlockSafety :: ExplicitUnsafe ( hir_id) => {
220
- assert_eq ! ( self . push_unsafe_count, 0 ) ;
221
- match self . unpushed_unsafe {
218
+ match self . in_scope_unsafe {
222
219
Safety :: Safe => { }
223
220
// no longer treat `unsafe fn`s as `unsafe` contexts (see RFC #2585)
224
221
Safety :: FnUnsafe
225
222
if self . tcx . lint_level_at_node ( UNSAFE_OP_IN_UNSAFE_FN , hir_id) . 0
226
223
!= Level :: Allow => { }
227
224
_ => return ,
228
225
}
229
- self . unpushed_unsafe = Safety :: ExplicitUnsafe ( hir_id) ;
226
+ self . in_scope_unsafe = Safety :: ExplicitUnsafe ( hir_id) ;
230
227
Some ( Safety :: ExplicitUnsafe ( hir_id) )
231
228
}
232
- BlockSafety :: PushUnsafe => {
233
- self . push_unsafe_count += 1 ;
234
- Some ( Safety :: BuiltinUnsafe )
235
- }
236
- BlockSafety :: PopUnsafe => {
237
- self . push_unsafe_count = self
238
- . push_unsafe_count
239
- . checked_sub ( 1 )
240
- . unwrap_or_else ( || span_bug ! ( span, "unsafe count underflow" ) ) ;
241
- if self . push_unsafe_count == 0 { Some ( self . unpushed_unsafe ) } else { None }
242
- }
243
229
} ;
244
230
245
231
if let Some ( unsafety) = new_unsafety {
0 commit comments