Skip to content

Commit a82d14b

Browse files
authored
Rollup merge of rust-lang#125996 - tmiasko:closure-recursively-reachable, r=oli-obk
Closures are recursively reachable
2 parents b6117c6 + 5d26f58 commit a82d14b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

compiler/rustc_passes/src/reachable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl<'tcx> ReachableContext<'tcx> {
157157
}
158158
hir::ImplItemKind::Type(_) => false,
159159
},
160+
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => true,
160161
_ => false,
161162
}
162163
}

tests/ui/cross-crate/auxiliary/static_init_aux.rs

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ pub static F: fn() = f;
33
pub static G: fn() = G0;
44
pub static H: &(dyn Fn() + Sync) = &h;
55
pub static I: fn() = Helper(j).mk();
6+
pub static K: fn() -> fn() = {
7+
#[inline(never)]
8+
fn k() {}
9+
#[inline(always)]
10+
|| -> fn() { k }
11+
};
612

713
static X: u32 = 42;
814
static G0: fn() = g;

tests/ui/cross-crate/static-init.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ static F: fn() = aux::F;
88
static G: fn() = aux::G;
99
static H: &(dyn Fn() + Sync) = aux::H;
1010
static I: fn() = aux::I;
11+
static K: fn() -> fn() = aux::K;
1112

1213
fn v() -> *const u32 {
1314
V
@@ -19,4 +20,5 @@ fn main() {
1920
G();
2021
H();
2122
I();
23+
K()();
2224
}

0 commit comments

Comments
 (0)