fix: enable clippy as_conversions lint across workspace #5577
+122
−59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
clippy::as_conversionslint at the workspace level by updatingCargo.toml.as_conversionsviolations across the workspace by:std::ptr::from_ref/std::ptr::from_mutwhere appropriate (e.g. in
cpu-template-helper).i64::from(),u64::try_from(), andusize::try_from().#[allow(clippy::as_conversions)]in low-level or constcontexts where
asis intentional and required (e.g., enum-to-byteencoding in ACPI AML, seccompiler const fns, and libc constant conversions).
truncation.
cpu-template-helperutils::timeacpi-tables(AML, DSDT, MADT, XSDT)seccompiler(bindings, types, lib)rebase-snapjailer(resource_limits)snapshot-editorfirecracker(main and examples)vmm(library, benches, and tests)Reason
This PR implements the final step of #3161, consolidating several
cast-related Clippy lints into
as_conversionsand fixing all violations.Enabling
as_conversionsensures:#[allow]where they are intentional and unavoidable.RUSTFLAGS="-Dwarnings".ascasts will be flagged consistently.All changes preserve existing behavior while making the code safer and more
explicit about type boundaries.
Verification
Locally ran:
RUSTFLAGS="-Dwarnings" cargo clippy --all --all-targetscargo fmtAll packages build clean with no Clippy warnings.
I was not able to run
tools/devtool checkbuildortools/devtool checkstylebecause
/dev/kvmis not available in my environment.Closes #3161.