Skip to content

[DRAFT] Modernization of coding styles through fixing Clippy warnings #1808

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

Closed
wants to merge 8 commits into from

Conversation

a4lg
Copy link
Contributor

@a4lg a4lg commented May 28, 2025

In the development of stdarch, we encounter many warnings (mainly from Clippy; currently 133 as counted by Rust Analyzer) 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 (currently, it reduces number of warnings from 133 to 1).

I found two possible issues inside intrinsic-test crate but the author is not sure whether they are true bugs. That's why the author is making this PR a draft (for now) to experiment with bug fixes.

Note: number of fixed warnings in each commit message does not match to numbers above (133 → 1) because in the commit message, cargo clippy is used (instead of Rust Analyzer) to test for warnings.

@a4lg a4lg force-pushed the lang-modernize-clippy-draft branch 2 times, most recently from dd7c8be to a340845 Compare May 29, 2025 06:04
@a4lg
Copy link
Contributor Author

a4lg commented May 29, 2025

Seems CI is failing for a reason unrelated to our side? I'll wait for several hours and retry with new commits.

a4lg added 8 commits May 29, 2025 08:20
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.

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 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 intrinsic-test by fixing
Clippy warnings.

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

**EXPERIMENTAL**
While the author is making this commit, the author found two possible
bugs.  They are being investigated and this commit is written so that
no functional changes will occur.
Check whether c_prefix is okay.
If this succeeds, this is incorporated as a separate bug fix.
If this fails, c_prefix must be removed and replaced with rust_prefix.
…ition

It seems it returns true when *no* constraints are found, opposite to
the expected behavior of the function name.

This commit reverses condition to test whether this is a real bug or not.
@a4lg a4lg force-pushed the lang-modernize-clippy-draft branch from a340845 to cc2b5e9 Compare May 29, 2025 11:42
@a4lg a4lg closed this May 30, 2025
@a4lg a4lg deleted the lang-modernize-clippy-draft branch May 30, 2025 02:27
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.

1 participant