You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Initialization by assignment not allowed for "drop-ful" types in constants. #62273
In the following example, FOO and ASSIGN are allowed but FOO_ASSIGN isn't:
pubstructFoo;implDropforFoo{fndrop(&mutself){}}pubconstFOO:Foo = {let x = Foo; x };pubconstASSIGN:i32 = {let x; x = 0; x };pubconstFOO_ASSIGN:Foo = {let x; x = Foo; x };
The reason is that x = Foo; is lowered to DropAndReplace in MIR, and that's not handled in const-checking as a Drop and an assignment (which it functionally is).
cc @davidtwco This might also break the [constant; N] promotion (while &T promotion would never encounter DropAndReplace because &T is always Copy).
EDIT: nevermind, promotion works based on temporaries, so it shouldn't be affected.
Activity
Centril commentedon Jul 1, 2019
I'm going to label this as a bug since it seems covered by #57175 from a T-Lang perspective.
Rollup merge of rust-lang#62275 - eddyb:const-drop-replace, r=pnkfelix