-
Notifications
You must be signed in to change notification settings - Fork 112
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
Okapi emits warnings when using a closure with no arguments #27
Comments
I was already in the code so took a look.
They are added by okapi/rocket-okapi-codegen/src/lib.rs Line 47 in 9807408
The function: fn preserve_span_information(input: TokenStream) -> TokenStream {
// Outputting the input unmodified would cause its span information to be
// lost when being consumed by other macros. But parsing it in then quoting
// it back out causes span information to be preserved.
// See https://github.com/GREsau/okapi/issues/12
// and https://github.com/rust-lang/rust/issues/43081
let parsed_input: syn::Item = syn::parse(input).unwrap();
// Nested generics cause span bugs - we can work around this by wrapping all
// generic type parameters in parentheses.
// https://github.com/rust-lang/rust/pull/48258
let parsed_input = GenericTypeVisitor.fold_item(parsed_input);
quote!(#parsed_input).into()
} Looking at: #12 there are similar issues there (that you reported 😛 ). I'm not familiar with that issue so will leave this to someone else (@GREsau 😉 ). When commenting out this line I don't have the error anymore 😄 okapi/rocket-okapi-codegen/src/lib.rs Line 31 in 9807408
maybe adding a strategic (btw thanks for mentioning |
Thanks for looking into this - yep, I think |
Actually now that I've taken a closer look, I think the best fix is to just remove the fixes that I added for #12 (which I'm very happy about, since that was a horrible hack!) When I remove |
I don't believe this is necessary in newer nightlies. It also causes its own warnings (#27).
This should be now fixed in v0.5.0 🙂 |
I don't believe this is necessary in newer nightlies. It also causes its own warnings (GREsau#27).
When writing a closure with no arguments, Okapi emits a warning on compilation.
This gives the following result:
I've looked at the emitted code using
cargo expand
, but i couldn't figure out the cause of this warning.The text was updated successfully, but these errors were encountered: