Auto merge of #85421 - Smittyvb:rm_pushpop_unsafe, r=matthewjasper
Remove some last remants of {push,pop}_unsafe! These macros have already been removed, but there was still some code handling these macros. That code is now removed.
This commit is contained in:
commit
312b894cc1
10 changed files with 13 additions and 54 deletions
|
@ -74,8 +74,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// First we build all the statements in the block.
|
||||
let mut let_scope_stack = Vec::with_capacity(8);
|
||||
let outer_source_scope = this.source_scope;
|
||||
let outer_push_unsafe_count = this.push_unsafe_count;
|
||||
let outer_unpushed_unsafe = this.unpushed_unsafe;
|
||||
let outer_in_scope_unsafe = this.in_scope_unsafe;
|
||||
this.update_source_scope_for_safety_mode(span, safety_mode);
|
||||
|
||||
let source_info = this.source_info(span);
|
||||
|
@ -206,8 +205,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
// Restore the original source scope.
|
||||
this.source_scope = outer_source_scope;
|
||||
this.push_unsafe_count = outer_push_unsafe_count;
|
||||
this.unpushed_unsafe = outer_unpushed_unsafe;
|
||||
this.in_scope_unsafe = outer_in_scope_unsafe;
|
||||
block.unit()
|
||||
}
|
||||
|
||||
|
@ -217,8 +215,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let new_unsafety = match safety_mode {
|
||||
BlockSafety::Safe => None,
|
||||
BlockSafety::ExplicitUnsafe(hir_id) => {
|
||||
assert_eq!(self.push_unsafe_count, 0);
|
||||
match self.unpushed_unsafe {
|
||||
match self.in_scope_unsafe {
|
||||
Safety::Safe => {}
|
||||
// no longer treat `unsafe fn`s as `unsafe` contexts (see RFC #2585)
|
||||
Safety::FnUnsafe
|
||||
|
@ -226,20 +223,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
!= Level::Allow => {}
|
||||
_ => return,
|
||||
}
|
||||
self.unpushed_unsafe = Safety::ExplicitUnsafe(hir_id);
|
||||
self.in_scope_unsafe = Safety::ExplicitUnsafe(hir_id);
|
||||
Some(Safety::ExplicitUnsafe(hir_id))
|
||||
}
|
||||
BlockSafety::PushUnsafe => {
|
||||
self.push_unsafe_count += 1;
|
||||
Some(Safety::BuiltinUnsafe)
|
||||
}
|
||||
BlockSafety::PopUnsafe => {
|
||||
self.push_unsafe_count = self
|
||||
.push_unsafe_count
|
||||
.checked_sub(1)
|
||||
.unwrap_or_else(|| span_bug!(span, "unsafe count underflow"));
|
||||
if self.push_unsafe_count == 0 { Some(self.unpushed_unsafe) } else { None }
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(unsafety) = new_unsafety {
|
||||
|
|
|
@ -367,12 +367,8 @@ struct Builder<'a, 'tcx> {
|
|||
/// `{ STMTS; EXPR1 } + EXPR2`.
|
||||
block_context: BlockContext,
|
||||
|
||||
/// The current unsafe block in scope, even if it is hidden by
|
||||
/// a `PushUnsafeBlock`.
|
||||
unpushed_unsafe: Safety,
|
||||
|
||||
/// The number of `push_unsafe_block` levels in scope.
|
||||
push_unsafe_count: usize,
|
||||
/// The current unsafe block in scope
|
||||
in_scope_unsafe: Safety,
|
||||
|
||||
/// The vector of all scopes that we have created thus far;
|
||||
/// we track this for debuginfo later.
|
||||
|
@ -877,8 +873,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
source_scopes: IndexVec::new(),
|
||||
source_scope: OUTERMOST_SOURCE_SCOPE,
|
||||
guard_context: vec![],
|
||||
push_unsafe_count: 0,
|
||||
unpushed_unsafe: safety,
|
||||
in_scope_unsafe: safety,
|
||||
local_decls: IndexVec::from_elem_n(LocalDecl::new(return_ty, return_span), 1),
|
||||
canonical_user_type_annotations: IndexVec::new(),
|
||||
upvar_mutbls: vec![],
|
||||
|
|
|
@ -27,8 +27,6 @@ impl<'tcx> Cx<'tcx> {
|
|||
safety_mode: match block.rules {
|
||||
hir::BlockCheckMode::DefaultBlock => BlockSafety::Safe,
|
||||
hir::BlockCheckMode::UnsafeBlock(..) => BlockSafety::ExplicitUnsafe(block.hir_id),
|
||||
hir::BlockCheckMode::PushUnsafeBlock(..) => BlockSafety::PushUnsafe,
|
||||
hir::BlockCheckMode::PopUnsafeBlock(..) => BlockSafety::PopUnsafe,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue