Is this closure_lifetime_binder unsoundness already covered by #25860?

I discovered a #25860-like unsoundness while experimenting with closure_lifetime_binder, and I'm not sure where (or whether) to report it, so I'm asking here.

#![forbid(unsafe_code)]
#![feature(closure_lifetime_binder)]

static UNIT: &'static &'static () = &&();

fn extend<'x>(r: &'x String) -> &'static String {
    let f = for<'a, 'b> |_: &'a &'b (), v: &'b String| -> &'a String { v };
    let g: fn(&'static &'static (), &'x String) -> &'static String = f;
    g(UNIT, r)
}

fn main() {
    let r: &'static String;
    {
        let s = String::from("abcd");
        r = extend(&s);
    }
    println!("{}", r);
}

This compiles on nightly-2026-10-25, and Miri reports a use-after-free.

While narrowing it down, I found that the feature isn't required. The same thing happens on stable with a plain closure, without the feature attribute and replacing the let f line with:

let f: for<'a, 'b> fn(&'a &'b (), &'b String) -> &'a String = |_, v| v;

I don't think this is new, but is it worth noting somewhere (#25860 and #97362 are locked), or is it fine to leave it?

This is fundamentally the same setup as the one in the comment at Implied bounds on nested references + variance = soundness hole · Issue #25860 · rust-lang/rust · GitHub, so I don't think this needs to be reported.

1 Like

Thanks, I'll leave it then.