From a4d5457771dbc51e8b4c21ce093cfad9a5b74223 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Wed, 5 Jun 2024 11:24:56 -0600 Subject: [PATCH] Use no_std compatible types std::env -> core::option_env --- macros/src/lib.rs | 13 ++++++++++--- src/lib.rs | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c78f9e6..077d10a 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,7 +1,16 @@ // Copyright (C) 2019-2023 Daniel Mueller // SPDX-License-Identifier: (Apache-2.0 OR MIT) +#![no_std] + extern crate proc_macro; +extern crate alloc; + +use alloc::{ + string::String, + vec, + vec::Vec, +}; use proc_macro::TokenStream; use proc_macro2::TokenStream as Tokens; @@ -199,10 +208,8 @@ fn expand_tracing_init(attribute_args: &AttributeArgs) -> Tokens { let __internal_event_filter = { use ::test_log::tracing_subscriber::fmt::format::FmtSpan; - match ::std::env::var_os("RUST_LOG_SPAN_EVENTS") { + match ::core::option_env!("RUST_LOG_SPAN_EVENTS") { Some(mut value) => { - value.make_ascii_lowercase(); - let value = value.to_str().expect("test-log: RUST_LOG_SPAN_EVENTS must be valid UTF-8"); value .split(",") .map(|filter| match filter.trim() { diff --git a/src/lib.rs b/src/lib.rs index 59084b9..51b413a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: (Apache-2.0 OR MIT) #![deny(missing_docs)] +#![no_std] //! A crate providing a replacement #[[macro@test]] attribute that //! initializes logging and/or tracing infrastructure before running