mirror of https://github.com/zkat/miette.git
fix: address review feedback and add feature powerset CI
- Make spin a required dependency for no_std hook support (OnceLock unavailable) - Simplify cfg guards: not(std) instead of not(std) && spin - Change clippy alloc/std lints from warn to deny - Remove no_std stub for from_current_location (compile-time vs runtime error) - Fix is_graphical cfg logic for fancy-base without fancy-no-backtrace - Add cargo-hack feature powerset CI job to verify all 56 combinations
This commit is contained in:
parent
c5ddfdc0be
commit
f346d78d21
|
|
@ -99,6 +99,20 @@ jobs:
|
||||||
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
|
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
|
||||||
run: cargo miri test --all --verbose --features fancy
|
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:
|
minimal_versions:
|
||||||
name: Minimal versions check
|
name: Minimal versions check
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ exclude = ["images/", "tests/", "miette-derive/"]
|
||||||
miette-derive = { path = "miette-derive", version = "=7.6.0", optional = true }
|
miette-derive = { path = "miette-derive", version = "=7.6.0", optional = true }
|
||||||
unicode-width = "0.2.0"
|
unicode-width = "0.2.0"
|
||||||
cfg-if = "1.0.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 }
|
owo-colors = { version = "4.0.0", optional = true }
|
||||||
textwrap = { version = "0.16.0", default-features = false, features = ["unicode-linebreak", "unicode-width"], 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")]
|
#[cfg(feature = "std")]
|
||||||
static HOOK: OnceLock<ErrorHook> = OnceLock::new();
|
static HOOK: OnceLock<ErrorHook> = OnceLock::new();
|
||||||
|
|
||||||
#[cfg(all(not(feature = "std"), feature = "spin"))]
|
#[cfg(not(feature = "std"))]
|
||||||
static HOOK: spin::Once<ErrorHook> = spin::Once::new();
|
static HOOK: spin::Once<ErrorHook> = spin::Once::new();
|
||||||
|
|
||||||
fn default_hook() -> ErrorHook {
|
fn default_hook() -> ErrorHook {
|
||||||
|
|
@ -96,7 +96,7 @@ pub fn set_hook(hook: ErrorHook) -> Result<(), InstallError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the error hook.
|
/// Set the error hook.
|
||||||
#[cfg(all(not(feature = "std"), feature = "spin"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub fn set_hook(hook: ErrorHook) -> Result<(), InstallError> {
|
pub fn set_hook(hook: ErrorHook) -> Result<(), InstallError> {
|
||||||
HOOK.call_once(|| hook);
|
HOOK.call_once(|| hook);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -108,7 +108,7 @@ pub(crate) fn capture_handler(error: &(dyn Diagnostic + 'static)) -> Box<dyn Rep
|
||||||
hook(error)
|
hook(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(feature = "std"), feature = "spin"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub(crate) fn capture_handler(error: &(dyn Diagnostic + 'static)) -> Box<dyn ReportHandler> {
|
pub(crate) fn capture_handler(error: &(dyn Diagnostic + 'static)) -> Box<dyn ReportHandler> {
|
||||||
let hook = HOOK.call_once(default_hook);
|
let hook = HOOK.call_once(default_hook);
|
||||||
hook(error)
|
hook(error)
|
||||||
|
|
@ -126,7 +126,7 @@ pub(crate) fn capture_handler_with_location(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
#[cfg(all(not(feature = "std"), feature = "spin"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub(crate) fn capture_handler_with_location(
|
pub(crate) fn capture_handler_with_location(
|
||||||
error: &(dyn Diagnostic + 'static),
|
error: &(dyn Diagnostic + 'static),
|
||||||
) -> Box<dyn ReportHandler> {
|
) -> Box<dyn ReportHandler> {
|
||||||
|
|
|
||||||
|
|
@ -352,10 +352,6 @@ impl MietteHandlerOpts {
|
||||||
} else if let Some(force_graphical) = self.force_graphical {
|
} else if let Some(force_graphical) = self.force_graphical {
|
||||||
force_graphical
|
force_graphical
|
||||||
} else {
|
} else {
|
||||||
#[cfg(all(feature = "fancy-no-syscall", not(feature = "fancy-no-backtrace")))]
|
|
||||||
{
|
|
||||||
true
|
|
||||||
}
|
|
||||||
#[cfg(feature = "fancy-no-backtrace")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
{
|
{
|
||||||
if let Ok(env) = std::env::var("NO_GRAPHICS") {
|
if let Ok(env) = std::env::var("NO_GRAPHICS") {
|
||||||
|
|
@ -364,6 +360,11 @@ impl MietteHandlerOpts {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(not(feature = "fancy-no-backtrace"))]
|
||||||
|
{
|
||||||
|
// fancy-base or fancy-no-syscall without std: default to graphical
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![deny(missing_docs, missing_debug_implementations, nonstandard_style)]
|
#![deny(missing_docs, missing_debug_implementations, nonstandard_style)]
|
||||||
#![warn(unreachable_pub, rust_2018_idioms)]
|
#![warn(unreachable_pub, rust_2018_idioms)]
|
||||||
#![warn(
|
#![deny(
|
||||||
clippy::alloc_instead_of_core,
|
clippy::alloc_instead_of_core,
|
||||||
clippy::std_instead_of_core,
|
clippy::std_instead_of_core,
|
||||||
clippy::std_instead_of_alloc
|
clippy::std_instead_of_alloc
|
||||||
|
|
|
||||||
|
|
@ -731,15 +731,6 @@ impl SourceOffset {
|
||||||
.map(|txt| Self::from_location(txt, loc.line() as usize, loc.column() as usize))?,
|
.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<ByteOffset> for SourceOffset {
|
impl From<ByteOffset> for SourceOffset {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue