Skip to content

Conversation

@Kivooeo
Copy link
Member

@Kivooeo Kivooeo commented Dec 20, 2025

r? WaffleLapkin (it seems that the fixme in wildcard branch is yours, and i partially resolved it, at least as far as i understand, you might have different vision and/or feel free to reroll in case you are busy with irl things)

i don't quite fully understand this part of code, but it somewhat working, at least i don't fully understand the part why cases like

    let x: fn() = if true {
        (|| ()) as fn()
    } else {
        (|| ()) as unsafe fn()
    };
    let x: unsafe fn() = || ();
    let y: fn() = x as fn();

is already correctly rejected by compiler, but this snippet from issue with match isn't

second unsureness is from i dont really understand if this is correct to emit error like this

so the problem is that this gets into wildcard where it get replace with *entry.get_mut() = adj; (also after this gets replaced it breaks mir) and just hoping for best, but then this closure gets into fn_sig() and ices

according to what i said above, the best approach i came up with is add the special case for this and emit error

in case i do span_delayed_bug instead of hard error i still get this

error: internal compiler error: broken MIR in DefId(0:3 ~ main[de72]::fndef) (_1 = move _4 as fn() (PointerCoercion(ClosureFnPointer(Safe), Implicit))): bad assignment (Binder { value: unsafe fn(), bound_vars: [] } = Binder { value: fn(), bound_vars: [] }): NoSolution

also not sure about error message itself if everything else is fine, maybe just using "match arms have incompatible types"

fixes #150128

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 20, 2025

WaffleLapkin is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@rust-cloud-vms rust-cloud-vms bot force-pushed the closures-are-also-functions branch from 0865dac to 8bebf82 Compare December 20, 2025 21:56
@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 20, 2025

very strongly related to #148320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE to get the signature of a closure, use 'args.as_closure().sig()' not ''fn_sig()'

5 participants