Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit warnings in #[function] macro expansion when invalid arguments used #73

Open
hiltontj opened this issue Jan 6, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@hiltontj
Copy link
Owner

hiltontj commented Jan 6, 2024

This is a follow on for #69 to cover the one TODO that was not cleaned up by #72.

The TODO can be found here:

impl Parse for FunctionMacroArgs {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
let mut args = Self::default();
while !input.is_empty() {
let lookahead = input.lookahead1();
if lookahead.peek(kw::name) {
if args.name.is_some() {
return Err(input.error("expected only a single `name` argument"));
}
let name = input.parse::<StrArg<kw::name>>()?.value;
args.name = Some(name);
} else {
// TODO - may want to warn here when found a invalid arg - see how
// tracing::instrument stores warnings and emits them later when generating the
// expanded token stream.
let _ = input.parse::<proc_macro2::TokenTree>();
}
}
Ok(args)
}
}

I believe that if unsupported arguments are passed to the #[function] macro, it will just ignore them, but should instead emit compiler warnings.

@hiltontj hiltontj added enhancement New feature or request good first issue Good for newcomers labels Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant