Closures are recursively reachable

This commit is contained in:
Tomasz Miąsko 2024-06-04 00:00:00 +00:00
parent 44701e070c
commit 5d26f58423
3 changed files with 9 additions and 0 deletions

View File

@ -157,6 +157,7 @@ fn is_recursively_reachable_local(&self, def_id: DefId) -> bool {
}
hir::ImplItemKind::Type(_) => false,
},
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => true,
_ => false,
}
}

View File

@ -3,6 +3,12 @@
pub static G: fn() = G0;
pub static H: &(dyn Fn() + Sync) = &h;
pub static I: fn() = Helper(j).mk();
pub static K: fn() -> fn() = {
#[inline(never)]
fn k() {}
#[inline(always)]
|| -> fn() { k }
};
static X: u32 = 42;
static G0: fn() = g;

View File

@ -8,6 +8,7 @@
static G: fn() = aux::G;
static H: &(dyn Fn() + Sync) = aux::H;
static I: fn() = aux::I;
static K: fn() -> fn() = aux::K;
fn v() -> *const u32 {
V
@ -19,4 +20,5 @@ fn main() {
G();
H();
I();
K()();
}