Make thir_check_unsafety
itself responsible for checking gate
This commit is contained in:
parent
13e7b237fd
commit
af3d9a3aa3
3 changed files with 14 additions and 12 deletions
|
@ -46,15 +46,13 @@ 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)
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -329,6 +329,11 @@ impl UnsafeOpKind {
|
|||
// FIXME: checking unsafety for closures should be handled by their parent body,
|
||||
// as they inherit their "safety context" from their declaration site.
|
||||
pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalDefId>) {
|
||||
// THIR unsafeck is gated under `-Z thir-unsafeck`
|
||||
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
|
||||
return;
|
||||
}
|
||||
|
||||
let (thir, expr) = tcx.thir_body(def);
|
||||
let thir = &thir.borrow();
|
||||
// If `thir` is empty, a type error occured, skip this body.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue