Skip to content

Commit 660795e

Browse files
authored
Rollup merge of #105441 - nnethercote:rm-UnsafetyState, r=lcnr
Remove `UnsafetyState` r? `@lcnr`
2 parents 433189b + 9af48e5 commit 660795e

File tree

5 files changed

+3
-42
lines changed

5 files changed

+3
-42
lines changed

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ impl<'tcx> AttributeMap<'tcx> {
827827
pub struct OwnerNodes<'tcx> {
828828
/// Pre-computed hash of the full HIR.
829829
pub hash_including_bodies: Fingerprint,
830-
/// Pre-computed hash of the item signature, sithout recursing into the body.
830+
/// Pre-computed hash of the item signature, without recursing into the body.
831831
pub hash_without_bodies: Fingerprint,
832832
/// Full HIR for the current owner.
833833
// The zeroth node's parent should never be accessed: the owner's parent is computed by the

compiler/rustc_hir_typeck/src/check.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::coercion::CoerceMany;
22
use crate::gather_locals::GatherLocalsVisitor;
33
use crate::FnCtxt;
4-
use crate::{GeneratorTypes, UnsafetyState};
4+
use crate::GeneratorTypes;
55
use rustc_hir as hir;
66
use rustc_hir::def::DefKind;
77
use rustc_hir::intravisit::Visitor;
@@ -30,7 +30,6 @@ pub(super) fn check_fn<'a, 'tcx>(
3030
can_be_generator: Option<hir::Movability>,
3131
) -> Option<GeneratorTypes<'tcx>> {
3232
let fn_id = fcx.tcx.hir().local_def_id_to_hir_id(fn_def_id);
33-
fcx.ps.set(UnsafetyState::function(fn_sig.unsafety, fn_id));
3433

3534
let tcx = fcx.tcx;
3635
let hir = tcx.hir();

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13931393
blk: &'tcx hir::Block<'tcx>,
13941394
expected: Expectation<'tcx>,
13951395
) -> Ty<'tcx> {
1396-
let prev = self.ps.replace(self.ps.get().recurse(blk));
1397-
13981396
// In some cases, blocks have just one exit, but other blocks
13991397
// can be targeted by multiple breaks. This can happen both
14001398
// with labeled blocks as well as when we desugar
@@ -1558,7 +1556,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15581556

15591557
self.write_ty(blk.hir_id, ty);
15601558

1561-
self.ps.set(prev);
15621559
ty
15631560
}
15641561

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_errors::ErrorGuaranteed;
88
pub use suggestions::*;
99

1010
use crate::coercion::DynamicCoerceMany;
11-
use crate::{Diverges, EnclosingBreakables, Inherited, UnsafetyState};
11+
use crate::{Diverges, EnclosingBreakables, Inherited};
1212
use rustc_hir as hir;
1313
use rustc_hir::def_id::DefId;
1414
use rustc_hir_analysis::astconv::AstConv;
@@ -74,8 +74,6 @@ pub struct FnCtxt<'a, 'tcx> {
7474

7575
pub(super) resume_yield_tys: Option<(Ty<'tcx>, Ty<'tcx>)>,
7676

77-
pub(super) ps: Cell<UnsafetyState>,
78-
7977
/// Whether the last checked node generates a divergence (e.g.,
8078
/// `return` will set this to `Always`). In general, when entering
8179
/// an expression or other node in the tree, the initial value
@@ -129,7 +127,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
129127
ret_coercion: None,
130128
ret_coercion_span: Cell::new(None),
131129
resume_yield_tys: None,
132-
ps: Cell::new(UnsafetyState::function(hir::Unsafety::Normal, hir::CRATE_HIR_ID)),
133130
diverges: Cell::new(Diverges::Maybe),
134131
enclosing_breakables: RefCell::new(EnclosingBreakables {
135132
stack: Vec::new(),

compiler/rustc_hir_typeck/src/lib.rs

-32
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,6 @@ pub struct LocalTy<'tcx> {
8989
revealed_ty: Ty<'tcx>,
9090
}
9191

92-
#[derive(Copy, Clone)]
93-
pub struct UnsafetyState {
94-
pub def: hir::HirId,
95-
pub unsafety: hir::Unsafety,
96-
from_fn: bool,
97-
}
98-
99-
impl UnsafetyState {
100-
pub fn function(unsafety: hir::Unsafety, def: hir::HirId) -> UnsafetyState {
101-
UnsafetyState { def, unsafety, from_fn: true }
102-
}
103-
104-
pub fn recurse(self, blk: &hir::Block<'_>) -> UnsafetyState {
105-
use hir::BlockCheckMode;
106-
match self.unsafety {
107-
// If this unsafe, then if the outer function was already marked as
108-
// unsafe we shouldn't attribute the unsafe'ness to the block. This
109-
// way the block can be warned about instead of ignoring this
110-
// extraneous block (functions are never warned about).
111-
hir::Unsafety::Unsafe if self.from_fn => self,
112-
113-
unsafety => {
114-
let (unsafety, def) = match blk.rules {
115-
BlockCheckMode::UnsafeBlock(..) => (hir::Unsafety::Unsafe, blk.hir_id),
116-
BlockCheckMode::DefaultBlock => (unsafety, self.def),
117-
};
118-
UnsafetyState { def, unsafety, from_fn: false }
119-
}
120-
}
121-
}
122-
}
123-
12492
/// If this `DefId` is a "primary tables entry", returns
12593
/// `Some((body_id, body_ty, fn_sig))`. Otherwise, returns `None`.
12694
///

0 commit comments

Comments
 (0)