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

Emit unwrap_or_default when appropriate for default fields #292

Closed

Conversation

novafacing
Copy link

Clippy has recently started emitting error messages like:

warning: if let can be simplified with `.unwrap_or_default()`
  --> simics-macro/src/init/mod.rs:16:15
   |
16 |     #[darling(default)]
   |               ^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
help: replace it with
   |
16 ~     #[darling(default)]
17 +     /// The name of the module, used in the `MOD:NAME` expression
18 ~     pub name.unwrap_or_default())]

This PR just uses unwrap_or_default as Clippy wants and the error message goes away.

@TedDriggs
Copy link
Owner

@novafacing it appears that this change has broken one of the compile tests. I'm not thrilled with the change in the compiler diagnostic - maybe adding an #[allow(clippy::...)] is the better move?

@novafacing
Copy link
Author

That works for me, I don't really like this diagnostic either. I updated the PR to just add that allow, if you're cool with that.

@martin-g
Copy link

Related to rust-lang/rust-clippy#12643

@TedDriggs
Copy link
Owner

TedDriggs commented Jul 9, 2024

This is being superseded by #296, which puts the allow on the generated trait impl rather than trying to hunt down each place where it appears.

@TedDriggs TedDriggs closed this Jul 9, 2024
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.

3 participants