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 all if_chain! macros #9353

Closed
nyurik opened this issue Aug 20, 2022 · 2 comments · Fixed by #11750
Closed

Remove all if_chain! macros #9353

nyurik opened this issue Aug 20, 2022 · 2 comments · Fixed by #11750

Comments

@nyurik
Copy link
Contributor

nyurik commented Aug 20, 2022

Description

Current Clippy code has a lot of legacy if_chain! macros even though the nightly if let chains is already in use. I would like to remove all if_chain! macro usage, replacing it with the regular if statement, unless of course there is any reason to avoid that?

One thing to note is that cargo fmt still hasn't been decided (see rfc) on how to handle it, and doesn't seem likely to be decided soon. This is not a blocker, as the code can always be reformatted later.

Possible Lint?

P.S. I just realized that this might be a good automated lint because it would be useful to other existing code as well. See #9354

@schubart
Copy link
Contributor

schubart commented Aug 31, 2022

#[clippy::author] should probably also be updated to produce if let chains instead of if_chain!.

This utility (recommended by the Clippy Book) still produces code that uses if_chain!, so new lint developers are still being steered towards this old style.

@xFrednet
Copy link
Member

xFrednet commented Sep 1, 2022

There have been multiple discussions about it on Zulip and in PRs (See https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/removing.20if_chain.20dependency/near/292061902). The consensus is, that we want to move to if let chains but until rustfmt supports their formatting we'll not convert our codebase. There are already some tools to automatically migrate from if_chain! to let chains.

Updating the documentation is a good point :)

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 a pull request may close this issue.

3 participants