-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Direct coercion from closures to unsafe fn pointers #57883
Copy link
Copy link
Closed
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-inferenceArea: Type inferenceArea: Type inferenceA-type-systemArea: Type systemArea: Type systemC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-inferenceArea: Type inferenceArea: Type inferenceA-type-systemArea: Type systemArea: Type systemC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
While you can coerce closures to
fnpointers, it is currently not possible to coerce closures tounsafe fnpointers since that requires a transitive coercion fromfnpointers tounsafe fnpointers. 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 fnpointers 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?