Direct coercion from closures to unsafe fn
pointers
#57883
Labels
A-coercions
Area: implicit and explicit `expr as Type` coercions
A-inference
Area: Type inference
A-typesystem
Area: The type system
C-tracking-issue
Category: A tracking issue for an RFC or an unstable feature.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
While you can coerce closures to
fn
pointers, it is currently not possible to coerce closures tounsafe fn
pointers since that requires a transitive coercion fromfn
pointers tounsafe fn
pointers. We do not allow transitive coercions. Example:This behavior of current Rust was unexpected in rust-lang/rfcs#2592 (comment).
@cramertj had the idea to implement an immediately attainable direct coercion between closures and
unsafe fn
pointers rather than go the more complex and contentious route of transitive coercions (which may have unforeseen consequences). This idea seems reasonable to me.cc @nikomatsakis @arielb1
PS: should we fcp the PR once made?
The text was updated successfully, but these errors were encountered: