Skip to content

Commit

Permalink
feat(parser/attr): support #[error(transparent)]
Browse files Browse the repository at this point in the history
  • Loading branch information
onkoe committed Aug 21, 2024
1 parent 9288c08 commit 94699b0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions macros/src/parser/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ use super::field::WrappedFieldInfo;
// #[from] contains a name and type. but that's just a field!
pub type FromAttribute = WrappedFieldInfo;

/// An attribute that describes a specific error variant.
///
/// Can either look like `#[error("some message here")]` or `#[error(transparent)]`
/// for variants with the `#[from]` attribute.
#[derive(Debug)]
pub struct ErrorAttribute {
// TODO(#15): `Option<TokenStream>` if we allow `from` variants to go without a message?
pub format_string: TokenStream,
pub enum ErrorAttribute {
Stringy(TokenStream),
Transparent,
}

impl ErrorAttribute {
pub const TRANSPARENT_LITERAL: &'static str = "transparent";
}

0 comments on commit 94699b0

Please sign in to comment.