Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
segevfiner opened this issue Jan 18, 2024 · 2 comments · Fixed by #312
Closed

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

segevfiner opened this issue Jan 18, 2024 · 2 comments · Fixed by #312

Comments

@segevfiner
Copy link

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

@dtolnay
Copy link
Owner

dtolnay commented Jan 18, 2024

Backtraces in the Error trait are nightly only.

@ShaneMurphy2
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants