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
|
@ -873,9 +873,8 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||||
|
|
||||||
sess.time("MIR_effect_checking", || {
|
sess.time("MIR_effect_checking", || {
|
||||||
for def_id in tcx.body_owners() {
|
for def_id in tcx.body_owners() {
|
||||||
if tcx.sess.opts.debugging_opts.thir_unsafeck {
|
tcx.ensure().thir_check_unsafety(def_id);
|
||||||
tcx.ensure().thir_check_unsafety(def_id);
|
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
|
||||||
} else {
|
|
||||||
mir::transform::check_unsafety::check_unsafety(tcx, def_id);
|
mir::transform::check_unsafety::check_unsafety(tcx, def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 body_owner_kind = tcx.hir().body_owner_kind(id);
|
||||||
let typeck_results = tcx.typeck_opt_const_arg(def);
|
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.
|
||||||
// Ensure unsafeck is ran before we steal the THIR.
|
match def {
|
||||||
match def {
|
ty::WithOptConstParam { did, const_param_did: Some(const_param_did) } => {
|
||||||
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))
|
}
|
||||||
}
|
ty::WithOptConstParam { did, const_param_did: None } => {
|
||||||
ty::WithOptConstParam { did, const_param_did: None } => {
|
tcx.ensure().thir_check_unsafety(did)
|
||||||
tcx.ensure().thir_check_unsafety(did)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,6 +329,11 @@ impl UnsafeOpKind {
|
||||||
// FIXME: checking unsafety for closures should be handled by their parent body,
|
// FIXME: checking unsafety for closures should be handled by their parent body,
|
||||||
// as they inherit their "safety context" from their declaration site.
|
// as they inherit their "safety context" from their declaration site.
|
||||||
pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalDefId>) {
|
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, expr) = tcx.thir_body(def);
|
||||||
let thir = &thir.borrow();
|
let thir = &thir.borrow();
|
||||||
// If `thir` is empty, a type error occured, skip this body.
|
// If `thir` is empty, a type error occured, skip this body.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue