Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante committed Jun 9, 2021
1 parent beb3fdd commit b6852b0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lang/attribute/error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ extern crate proc_macro;

use anchor_syn::codegen::error as error_codegen;
use anchor_syn::parser::error as error_parser;
use anchor_syn::ErrorArgs;
use syn::parse::Parse;
use syn::parse_macro_input;

/// Generates `Error` and `type Result<T> = Result<T, Error>` types to be
Expand Down Expand Up @@ -50,7 +52,10 @@ pub fn error(
args: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let args = syn::parse::<anchor_syn::ErrorArgs as Parse>(args);
let args = match args.is_empty() {
true => None,
false => Some(parse_macro_input!(args as ErrorArgs)),
};
let mut error_enum = parse_macro_input!(input as syn::ItemEnum);
let error = error_codegen::generate(error_parser::parse(&mut error_enum, args));
proc_macro::TokenStream::from(error)
Expand Down

0 comments on commit b6852b0

Please sign in to comment.