Skip to content

Unable to get #[from] + backtrace example to compile #257

@metasim

Description

@metasim

I have a use case where this example from the README is exactly what I need:

#[derive(Error, Debug)]
pub enum MyError {
    Io {
        #[from]
        source: io::Error,
        backtrace: Backtrace,
    },
}

However, when I compile it (Rust Playground link) I get the following error:

no `ThiserrorProvide` in `__private`
   Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `thiserror`
   --> src/lib.rs:5:10
    |
5   | #[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.48/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]: use of unstable library feature 'error_generic_member_access'
--> src/lib.rs:5:10
|
5 | #[derive(Error, Debug)]
| ^^^^^
|
= note: see issue #99301 rust-lang/rust#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[E0277]: MyError doesn't implement std::fmt::Display
--> src/lib.rs:6:10
|
6 | pub enum MyError {
| ^^^^^^^ MyError cannot be formatted with the default formatter
|
= help: the trait std::fmt::Display is not implemented for MyError
= note: in format strings you may be able to use {:?} (or {:#?} for pretty-print) instead
note: required by a bound in std::error::Error
--> /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/error.rs:32:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions