diff --git a/src/api_server/src/lib.rs b/src/api_server/src/lib.rs index 8dc929ed09fb..87c9e5868ebb 100644 --- a/src/api_server/src/lib.rs +++ b/src/api_server/src/lib.rs @@ -3,6 +3,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Implements the interface for intercepting API requests, forwarding them to the VMM //! and responding to the user. //! It is constructed on top of an HTTP Server that uses Unix Domain Sockets and `EPOLL` to diff --git a/src/arch/src/lib.rs b/src/arch/src/lib.rs index 0fe2c6c371ea..828ccd6997c6 100644 --- a/src/arch/src/lib.rs +++ b/src/arch/src/lib.rs @@ -3,6 +3,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Implements platform specific functionality. //! Supported platforms: x86_64 and aarch64. use std::{fmt, result}; diff --git a/src/cpuid/src/lib.rs b/src/cpuid/src/lib.rs index b7af7d404513..78b978de5a91 100644 --- a/src/cpuid/src/lib.rs +++ b/src/cpuid/src/lib.rs @@ -7,6 +7,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Utility for configuring the CPUID (CPU identification) for the guest microVM. #![cfg(target_arch = "x86_64")] diff --git a/src/devices/src/lib.rs b/src/devices/src/lib.rs index 72db8b292a03..408f4261dd20 100644 --- a/src/devices/src/lib.rs +++ b/src/devices/src/lib.rs @@ -6,6 +6,7 @@ // found in the THIRD-PARTY file. #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Emulates virtual and hardware devices. use std::io; diff --git a/src/dumbo/src/lib.rs b/src/dumbo/src/lib.rs index e737990abd8e..8796efa48d12 100644 --- a/src/dumbo/src/lib.rs +++ b/src/dumbo/src/lib.rs @@ -3,6 +3,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Provides helper logic for parsing and writing protocol data units, and minimalist //! implementations of a TCP listener, a TCP connection, and an HTTP/1.1 server. pub mod pdu; diff --git a/src/firecracker/src/main.rs b/src/firecracker/src/main.rs index 8d06d52a6b3a..dcce45417f21 100644 --- a/src/firecracker/src/main.rs +++ b/src/firecracker/src/main.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] mod api_server_adapter; mod metrics; diff --git a/src/io_uring/src/lib.rs b/src/io_uring/src/lib.rs index 02338d0cd128..bbc73829353c 100644 --- a/src/io_uring/src/lib.rs +++ b/src/io_uring/src/lib.rs @@ -3,6 +3,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! High-level interface over Linux io_uring. //! //! Aims to provide an easy-to-use interface, while making some Firecracker-specific simplifying diff --git a/src/jailer/src/main.rs b/src/jailer/src/main.rs index dfeb6bf631e2..eacb34cbe451 100644 --- a/src/jailer/src/main.rs +++ b/src/jailer/src/main.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] mod cgroup; mod chroot; diff --git a/src/logger/src/lib.rs b/src/logger/src/lib.rs index 038ad7ed8952..2044a86dac93 100644 --- a/src/logger/src/lib.rs +++ b/src/logger/src/lib.rs @@ -3,6 +3,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Crate that implements Firecracker specific functionality as far as logging and metrics //! collecting. diff --git a/src/mmds/src/lib.rs b/src/mmds/src/lib.rs index 48efaeedaa84..c97ee4e87c43 100644 --- a/src/mmds/src/lib.rs +++ b/src/mmds/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] pub mod data_store; pub mod ns; diff --git a/src/rate_limiter/src/lib.rs b/src/rate_limiter/src/lib.rs index d0930b900982..a7d6cc0ee93a 100644 --- a/src/rate_limiter/src/lib.rs +++ b/src/rate_limiter/src/lib.rs @@ -3,6 +3,7 @@ #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! # Rate Limiter //! //! Provides a rate limiter written in Rust useful for IO operations that need to diff --git a/src/rebase-snap/src/main.rs b/src/rebase-snap/src/main.rs index 61163a555ab3..0d96b4b2a476 100644 --- a/src/rebase-snap/src/main.rs +++ b/src/rebase-snap/src/main.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] use std::fs::{File, OpenOptions}; use std::io::{Seek, SeekFrom}; diff --git a/src/seccompiler/src/lib.rs b/src/seccompiler/src/lib.rs index 40f4a6da33dc..581f52b15181 100644 --- a/src/seccompiler/src/lib.rs +++ b/src/seccompiler/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! The library crate that defines common helper functions that are generally used in //! conjunction with seccompiler-bin. diff --git a/src/snapshot/src/lib.rs b/src/snapshot/src/lib.rs index 4d191df3a6b4..d58600ffd53c 100644 --- a/src/snapshot/src/lib.rs +++ b/src/snapshot/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![deny(missing_docs)] #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] //! Provides version tolerant serialization and deserialization facilities and //! implements a persistent storage format for Firecracker state snapshots. diff --git a/src/utils/src/lib.rs b/src/utils/src/lib.rs index ccdadd512544..01f54c5080e2 100644 --- a/src/utils/src/lib.rs +++ b/src/utils/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![warn(clippy::ptr_as_ptr)] +#![warn(clippy::cast_lossless)] // We use `utils` as a wrapper over `vmm_sys_util` to control the latter // dependency easier (i.e. update only in one place `vmm_sys_util` version). diff --git a/tests/integration_tests/build/test_clippy.py b/tests/integration_tests/build/test_clippy.py index 279c1c5800d6..e185cf3a4024 100644 --- a/tests/integration_tests/build/test_clippy.py +++ b/tests/integration_tests/build/test_clippy.py @@ -23,6 +23,5 @@ def test_rust_clippy(target): @type: build """ utils.run_cmd( - "cargo clippy --target {} --all --profile test" - " -- -D warnings -D clippy::cast_lossless".format(target) + "cargo clippy --target {} --all --profile test" " -- -D warnings".format(target) )