diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6250716..161aecc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,6 +99,20 @@ jobs: MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance run: cargo miri test --all --verbose --features fancy + feature-check: + name: Feature combinations check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + - name: Install cargo-hack + uses: taiki-e/install-action@cargo-hack + - name: Check feature powerset + run: cargo hack check --feature-powerset --no-dev-deps --skip default + minimal_versions: name: Minimal versions check runs-on: ${{ matrix.os }} diff --git a/Cargo.toml b/Cargo.toml index f6221dc..ae6292e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ exclude = ["images/", "tests/", "miette-derive/"] miette-derive = { path = "miette-derive", version = "=7.6.0", optional = true } unicode-width = "0.2.0" cfg-if = "1.0.0" -spin = { version = "0.9", default-features = false, features = ["once"], optional = true } +spin = { version = "0.9", default-features = false, features = ["once"] } 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 c7fb697..3667b73 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(all(not(feature = "std"), feature = "spin"))] +#[cfg(not(feature = "std"))] 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(all(not(feature = "std"), feature = "spin"))] +#[cfg(not(feature = "std"))] 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(all(not(feature = "std"), feature = "spin"))] +#[cfg(not(feature = "std"))] pub(crate) fn capture_handler_with_location( error: &(dyn Diagnostic + 'static), ) -> Box { diff --git a/src/handler.rs b/src/handler.rs index 5ceaa78..21ab0e7 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -352,10 +352,6 @@ impl MietteHandlerOpts { } else if let Some(force_graphical) = self.force_graphical { force_graphical } else { - #[cfg(all(feature = "fancy-no-syscall", not(feature = "fancy-no-backtrace")))] - { - true - } #[cfg(feature = "fancy-no-backtrace")] { if let Ok(env) = std::env::var("NO_GRAPHICS") { @@ -364,6 +360,11 @@ impl MietteHandlerOpts { true } } + #[cfg(not(feature = "fancy-no-backtrace"))] + { + // fancy-base or fancy-no-syscall without std: default to graphical + true + } } } diff --git a/src/lib.rs b/src/lib.rs index dfed8c0..d646ebe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] #![deny(missing_docs, missing_debug_implementations, nonstandard_style)] #![warn(unreachable_pub, rust_2018_idioms)] -#![warn( +#![deny( clippy::alloc_instead_of_core, clippy::std_instead_of_core, clippy::std_instead_of_alloc diff --git a/src/protocol.rs b/src/protocol.rs index f34aa7d..d7e3855 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -731,15 +731,6 @@ impl SourceOffset { .map(|txt| Self::from_location(txt, loc.line() as usize, loc.column() as usize))?, )) } - - /// Returns both the filename that was given and the offset of the caller - /// as a [`SourceOffset`]. - /// - /// In no_std environments, this is not supported and will return an error. - #[cfg(not(feature = "std"))] - pub fn from_current_location() -> Result<(String, Self), MietteError> { - Err(MietteError::OutOfBounds) - } } impl From for SourceOffset {