Auto merge of #95436 - cjgillot:static-mut, r=oli-obk
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:
commit
a40c595695
40 changed files with 98 additions and 128 deletions
|
@ -156,7 +156,6 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
|
||||
let tcx = infcx.tcx;
|
||||
let param_env = tcx.param_env(def.did);
|
||||
let id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||
|
||||
let mut local_names = IndexVec::from_elem(None, &input_body.local_decls);
|
||||
for var_debug_info in &input_body.var_debug_info {
|
||||
|
@ -226,7 +225,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(&body);
|
||||
|
||||
let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(id).is_fn_or_closure();
|
||||
let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(def.did).is_fn_or_closure();
|
||||
let borrow_set =
|
||||
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));
|
||||
|
||||
|
@ -289,8 +288,9 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
.pass_name("borrowck")
|
||||
.iterate_to_fixpoint();
|
||||
|
||||
let def_hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||
let movable_generator = !matches!(
|
||||
tcx.hir().get(id),
|
||||
tcx.hir().get(def_hir_id),
|
||||
Node::Expr(&hir::Expr {
|
||||
kind: hir::ExprKind::Closure(.., Some(hir::Movability::Static)),
|
||||
..
|
||||
|
@ -385,7 +385,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
let scope = mbcx.body.source_info(location).scope;
|
||||
let lint_root = match &mbcx.body.source_scopes[scope].local_data {
|
||||
ClearCrossCrate::Set(data) => data.lint_root,
|
||||
_ => id,
|
||||
_ => def_hir_id,
|
||||
};
|
||||
|
||||
// Span and message don't matter; we overwrite them below anyway
|
||||
|
|
|
@ -524,7 +524,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||
let tcx = self.infcx.tcx;
|
||||
let typeck_root_def_id = tcx.typeck_root_def_id(self.mir_def.did.to_def_id());
|
||||
|
||||
match tcx.hir().body_owner_kind(self.mir_hir_id) {
|
||||
match tcx.hir().body_owner_kind(self.mir_def.did) {
|
||||
BodyOwnerKind::Closure | BodyOwnerKind::Fn => {
|
||||
let defining_ty = if self.mir_def.did.to_def_id() == typeck_root_def_id {
|
||||
tcx.type_of(typeck_root_def_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue