Initialization by assignment not allowed for "drop-ful" types in constants. #62273
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
A-MIR
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In the following example,
FOO
andASSIGN
are allowed butFOO_ASSIGN
isn't:The reason is that
x = Foo;
is lowered toDropAndReplace
in MIR, and that's not handled in const-checking as aDrop
and an assignment (which it functionally is).cc @davidtwco This might also break the[constant; N]
promotion (while&T
promotion would never encounterDropAndReplace
because&T
is alwaysCopy
).EDIT: nevermind, promotion works based on temporaries, so it shouldn't be affected.
cc @oli-obk @RalfJung @Centril
The text was updated successfully, but these errors were encountered: