Remember mutability in DefKind::Static
.
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
This commit is contained in:
parent
11909e3588
commit
21a554caf6
40 changed files with 98 additions and 128 deletions
|
@ -41,7 +41,7 @@ crate fn mir_built<'tcx>(
|
|||
/// Construct the MIR for a given `DefId`.
|
||||
fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_> {
|
||||
let id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||
let body_owner_kind = tcx.hir().body_owner_kind(id);
|
||||
let body_owner_kind = tcx.hir().body_owner_kind(def.did);
|
||||
let typeck_results = tcx.typeck_opt_const_arg(def);
|
||||
|
||||
// Ensure unsafeck and abstract const building is ran before we steal the THIR.
|
||||
|
@ -802,7 +802,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
check_overflow |= tcx.sess.overflow_checks();
|
||||
// Constants always need overflow checks.
|
||||
check_overflow |= matches!(
|
||||
tcx.hir().body_owner_kind(hir_id),
|
||||
tcx.hir().body_owner_kind(def.did),
|
||||
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_)
|
||||
);
|
||||
|
||||
|
|
|
@ -523,7 +523,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
Res::Def(DefKind::Static, def_id) => {
|
||||
Res::Def(DefKind::Static(_), def_id) => {
|
||||
InlineAsmOperand::SymStatic { def_id }
|
||||
}
|
||||
|
||||
|
@ -901,7 +901,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
// We encode uses of statics as a `*&STATIC` where the `&STATIC` part is
|
||||
// a constant reference (or constant raw pointer for `static mut`) in MIR
|
||||
Res::Def(DefKind::Static, id) => {
|
||||
Res::Def(DefKind::Static(_), id) => {
|
||||
let ty = self.tcx.static_ptr_ty(id);
|
||||
let temp_lifetime = self.region_scope_tree.temporary_scope(expr.hir_id.local_id);
|
||||
let kind = if self.tcx.is_thread_local_static(id) {
|
||||
|
|
|
@ -420,7 +420,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
_ => {
|
||||
let pattern_error = match res {
|
||||
Res::Def(DefKind::ConstParam, _) => PatternError::ConstParamInPattern(span),
|
||||
Res::Def(DefKind::Static, _) => PatternError::StaticInPattern(span),
|
||||
Res::Def(DefKind::Static(_), _) => PatternError::StaticInPattern(span),
|
||||
_ => PatternError::NonConstPath(span),
|
||||
};
|
||||
self.errors.push(pattern_error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue