1- #[ cfg( nightly) ]
2- use core:: any:: Demand ;
3- #[ cfg( nightly) ]
4- use core:: error:: Error ;
51use core:: fmt;
2+ #[ cfg( nightly) ]
3+ use core:: { any:: Demand , error:: Error } ;
64#[ cfg( all( not( nightly) , feature = "std" ) ) ]
75use std:: error:: Error ;
86
@@ -13,14 +11,11 @@ use crate::Report;
1311/// When in a `std` environment or on a nightly toolchain, every [`Error`] is a valid `Context`.
1412/// This trait is not limited to [`Error`]s and can also be manually implemented on a type.
1513///
16- /// [`Error`]: core::error::Error
17- ///
1814/// ## Example
1915///
2016/// Used for creating a [`Report`] or for switching the [`Report`]'s context:
2117///
2218/// ```rust
23- /// # #![cfg_attr(any(not(feature = "std"), miri), allow(unused_imports))]
2419/// use std::{fmt, fs, io};
2520///
2621/// use error_stack::{Context, Result, ResultExt, Report};
@@ -32,7 +27,7 @@ use crate::Report;
3227/// }
3328///
3429/// impl fmt::Display for ConfigError {
35- /// # #[allow(unused_variables)]
30+ /// # #[allow(unused_variables)] // `fmt` is not used in this example
3631/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
3732/// # const _: &str = stringify! {
3833/// ...
@@ -44,9 +39,6 @@ use crate::Report;
4439/// // `Context` manually.
4540/// impl Context for ConfigError {}
4641///
47- /// # #[cfg(any(not(feature = "std"), miri))]
48- /// # pub fn read_file(_: &str) -> Result<String, ConfigError> { error_stack::bail!(ConfigError::ParseError) }
49- /// # #[cfg(all(feature = "std", not(miri)))]
5042/// pub fn read_file(path: &str) -> Result<String, io::Error> {
5143/// // Creates a `Report` from `io::Error`, the current context is `io::Error`
5244/// fs::read_to_string(path).map_err(Report::from)
@@ -62,7 +54,6 @@ use crate::Report;
6254/// # }; Ok(())
6355/// }
6456/// # let err = parse_config("invalid-path").unwrap_err();
65- /// # #[cfg(all(feature = "std", not(miri)))]
6657/// # assert!(err.contains::<io::Error>());
6758/// # assert!(err.contains::<ConfigError>());
6859/// ```
0 commit comments