From d330e740087fc536693ab86eebce3fcb831dfc33 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Thu, 28 Mar 2024 20:01:51 +1000 Subject: [PATCH] fix up new lints and warnings --- buffer/src/lib.rs | 6 +++++- buffer/src/value.rs | 2 ++ derive/test/lib.rs | 2 ++ flatten/src/map.rs | 1 - fmt/src/lib.rs | 4 ++-- fmt/src/token_write.rs | 2 ++ .../examples/{stream_simple.rs => stream_nested_simple.rs} | 0 src/lib.rs | 2 +- 8 files changed, 14 insertions(+), 5 deletions(-) rename nested/examples/{stream_simple.rs => stream_nested_simple.rs} (100%) diff --git a/buffer/src/lib.rs b/buffer/src/lib.rs index 62fce9c0..a22d81c8 100644 --- a/buffer/src/lib.rs +++ b/buffer/src/lib.rs @@ -9,18 +9,22 @@ Rather than conditionally compile these methods, this library stubs out functionality when an allocator isn't available. */ -#![cfg_attr(not(test), no_std)] +#![no_std] #![deny(missing_docs)] mod error; #[cfg(feature = "std")] +#[macro_use] +#[allow(unused_imports)] extern crate std as libstd; #[cfg(not(feature = "alloc"))] extern crate core as std; #[cfg(any(test, feature = "alloc"))] +#[macro_use] +#[allow(unused_imports)] extern crate alloc; #[cfg(feature = "alloc")] extern crate core; diff --git a/buffer/src/value.rs b/buffer/src/value.rs index 11352332..dbf78cbf 100644 --- a/buffer/src/value.rs +++ b/buffer/src/value.rs @@ -1790,6 +1790,8 @@ mod tests { mod alloc_tests { use super::*; + use crate::std::string::String; + use sval::Stream as _; use sval_derive_macros::*; diff --git a/derive/test/lib.rs b/derive/test/lib.rs index 8a08a459..f65a5678 100644 --- a/derive/test/lib.rs +++ b/derive/test/lib.rs @@ -501,6 +501,7 @@ mod derive_tuple { #[test] fn skip() { + #[allow(dead_code)] #[derive(Value)] struct Tuple(#[sval(skip)] i32, i32); @@ -1045,6 +1046,7 @@ mod derive_enum { #[test] fn skip() { #[derive(Value)] + #[allow(dead_code)] enum Enum { Record { #[sval(skip)] diff --git a/flatten/src/map.rs b/flatten/src/map.rs index 585a37c2..187ac0e9 100644 --- a/flatten/src/map.rs +++ b/flatten/src/map.rs @@ -357,7 +357,6 @@ impl<'sval, S: Stream<'sval>> Stream<'sval> for PassThru { #[cfg(test)] mod tests { - use alloc::borrow::ToOwned; use sval_derive_macros::*; use super::*; diff --git a/fmt/src/lib.rs b/fmt/src/lib.rs index c964dfed..c79121d6 100644 --- a/fmt/src/lib.rs +++ b/fmt/src/lib.rs @@ -6,10 +6,10 @@ that formats it using the same output that you'd get if you derived [`core::fmt::Debug`]. */ -#![cfg_attr(not(test), no_std)] +#![no_std] #![deny(missing_docs)] -#[cfg(feature = "alloc")] +#[cfg(any(test, feature = "alloc"))] extern crate alloc; mod writer; diff --git a/fmt/src/token_write.rs b/fmt/src/token_write.rs index 0b4143c4..0ad32180 100644 --- a/fmt/src/token_write.rs +++ b/fmt/src/token_write.rs @@ -535,6 +535,8 @@ impl<'a, W: TokenWrite + ?Sized> TokenWrite for &'a mut W { mod tests { use super::*; + use alloc::string::String; + #[test] fn escape_debug() { let cases = [ diff --git a/nested/examples/stream_simple.rs b/nested/examples/stream_nested_simple.rs similarity index 100% rename from nested/examples/stream_simple.rs rename to nested/examples/stream_nested_simple.rs diff --git a/src/lib.rs b/src/lib.rs index c4234725..cd231f04 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,7 +79,7 @@ The [`Value`] and [`Stream`] traits aren't object-safe themselves, but object-sa wrappers are provided by the `sval_dynamic` crate. This wrapper works in no-std. */ -#![cfg_attr(not(test), no_std)] +#![no_std] #![deny(missing_docs)] #[cfg(feature = "std")]