You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm the author of the enum_dispatch procedural macro. Recently I added better support for generic parameters, but in some cases specifying them explicitly produces warnings like the following:
warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> examples/late_dispatch.rs:11:1
|
6 | fn foo<'a>(&mut self) -> &'a u32 {
| - the late bound lifetime parameter is introduced here
...
11 | #[enum_dispatch(FooAPI)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(late_bound_lifetime_arguments)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
= note: this warning originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
The warning appears due to an explicitly specified lifetime parameter in the generated code:
The explicit specification is useful in general, but begins causing issues when late-bound lifetime parameters are present in a method's signature (as they are here).
According to the linked issue, the recommendation is "Just removing the lifetime arguments pointed to by the lint". That's not an option in a procedural macro, which doesn't get to look at compiler warnings. That means I need some way to check if there are any late-bound lifetime parameters in a function signature when I'm generating its implementation.
What I'm proposing is something along the lines of syn::Signature::has_late_bound_lifetimes(&self) -> bool. The rules for determining early/late bound lifetimes are fairly complex, which is why I figure it would be nice to have a single canonical implementation in syn that is available to any procedural macro author.
I'm the author of the
enum_dispatch
procedural macro. Recently I added better support for generic parameters, but in some cases specifying them explicitly produces warnings like the following:The warning appears due to an explicitly specified lifetime parameter in the generated code:
The explicit specification is useful in general, but begins causing issues when late-bound lifetime parameters are present in a method's signature (as they are here).
According to the linked issue, the recommendation is "Just removing the lifetime arguments pointed to by the lint". That's not an option in a procedural macro, which doesn't get to look at compiler warnings. That means I need some way to check if there are any late-bound lifetime parameters in a function signature when I'm generating its implementation.
What I'm proposing is something along the lines of
syn::Signature::has_late_bound_lifetimes(&self) -> bool
. The rules for determining early/late bound lifetimes are fairly complex, which is why I figure it would be nice to have a single canonical implementation insyn
that is available to any procedural macro author.More context: https://gitlab.com/antonok/enum_dispatch/-/issues/34
The text was updated successfully, but these errors were encountered: