Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always declare locals as mutable in derived impls #185

Merged
merged 1 commit into from Apr 28, 2022

Conversation

TedDriggs
Copy link
Owner

Values for fields are kept in local variables prior to construction in
the From* derivations. Before #177, these local variables would be
immutable, since nothing would ever modify them. However, now the
generated code will mutate the local variable to insert the result of
a from_none call to the child. Therefore, for simplicity the variables
are always emitted as mutable.

Fixes #183

@TedDriggs TedDriggs added the bug label Apr 28, 2022
Values for fields are kept in local variables prior to construction in
the `From*` derivations. Before #177, these local variables would be
immutable, since nothing would ever modify them. However, now the
generated code will mutate the local variable to insert the result of
a `from_none` call to the child. Therefore, for simplicity the variables
are always emitted as mutable.

Fixes #183
@TedDriggs TedDriggs merged commit edeeb03 into master Apr 28, 2022
@TedDriggs TedDriggs deleted the no-attrs-still-mutable branch April 28, 2022 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using #[derive(FromDeriveInput)] without #[darling(attributes)] should compile
1 participant