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

Default::default() makes code unreadable #2630

Closed
garious opened this issue Feb 1, 2019 · 1 comment · Fixed by #31318
Closed

Default::default() makes code unreadable #2630

garious opened this issue Feb 1, 2019 · 1 comment · Fixed by #31318
Labels
good first issue Good for newcomers

Comments

@garious
Copy link
Contributor

garious commented Feb 1, 2019

Problem

Rust offers us this convenient feature of setting any type that implements Default to its default using Default::default(). Unfortunately it makes the code unreadable.

Proposed Solution

Replace most of the 72 instances in current code with an explicit type. For example, if the function accepts a Pubkey, replace Default::default() with Pubkey::default().

@ryoqun
Copy link
Member

ryoqun commented Apr 23, 2023

seems clippy now supports this natively: https://rust-lang.github.io/rust-clippy/v0.0.212/index.html#default_trait_access #31318

steviez pushed a commit to steviez/solana that referenced this issue Aug 20, 2024
- Removes the empty program account check (InvalidAccountData).
- Adjusts checks of program.state.status to conform to error messages.
- Adds check to prevent authority transfer to itself.
- Adjusts most execution errors to UnsupportedProgramId.
- Removes the redundant owner check in execution.
- Adds a tombstone in the program cache upon retraction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants