From 8147465350c2a48ef5f65f31c125b032de533d3a Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:21:58 +0000 Subject: [PATCH] Make Xilem Core unconditionally `no_std` (#877) This removes the need to ignore `unused_qualifications`. The `extern crate std` isn't *strictly* needed, but it will make future debugging easier (you can do `println` or `dbg!`, for example). --- xilem_core/src/lib.rs | 6 +++++- xilem_core/src/message.rs | 2 ++ xilem_core/src/views/orphan.rs | 6 ------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xilem_core/src/lib.rs b/xilem_core/src/lib.rs index 5ec218b8..d0fc939c 100644 --- a/xilem_core/src/lib.rs +++ b/xilem_core/src/lib.rs @@ -23,12 +23,16 @@ #![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))] // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![cfg_attr(not(test), no_std)] #![forbid(unsafe_code)] +#![no_std] // TODO: Remove any items listed as "Deferred" #![expect(clippy::allow_attributes_without_reason, reason = "Deferred: Noisy")] extern crate alloc; +// Used only for ad-hoc debugging of tests +#[cfg(test)] +extern crate std; + mod deferred; pub use deferred::{AsyncCtx, MessageProxy, PhantomView, ProxyError, RawProxy}; diff --git a/xilem_core/src/message.rs b/xilem_core/src/message.rs index ff0b071a..b80a270f 100644 --- a/xilem_core/src/message.rs +++ b/xilem_core/src/message.rs @@ -122,6 +122,8 @@ pub trait ViewMessage { #[cfg(test)] mod tests { use alloc::boxed::Box; + use alloc::format; + use alloc::string::{String, ToString}; use core::fmt::Debug; use crate::DynMessage; diff --git a/xilem_core/src/views/orphan.rs b/xilem_core/src/views/orphan.rs index 2ad8d40e..e92684c5 100644 --- a/xilem_core/src/views/orphan.rs +++ b/xilem_core/src/views/orphan.rs @@ -1,12 +1,6 @@ // Copyright 2024 the Xilem Authors // SPDX-License-Identifier: Apache-2.0 -#![allow( - // TODO: Instead of being conditionally no_std, instead conditionally use `extern crate std` - unused_qualifications, - reason = "We have `std` enabled when testing, which means that some items are conditionally in the prelude" -)] - use crate::{ DynMessage, MessageResult, Mut, View, ViewElement, ViewId, ViewMarker, ViewPathTracker, };