-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Initialization by assignment not allowed for "drop-ful" types in constants. #62273
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In the following example,
FOOandASSIGNare allowed butFOO_ASSIGNisn't:The reason is that
x = Foo;is lowered toDropAndReplacein MIR, and that's not handled in const-checking as aDropand an assignment (which it functionally is).cc @davidtwco This might also break the[constant; N]promotion (while&Tpromotion would never encounterDropAndReplacebecause&Tis alwaysCopy).EDIT: nevermind, promotion works based on temporaries, so it shouldn't be affected.
cc @oli-obk @RalfJung @Centril