dtolnay / dtolnay/thiserror

Allow #[error(transparent)] on fields

Open
#103 1 comment 12 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
5.5k
Forks
213
PR merge metrics
No merged PRs in 30d

Description

The crate I'm currently working on has code like the following:

```rust
#[derive(Debug, Clone, Error)]
pub struct Error {
pub(crate) kind: ErrorKind,
backtrack: Option,
}

#[derive(Debug, Error)]
pub enum ErrorKind {
// error variants go here
}
```

If I understand correctly, this doesn't currently allow the `Error` impl for `Error` to return types from the `ErrorKind` variants, which seems like it would be useful. I thought I might try `#[error(transparent)]` on `Error`'s `kind` field, but that's not allowed. Is there currently a way to support this scenario? From the description of `error(transparent)` it seems like it would be a good fit for this, but maybe there's a good reason not to allow this.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.