WIP state
This commit is contained in:
parent
97032a6dfa
commit
2987f4ba42
7 changed files with 160 additions and 227 deletions
|
@ -28,6 +28,7 @@ crate fn mir_built<'tcx>(
|
|||
if let Some(def) = def.try_upgrade(tcx) {
|
||||
return tcx.mir_built(def);
|
||||
}
|
||||
debug!("mir_built: def={:?}", def);
|
||||
|
||||
let mut body = mir_build(tcx, def);
|
||||
if def.const_param_did.is_some() {
|
||||
|
@ -40,6 +41,7 @@ crate fn mir_built<'tcx>(
|
|||
|
||||
/// Construct the MIR for a given `DefId`.
|
||||
fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_> {
|
||||
debug!("mir_build: def={:?}", def);
|
||||
let id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||
let body_owner_kind = tcx.hir().body_owner_kind(id);
|
||||
let typeck_results = tcx.typeck_opt_const_arg(def);
|
||||
|
@ -47,10 +49,12 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
|
|||
// Ensure unsafeck is ran before we steal the THIR.
|
||||
match def {
|
||||
ty::WithOptConstParam { did, const_param_did: Some(const_param_did) } => {
|
||||
tcx.ensure().thir_check_unsafety_for_const_arg((did, const_param_did))
|
||||
tcx.ensure().thir_check_unsafety_for_const_arg((did, const_param_did));
|
||||
tcx.ensure().mir_abstract_const_of_const_arg((did, const_param_did));
|
||||
}
|
||||
ty::WithOptConstParam { did, const_param_did: None } => {
|
||||
tcx.ensure().thir_check_unsafety(did)
|
||||
tcx.ensure().thir_check_unsafety(did);
|
||||
tcx.ensure().mir_abstract_const(did);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,9 @@ impl<'tcx> Cx<'tcx> {
|
|||
}
|
||||
|
||||
fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> {
|
||||
debug!("Expr::make_mirror_unadjusted: expr={:?}", expr);
|
||||
let expr_ty = self.typeck_results().expr_ty(expr);
|
||||
debug!("Expr::make_mirror_unadjusted: expr_ty={:?}", expr_ty);
|
||||
let temp_lifetime = self.region_scope_tree.temporary_scope(expr.hir_id.local_id);
|
||||
|
||||
let kind = match expr.kind {
|
||||
|
@ -762,6 +764,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
hir::ExprKind::Err => unreachable!(),
|
||||
};
|
||||
|
||||
debug!("Expr::make_mirror_unadjusted: finish");
|
||||
Expr { temp_lifetime, ty: expr_ty, span: expr.span, kind }
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ crate fn thir_body<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
owner_def: ty::WithOptConstParam<LocalDefId>,
|
||||
) -> (&'tcx Steal<Thir<'tcx>>, ExprId) {
|
||||
debug!("thir_body: {:?}", owner_def);
|
||||
let hir = tcx.hir();
|
||||
let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(owner_def.did)));
|
||||
let mut cx = Cx::new(tcx, owner_def);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue