From 71c7ebec0ed3dd891f78bfe5cd9d9c3a616bab78 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 28 Aug 2021 14:12:47 -0700 Subject: [PATCH] Update documentation of source-backtrace behavior --- README.md | 6 +++--- src/lib.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 101a522..e12b693 100644 --- a/README.md +++ b/README.md @@ -137,14 +137,14 @@ pub enum DataStoreError { } ``` -- If a field is `#[from]` and `#[backtrace]`, the Error trait's `backtrace()` - method is forwarded to the `source`. +- If a field is both a source (named `source`, or has `#[source]` or `#[from]` + attribute) *and* is marked `#[backtrace]`, then the Error trait's + `backtrace()` method is forwarded to the source's backtrace. ```rust #[derive(Error, Debug)] pub enum MyError { Io { - #[from] #[backtrace] source: io::Error, }, diff --git a/src/lib.rs b/src/lib.rs index a1416c0..2fae25c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -161,15 +161,15 @@ //! # }; //! ``` //! -//! - If a field is `#[from]` and `#[backtrace]`, the Error trait's -//! `backtrace()` method is forwarded to the field. +//! - If a field is both a source (named `source`, or has `#[source]` or +//! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error +//! trait's `backtrace()` method is forwarded to the source's backtrace. //! //! ```rust //! # const IGNORE: &str = stringify! { //! #[derive(Error, Debug)] //! pub enum MyError { //! Io { -//! #[from] //! #[backtrace] //! source: io::Error, //! },