diff options
Diffstat (limited to 'src/pin_project/attribute.rs')
-rw-r--r-- | src/pin_project/attribute.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/pin_project/attribute.rs b/src/pin_project/attribute.rs index 92ed547..c8811cb 100644 --- a/src/pin_project/attribute.rs +++ b/src/pin_project/attribute.rs @@ -17,9 +17,9 @@ use crate::utils::SliceExt; // // At this stage, only attributes are parsed and the following attributes are // added to the attributes of the item. -// * `#[derive(InternalDerive)]` - An internal helper macro that does the above +// - `#[derive(InternalDerive)]` - An internal helper macro that does the above // processing. -// * `#[pin(__private(#args))]` - Pass the argument of `#[pin_project]` to +// - `#[pin(__private(#args))]` - Pass the argument of `#[pin_project]` to // proc-macro-derive (`InternalDerive`). pub(super) fn parse_attribute(args: &TokenStream, input: TokenStream) -> Result<TokenStream> { @@ -51,16 +51,15 @@ impl Parse for Input { if !ahead.peek(Token![struct]) && !ahead.peek(Token![enum]) { // If we check this only on proc-macro-derive, it may generate unhelpful error // messages. So it is preferable to be able to detect it here. - Err(error!( + bail!( input.parse::<TokenStream>()?, "#[pin_project] attribute may only be used on structs or enums" - )) + ); } else if let Some(attr) = attrs.find(PIN) { - Err(error!(attr, "#[pin] attribute may only be used on fields of structs or variants")) + bail!(attr, "#[pin] attribute may only be used on fields of structs or variants"); } else if let Some(attr) = attrs.find("pin_project") { - Err(error!(attr, "duplicate #[pin_project] attribute")) - } else { - Ok(Self { attrs, body: input.parse()? }) + bail!(attr, "duplicate #[pin_project] attribute"); } + Ok(Self { attrs, body: input.parse()? }) } } |