1
Fork 0

Make the THIR unsafeck use the thir_body query

This commit is contained in:
LeSeulArtichaut 2021-05-13 23:36:19 +02:00
parent 6f64eb1fe6
commit 6dfdea9800
5 changed files with 55 additions and 56 deletions

View file

@ -46,6 +46,18 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
let body_owner_kind = tcx.hir().body_owner_kind(id);
let typeck_results = tcx.typeck_opt_const_arg(def);
if tcx.sess.opts.debugging_opts.thir_unsafeck {
// 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))
}
ty::WithOptConstParam { did, const_param_did: None } => {
tcx.ensure().thir_check_unsafety(did)
}
}
}
// Figure out what primary body this item has.
let (body_id, return_ty_span, span_with_body) = match tcx.hir().get(id) {
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) => {