Skip to content

Coding style modernization to deal with Clippy warnings #1812

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

Merged
merged 6 commits into from
May 31, 2025

Conversation

a4lg
Copy link
Contributor

@a4lg a4lg commented May 30, 2025

In the development of stdarch, we encounter many warnings (mainly from Clippy; currently 133 as counted by Rust Analyzer and 132 as counted by cargo clippy) and hid real warnings we need to take care of.

However, the author found that source of such changes are mainly from old Rust code (which does not know newer coding styles) and decided to deal with it by this PR.

Policy

I allowed clippy::collapsible_if for now (to be reviewed) because it's just nested ifs.
I allowed clippy::obfuscated_if_else because a candidate to fix this issue looked more complex than before.
I allowed clippy::manual_range_contains (as suggested by @Amanieu) because fixing the warning will complicate the code.

Other than that, I mostly used suggestions generated by Clippy.

Further Simplification

In crates/stdarch-gen-arm/src/fn_suffix.rs, I also simplified the code (use a new variable to deal with Clippy warnings and use format!() macro) where no warnings are generated. It makes the code more simple and easier to maintain.

@rustbot
Copy link
Collaborator

rustbot commented May 30, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

a4lg added 6 commits May 31, 2025 05:09
It modernizes the coding style of the crate stdarch-gen-arm by fixing
Clippy warnings (except clippy::{collapsible_if,obfuscated_if_else} that
might make the program look worse as a result of "fixing" warnings).

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 84/84
Note:
Rust Analyzer double counts one of the Clippy warnings so it reduces
85 warnings (as reported by the Rust Analyzer).

This commit also applies similar technique used to resolve Clippy
warnings but also simplifies identifier name formatting and makes
reading easier.

Confirmed that the exact same code will be generated.
It modernizes the coding style of the crate stdarch-gen-loongarch by
fixing Clippy warnings.

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 1/1

Confirmed that the exact same code will be generated (note that,
generated.rs in the repository is *not* an exact output but some spaces
removed).
It modernizes the coding style of the crate stdarch-test by fixing
Clippy warnings.

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 1/1
It modernizes the coding style of the crate stdarch-verify by dealing
with Clippy warnings (allows clippy::collapsible_if but review may be
required for later changes).

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 4/4
It modernizes the coding style of the crate stdarch_examples (an example
"connect5") by fixing Clippy warnings (except clippy::manual_range_contains
in which "fixing" the warning will complicate the code).

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 6/6
It modernizes the coding style of the crate intrinsic-test by fixing
Clippy warnings.

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 36/36
@a4lg a4lg force-pushed the lang-modernize-clippy branch from f30cc42 to 87961c5 Compare May 31, 2025 05:10
@a4lg
Copy link
Contributor Author

a4lg commented May 31, 2025

Updated the PR with all your suggestions plus two similar changes.

@Amanieu Amanieu added this pull request to the merge queue May 31, 2025
Merged via the queue into rust-lang:master with commit 968efab May 31, 2025
62 checks passed
@a4lg a4lg deleted the lang-modernize-clippy branch May 31, 2025 10:31
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