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

Remove need for Copy on error enums #1292

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Remove need for Copy on error enums #1292

wants to merge 10 commits into from

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Jul 11, 2024

What

Remove need for Copy/Clone/etc on error enums and int enums.

Why

Less compiler errors for folks just getting started.

The generated code currently requires that error enums impl the Copy trait because they use a copy within. That copy is unnecessary and this change removes it, removing the need for Copy to be derived on error enums.

I was confident that the copy had been put there as an optimisation, but when I looked into the code that was relying on it I found not optimisation was in use. When I tried to add the optimisation, I couldn't find a contract size difference.

A while ago we in #1293 added better error messages for needing copy, which was a good fix at the time, I just think we can remove the need for this all together.

Close #630

@leighmcculloch leighmcculloch changed the title Remove need for Copy/Clone/etc on error enums Remove need for Copy on error enums Jul 11, 2024
@leighmcculloch leighmcculloch marked this pull request as ready for review July 11, 2024 05:22
@leighmcculloch leighmcculloch deleted the i630 branch July 11, 2024 06:26
Comment on lines -147 to +148
Ok((*self as u32).into())
Ok(match self {
#(#try_intos,)*
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This optimisation doesn't matter, it's in testutils, it doesn't impact wasm builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a clear error message for when an integer enum doesn't have derive(Copy)
2 participants