diff --git a/.cirrus.yml b/.cirrus.yml index b171fc8..5968f78 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -100,20 +100,20 @@ stable_no_std_test_task: - cargo build --no-default-features --target thumbv6m-none-eabi before_cache_script: rm -rf $CARGO_HOME/registry/index -nightly_no_std_test_task: - name: "Rust Nightly (no_std)" +rust_1_81_no_std_test_task: + name: "Rust 1.81 (no_std)" container: - image: rustlang/rust:nightly + image: rust:latest cpu: 1 memory: 2Gi cargo_cache: folder: $CARGO_HOME/registry fingerprint_script: cat Cargo.toml setup_script: - - rustup target add thumbv6m-none-eabi --toolchain nightly + - rustup target add thumbv6m-none-eabi core_error_test_script: - rustc --version - - cargo +nightly build --no-default-features --features=unstable-core-error --target thumbv6m-none-eabi + - cargo build --no-default-features --features=rust_1_81 --target thumbv6m-none-eabi before_cache_script: rm -rf $CARGO_HOME/registry/index nightly_test_task: diff --git a/Cargo.toml b/Cargo.toml index 6bac350..6daa39a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,9 @@ rust_1_61 = ["snafu-derive/rust_1_61"] # `Backtrace` was stabilized rust_1_65 = ["rust_1_61"] +# `core::error` was stabilized +rust_1_81 = ["rust_1_65"] + # The backtrace type becomes `backtrace::Backtrace` backtraces-impl-backtrace-crate = ["backtrace"] diff --git a/src/guide/compatibility.md b/src/guide/compatibility.md index ee9ac7a..22550d8 100644 --- a/src/guide/compatibility.md +++ b/src/guide/compatibility.md @@ -46,3 +46,20 @@ the standard library is available and no other backtrace provider is selected. [`Backtrace`]: std::backtrace::Backtrace + +## `rust_1_81` + +
+ +When enabled, SNAFU will assume that it's safe to target features +available in Rust 1.81. Notably, the [`core::error::Error`][] trait is +used instead of [`std::error::Error`][]. diff --git a/src/lib.rs b/src/lib.rs index 8d02fcf..ff93dfa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -338,25 +338,41 @@ generate_guide! { } } -#[cfg(feature = "unstable-core-error")] +#[cfg(any(feature = "rust_1_81", feature = "unstable-core-error"))] #[doc(hidden)] pub use core::error; -#[cfg(feature = "unstable-core-error")] +#[cfg(any(feature = "rust_1_81", feature = "unstable-core-error"))] #[doc(hidden)] pub use core::error::Error; -#[cfg(all(not(feature = "unstable-core-error"), any(feature = "std", test)))] +#[cfg(all( + not(any(feature = "rust_1_81", feature = "unstable-core-error")), + any(feature = "std", test) +))] #[doc(hidden)] pub use std::error; -#[cfg(all(not(feature = "unstable-core-error"), any(feature = "std", test)))] +#[cfg(all( + not(any(feature = "rust_1_81", feature = "unstable-core-error")), + any(feature = "std", test) +))] #[doc(hidden)] pub use std::error::Error; -#[cfg(not(any(feature = "unstable-core-error", feature = "std", test)))] +#[cfg(not(any( + feature = "rust_1_81", + feature = "unstable-core-error", + feature = "std", + test +)))] mod no_std_error; -#[cfg(not(any(feature = "unstable-core-error", feature = "std", test)))] +#[cfg(not(any( + feature = "rust_1_81", + feature = "unstable-core-error", + feature = "std", + test +)))] #[doc(hidden)] pub use no_std_error::Error;