From fc3414f9d2bd78084e5b85d538b8ab6b586f1f77 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Tue, 27 Feb 2024 16:40:23 -0500 Subject: [PATCH] lib: clean up no_std and use of std in test code Like we just did in Rustls and webpki, _always_ opt-in to no_std, and then import the std prelude in tests where necessary. This resolves some nightly clippy warnings about redundant imports that will arise otherwise --- src/lib.rs | 4 ++-- src/tests.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1cdd426..6471dd0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,10 +49,10 @@ unused_extern_crates, unused_qualifications )] -#![cfg_attr(not(test), no_std)] +#![no_std] extern crate alloc; -#[cfg(all(feature = "std", not(test)))] +#[cfg(any(feature = "std", test))] extern crate std; #[cfg(test)] diff --git a/src/tests.rs b/src/tests.rs index 3c32998..290f89b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,5 +1,8 @@ #[cfg(test)] mod unit { + use alloc::{format, vec}; + use std::prelude::v1::*; + use crate::{Error, Item}; #[test]