-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Error in no_std environments (#268)
Resolves #261 ## Synopsis The `Error` derive can be made to work well for the most part in `no_std` environments by enabling `#![feature(error_in_core)]`. This changes the `Error` derive slightly to import `Error` and related traits from core, when the `std` feature is disabled. In passing this also fixes actually running the nightly error tests. They were not actually run anymore because there was no `build.rs` file in the root of the repo, only in the `impl` package. So the `nightly` config was not available in tests. Co-authored-by: tyranron <[email protected]>
- Loading branch information
Showing
13 changed files
with
84 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[cfg(not(feature = "testing-helpers"))] | ||
fn detect_nightly() {} | ||
|
||
#[cfg(feature = "testing-helpers")] | ||
fn detect_nightly() { | ||
use rustc_version::{version_meta, Channel}; | ||
|
||
if version_meta().unwrap().channel == Channel::Nightly { | ||
println!("cargo:rustc-cfg=nightly"); | ||
} | ||
} | ||
|
||
fn main() { | ||
detect_nightly(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
std='' | ||
if [ "${1:-}" = 'std' ]; then | ||
std=',std' | ||
fi | ||
|
||
set -euxo pipefail | ||
|
||
for feature in $(tomljson Cargo.toml | jq --raw-output '.features | keys[]' | grep -v 'default\|std\|testing-helpers'); do | ||
cargo test -p derive_more --tests --no-default-features --features "$feature,testing-helpers"; | ||
for feature in $(tomljson Cargo.toml | jq --raw-output '.features | keys[]' | grep -v 'default\|std\|full\|testing-helpers'); do | ||
cargo +nightly test -p derive_more --tests --no-default-features --features "$feature$std,testing-helpers" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
#![cfg_attr(nightly, feature(error_generic_member_access, provide_any))] | ||
#![cfg_attr(not(feature = "std"), feature(error_in_core))] | ||
|
||
mod error; |