-
-
Notifications
You must be signed in to change notification settings - Fork 203
Closed
Description
I find that I write
#[derive(thiserror::Error)]
#[error("{}: {}", self, .0)
Foo {
Bar(#[from] inner::Error),
...
}by accident very often.
By writing this, what I intended is for Foo::Bar(inner::Error) to be formatted into a string as "Bar: <display impl for inner::Error>". But that's not what self means. Instead what happens is this code attempts to format self using itself, leading to unconstrained recursion and a stack overflow.
What's problematic about this is there's no indication of the mistake I'm making during compile time or even linting. I'm not sure how this crate could 'fix' this, but I'm curious why self is even allowed to be used in the #[error(...)] macro.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels