mirror of https://github.com/zkat/miette.git
fix: make spin dependency optional for std builds
- spin is now optional, only needed for no_std (provides Once) - std builds use OnceLock, avoiding unnecessary dependency - Restore unicode-width default features (keeps CJK support)
This commit is contained in:
parent
c07cab4b60
commit
c5ddfdc0be
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ pub type ErrorHook =
|
|||
#[cfg(feature = "std")]
|
||||
static HOOK: OnceLock<ErrorHook> = OnceLock::new();
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[cfg(all(not(feature = "std"), feature = "spin"))]
|
||||
static HOOK: spin::Once<ErrorHook> = 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<dyn Rep
|
|||
hook(error)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[cfg(all(not(feature = "std"), feature = "spin"))]
|
||||
pub(crate) fn capture_handler(error: &(dyn Diagnostic + 'static)) -> Box<dyn ReportHandler> {
|
||||
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<dyn ReportHandler> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue