diff --git a/Cargo.toml b/Cargo.toml index 5b2dece..f6221dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,9 @@ exclude = ["images/", "tests/", "miette-derive/"] [dependencies] miette-derive = { path = "miette-derive", version = "=7.6.0", optional = true } -unicode-width = { version = "0.2.0", default-features = false } +unicode-width = "0.2.0" cfg-if = "1.0.0" -# spin is needed for no_std environments (provides Once without std) -spin = { version = "0.9", default-features = false, features = ["once"] } +spin = { version = "0.9", default-features = false, features = ["once"], optional = true } owo-colors = { version = "4.0.0", optional = true } textwrap = { version = "0.16.0", default-features = false, features = ["unicode-linebreak", "unicode-width"], optional = true } diff --git a/src/eyreish/mod.rs b/src/eyreish/mod.rs index 3667b73..c7fb697 100644 --- a/src/eyreish/mod.rs +++ b/src/eyreish/mod.rs @@ -68,7 +68,7 @@ pub type ErrorHook = #[cfg(feature = "std")] static HOOK: OnceLock = OnceLock::new(); -#[cfg(not(feature = "std"))] +#[cfg(all(not(feature = "std"), feature = "spin"))] static HOOK: spin::Once = spin::Once::new(); fn default_hook() -> ErrorHook { @@ -96,7 +96,7 @@ pub fn set_hook(hook: ErrorHook) -> Result<(), InstallError> { } /// Set the error hook. -#[cfg(not(feature = "std"))] +#[cfg(all(not(feature = "std"), feature = "spin"))] pub fn set_hook(hook: ErrorHook) -> Result<(), InstallError> { HOOK.call_once(|| hook); Ok(()) @@ -108,7 +108,7 @@ pub(crate) fn capture_handler(error: &(dyn Diagnostic + 'static)) -> Box Box { let hook = HOOK.call_once(default_hook); hook(error) @@ -126,7 +126,7 @@ pub(crate) fn capture_handler_with_location( } #[track_caller] -#[cfg(not(feature = "std"))] +#[cfg(all(not(feature = "std"), feature = "spin"))] pub(crate) fn capture_handler_with_location( error: &(dyn Diagnostic + 'static), ) -> Box {