From 8c3ea0c59ad828d65cd71a0f7a87e3cb688b6be2 Mon Sep 17 00:00:00 2001 From: RAprogramm Date: Wed, 29 Oct 2025 09:44:43 +0700 Subject: [PATCH] #326 fix: add missing alloc imports for no_std compatibility Add missing imports from alloc crate when std feature is disabled: - String in builder.rs (lines 126, 416) - Box in introspection.rs (line 238) - ToString in display.rs (line 391) Also add CI check for no_std builds to prevent future regressions. Fixes #326 --- .github/workflows/ci.yml | 22 +++++++++++++++++++++- src/app_error/core/builder.rs | 2 +- src/app_error/core/display.rs | 1 + src/app_error/core/introspection.rs | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3729db..4b89c9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,28 @@ jobs: all-features: true secrets: inherit + no-std: + name: no_std compatibility + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Install Rust (stable) + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + with: + shared-key: no-std + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Check no_std build + run: cargo check --no-default-features + update-changelog: - needs: ci + needs: [ci, no-std] uses: ./.github/workflows/reusable-changelog.yml secrets: GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/src/app_error/core/builder.rs b/src/app_error/core/builder.rs index 8af5337..299463a 100644 --- a/src/app_error/core/builder.rs +++ b/src/app_error/core/builder.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT -use alloc::{borrow::Cow, sync::Arc}; +use alloc::{borrow::Cow, string::String, sync::Arc}; use core::error::Error as CoreError; #[cfg(feature = "backtrace")] use std::backtrace::Backtrace; diff --git a/src/app_error/core/display.rs b/src/app_error/core/display.rs index 652f374..f12b92c 100644 --- a/src/app_error/core/display.rs +++ b/src/app_error/core/display.rs @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: MIT +use alloc::string::ToString; use core::{ error::Error as CoreError, fmt::{Formatter, Result as FmtResult}, diff --git a/src/app_error/core/introspection.rs b/src/app_error/core/introspection.rs index 39ea124..67e29c6 100644 --- a/src/app_error/core/introspection.rs +++ b/src/app_error/core/introspection.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT -use alloc::borrow::Cow; +use alloc::{borrow::Cow, boxed::Box}; use core::error::Error as CoreError; #[cfg(feature = "backtrace")]