thiserror icon indicating copy to clipboard operation
thiserror copied to clipboard

Using `#[from] #[backtrace]` fails to compile

Open segevfiner opened this issue 1 year ago • 2 comments

use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
    #[error("system: {0}")]
    System(#[from] #[backtrace] anyhow::Error),
}
Error
⣿
Errors

Exited with status 101

Standard Error

   Compiling playground v0.0.1 (/playground)
error[[E0432]](https://doc.rust-lang.org/stable/error_codes/E0432.html): unresolved import `thiserror`
   --> src/lib.rs:3:10
    |
3   | #[derive(Error, Debug)]
    |          ^^^^^ no `ThiserrorProvide` in `__private`
    |
note: found an item that was configured out
   --> /playground/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thiserror-1.0.53/src/lib.rs:256:29
    |
256 |     pub use crate::provide::ThiserrorProvide;
    |                             ^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

error[[E0658]](https://doc.rust-lang.org/stable/error_codes/E0658.html): use of unstable library feature 'error_generic_member_access'
 --> src/lib.rs:3:10
  |
3 | #[derive(Error, Debug)]
  |          ^^^^^
  |
  = note: [see issue #99301 <https://github.com/rust-lang/rust/issues/99301>](https://github.com/rust-lang/rust/issues/99301) for more information
  = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

error[[E0599]](https://doc.rust-lang.org/stable/error_codes/E0599.html): no method named `thiserror_provide` found for reference `&anyhow::Error` in the current scope
 --> src/lib.rs:5:13
  |
5 |     #[error("system: {0}")]
  |             ^^^^^^^^^^^^^ method not found in `&Error`

Some errors have detailed explanations: E0432, E0599, E0658.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `playground` (lib) due to 3 previous errors

Playground

segevfiner avatar Jan 18 '24 22:01 segevfiner

Backtraces in the Error trait are nightly only.

dtolnay avatar Jan 18 '24 22:01 dtolnay

Might be nice to include a note in the crate level docs mentioning that.

ShaneMurphy2 avatar Mar 09 '24 03:03 ShaneMurphy2