diff --git a/pgx-utils/src/sql_entity_graph/pg_extern/argument.rs b/pgx-utils/src/sql_entity_graph/pg_extern/argument.rs index 68190f088..9ee00620c 100644 --- a/pgx-utils/src/sql_entity_graph/pg_extern/argument.rs +++ b/pgx-utils/src/sql_entity_graph/pg_extern/argument.rs @@ -330,16 +330,17 @@ impl ToTokens for Argument { #[derive(Debug, Clone)] pub(crate) struct DefaultMacro { ty: syn::Type, - comma: Token![,], pub(crate) expr: syn::Expr, } impl Parse for DefaultMacro { fn parse(input: ParseStream) -> Result { + let ty = input.parse()?; + let _comma: Token![,] = input.parse()?; + let expr = input.parse()?; Ok(Self { - ty: input.parse()?, - comma: input.parse()?, - expr: input.parse()?, + ty, + expr, }) } } diff --git a/pgx-utils/src/sql_entity_graph/pg_extern/returning.rs b/pgx-utils/src/sql_entity_graph/pg_extern/returning.rs index 6c18b1c45..a38f07ed8 100644 --- a/pgx-utils/src/sql_entity_graph/pg_extern/returning.rs +++ b/pgx-utils/src/sql_entity_graph/pg_extern/returning.rs @@ -275,49 +275,50 @@ impl ToTokens for Returning { #[derive(Debug, Clone)] pub(crate) struct NameMacro { pub(crate) ident: String, - comma: Token![,], pub(crate) ty: syn::Type, } impl Parse for NameMacro { fn parse(input: ParseStream) -> Result { + let ident = input + .parse::() + .map(|v| v.to_string()) + // Avoid making folks unable to use rust keywords. + .or_else(|_| { + input + .parse::() + .map(|_| String::from("type")) + }) + .or_else(|_| { + input + .parse::() + .map(|_| String::from("mod")) + }) + .or_else(|_| { + input + .parse::() + .map(|_| String::from("extern")) + }) + .or_else(|_| { + input + .parse::() + .map(|_| String::from("async")) + }) + .or_else(|_| { + input + .parse::() + .map(|_| String::from("crate")) + }) + .or_else(|_| { + input + .parse::() + .map(|_| String::from("use")) + })?; + let _comma: Token![,] = input.parse()?; + let ty = input.parse()?; Ok(Self { - ident: input - .parse::() - .map(|v| v.to_string()) - // Avoid making folks unable to use rust keywords. - .or_else(|_| { - input - .parse::() - .map(|_| String::from("type")) - }) - .or_else(|_| { - input - .parse::() - .map(|_| String::from("mod")) - }) - .or_else(|_| { - input - .parse::() - .map(|_| String::from("extern")) - }) - .or_else(|_| { - input - .parse::() - .map(|_| String::from("async")) - }) - .or_else(|_| { - input - .parse::() - .map(|_| String::from("crate")) - }) - .or_else(|_| { - input - .parse::() - .map(|_| String::from("use")) - })?, - comma: input.parse()?, - ty: input.parse()?, + ident, + ty, }) } }