Skip to content

Commit 2987f4b

Browse files
committed
WIP state
1 parent 97032a6 commit 2987f4b

File tree

7 files changed

+160
-227
lines changed

7 files changed

+160
-227
lines changed

compiler/rustc_middle/src/mir/abstract_const.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub enum Node<'tcx> {
1717
Binop(mir::BinOp, NodeId, NodeId),
1818
UnaryOp(mir::UnOp, NodeId),
1919
FunctionCall(NodeId, &'tcx [NodeId]),
20+
Block(&'tcx [NodeId], Option<NodeId>),
2021
Cast(CastKind, NodeId, Ty<'tcx>),
2122
}
2223

compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ crate fn mir_built<'tcx>(
2828
if let Some(def) = def.try_upgrade(tcx) {
2929
return tcx.mir_built(def);
3030
}
31+
debug!("mir_built: def={:?}", def);
3132

3233
let mut body = mir_build(tcx, def);
3334
if def.const_param_did.is_some() {
@@ -40,17 +41,20 @@ crate fn mir_built<'tcx>(
4041

4142
/// Construct the MIR for a given `DefId`.
4243
fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_> {
44+
debug!("mir_build: def={:?}", def);
4345
let id = tcx.hir().local_def_id_to_hir_id(def.did);
4446
let body_owner_kind = tcx.hir().body_owner_kind(id);
4547
let typeck_results = tcx.typeck_opt_const_arg(def);
4648

4749
// Ensure unsafeck is ran before we steal the THIR.
4850
match def {
4951
ty::WithOptConstParam { did, const_param_did: Some(const_param_did) } => {
50-
tcx.ensure().thir_check_unsafety_for_const_arg((did, const_param_did))
52+
tcx.ensure().thir_check_unsafety_for_const_arg((did, const_param_did));
53+
tcx.ensure().mir_abstract_const_of_const_arg((did, const_param_did));
5154
}
5255
ty::WithOptConstParam { did, const_param_did: None } => {
53-
tcx.ensure().thir_check_unsafety(did)
56+
tcx.ensure().thir_check_unsafety(did);
57+
tcx.ensure().mir_abstract_const(did);
5458
}
5559
}
5660

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ impl<'tcx> Cx<'tcx> {
149149
}
150150

151151
fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> {
152+
debug!("Expr::make_mirror_unadjusted: expr={:?}", expr);
152153
let expr_ty = self.typeck_results().expr_ty(expr);
154+
debug!("Expr::make_mirror_unadjusted: expr_ty={:?}", expr_ty);
153155
let temp_lifetime = self.region_scope_tree.temporary_scope(expr.hir_id.local_id);
154156

155157
let kind = match expr.kind {
@@ -762,6 +764,7 @@ impl<'tcx> Cx<'tcx> {
762764
hir::ExprKind::Err => unreachable!(),
763765
};
764766

767+
debug!("Expr::make_mirror_unadjusted: finish");
765768
Expr { temp_lifetime, ty: expr_ty, span: expr.span, kind }
766769
}
767770

compiler/rustc_mir_build/src/thir/cx/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ crate fn thir_body<'tcx>(
2020
tcx: TyCtxt<'tcx>,
2121
owner_def: ty::WithOptConstParam<LocalDefId>,
2222
) -> (&'tcx Steal<Thir<'tcx>>, ExprId) {
23+
debug!("thir_body: {:?}", owner_def);
2324
let hir = tcx.hir();
2425
let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(owner_def.did)));
2526
let mut cx = Cx::new(tcx, owner_def);

compiler/rustc_privacy/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ where
159159
self.visit_const(leaf)
160160
}
161161
ACNode::Cast(_, _, ty) => self.visit_ty(ty),
162-
ACNode::Binop(..) | ACNode::UnaryOp(..) | ACNode::FunctionCall(_, _) => {
163-
ControlFlow::CONTINUE
164-
}
162+
ACNode::Block(_, _)
163+
| ACNode::Binop(..)
164+
| ACNode::UnaryOp(..)
165+
| ACNode::FunctionCall(_, _) => ControlFlow::CONTINUE,
165166
})
166167
}
167168

0 commit comments

Comments
 (0)