io: Split cfg(all(...)) into stacked attributes
What changed, and why it matters
This commit is a purely cosmetic change in how Rust conditional compilation rules are written. It splits combined conditions like `cfg(all(A, B))` into two separate stacked `#[cfg(A)]` and `#[cfg(B)]` lines. The actual conditions and the resulting compiled code are unchanged, so there is no security or functional effect.
No security action needed. This is a non-functional style/refactor commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors #[cfg(all(...))] attributes into stacked #[cfg(...)] attributes in io/src/error.rs and io/src/lib.rs. In Rust, multiple #[cfg] attributes on the same item are combined with a logical AND, so this is semantically equivalent to the original cfg(all(...)) form. No logic, feature gating, or public API behavior changes.
Changed components
io/src/error.rsio/src/lib.rsInspect captured patch +14 / −7
diff --git a/io/src/error.rs b/io/src/error.rs
index 3ebde2a4..4cfdd289 100644
--- a/io/src/error.rs
+++ b/io/src/error.rs
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: CC0-1.0
-#[cfg(all(not(feature = "std"), feature = "alloc"))]
+#[cfg(feature = "alloc")]
+#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
use core::fmt;
#[cfg(feature = "std")]
@@ -19,7 +20,8 @@ pub struct Error {
#[cfg(feature = "std")]
error: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
- #[cfg(all(feature = "alloc", not(feature = "std")))]
+ #[cfg(feature = "alloc")]
+ #[cfg(not(feature = "std"))]
error: Option<Box<dyn fmt::Debug + Send + Sync + 'static>>,
}
@@ -34,7 +36,8 @@ impl Error {
}
/// Constructs a new I/O error.
- #[cfg(all(feature = "alloc", not(feature = "std")))]
+ #[cfg(feature = "alloc")]
+ #[cfg(not(feature = "std"))]
pub fn new<E: sealed::IntoBoxDynDebug>(kind: ErrorKind, error: E) -> Self {
Self { kind, _not_unwind_safe: core::marker::PhantomData, error: Some(error.into()) }
}
@@ -49,7 +52,8 @@ impl Error {
}
/// Returns a reference to this error.
- #[cfg(all(feature = "alloc", not(feature = "std")))]
+ #[cfg(feature = "alloc")]
+ #[cfg(not(feature = "std"))]
pub fn get_ref(&self) -> Option<&(dyn fmt::Debug + Send + Sync + 'static)> {
self.error.as_deref()
}
@@ -197,7 +201,8 @@ define_errorkind!(
Other
);
-#[cfg(all(feature = "alloc", not(feature = "std")))]
+#[cfg(feature = "alloc")]
+#[cfg(not(feature = "std"))]
mod sealed {
use alloc::boxed::Box;
use alloc::string::String;
diff --git a/io/src/lib.rs b/io/src/lib.rs
index c38720a7..9d0f223d 100644
--- a/io/src/lib.rs
+++ b/io/src/lib.rs
@@ -38,7 +38,8 @@ mod error;
#[cfg(feature = "hashes")]
mod hash;
-#[cfg(all(not(feature = "std"), feature = "alloc"))]
+#[cfg(feature = "alloc")]
+#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::cmp;
#[cfg(feature = "std")]
@@ -650,7 +651,8 @@ impl<D> From<Error> for ReadError<D> {
#[cfg(test)]
mod tests {
- #[cfg(all(not(feature = "std"), feature = "alloc"))]
+ #[cfg(feature = "alloc")]
+ #[cfg(not(feature = "std"))]
use alloc::{string::ToString, vec};
#[cfg(feature = "std")]
use std::{string::ToString, vec};
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.