Rollup merge of #87645 - LeSeulArtichaut:issue-87414, r=oli-obk
Properly find owner of closure in THIR unsafeck Previously, when encountering a closure in a constant, the THIR unsafeck gets invoked on the owner of the constant instead of the constant itself, producing cycles. Supersedes #87492. ```@FabianWolff``` thanks for your work on that PR, I copied your test file and added you as a co-author. Fixes #87414. r? ```@oli-obk```
This commit is contained in:
commit
345862d224
2 changed files with 19 additions and 7 deletions
|
@ -599,13 +599,10 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD
|
|||
|
||||
// Closures are handled by their owner, if it has a body
|
||||
if tcx.is_closure(def.did.to_def_id()) {
|
||||
let owner = tcx.hir().local_def_id_to_hir_id(def.did).owner;
|
||||
let owner_hir_id = tcx.hir().local_def_id_to_hir_id(owner);
|
||||
|
||||
if tcx.hir().maybe_body_owned_by(owner_hir_id).is_some() {
|
||||
tcx.ensure().thir_check_unsafety(owner);
|
||||
return;
|
||||
}
|
||||
let hir = tcx.hir();
|
||||
let owner = hir.enclosing_body_owner(hir.local_def_id_to_hir_id(def.did));
|
||||
tcx.ensure().thir_check_unsafety(hir.local_def_id(owner));
|
||||
return;
|
||||
}
|
||||
|
||||
let (thir, expr) = tcx.thir_body(def);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue