-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking issue for unsizing casts in const fns #64992
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-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-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-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.
Right now we don't allow unsizing casts (array -> slice or type -> dyn Trait) in const fns on stable.
While we can't allow unsizing to
dyn Traituntil we've figured out trait bounds in const fns, we can easily allow unsizing casts for slices, there's no reason not to have them. The only reason we didn't have them in the initial min_const_fn feature gate was the fact that we preferred overly aggressive rules over accidental stabilization.The relevant code is
rust/src/librustc_mir/transform/qualify_min_const_fn.rs
Lines 162 to 165 in dc45735
We need to check the destination and source types for slice and array respectively and permit the cast in that case. We also need to recurse with
check_operandon the value that is being casted.