Replacing a parameter declared as mut a
with let mut a = a;
causes program to no longer compile
#31723
Labels
A-destructors
Area: Destructors (`Drop`, …)
This may very well be a dupe of #31439, but it manifests somewhat differently and may shed light on the potential fix. Probably still worth having a test case for anyway.
Take this program, which compiles:
Now, instead of declaring the parameter as
mut a
, declare it as immutable and rebind it as mutable in the body of the function, which is supposed to be semantically equivalent. This results in a compiler error:As in #31439, replacing the implicit return with an explicit return also allows the program to compile.
The text was updated successfully, but these errors were encountered: