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
{{ message }}
Repository navigation
E0726 makes invalid mid-keyword suggestion with proc-macro derived on struct #108256
error[E0726]: implicit elided lifetime not allowed here
--> src/lib.rs:12:1
|
12 | pub struct ContextWrapper<'a,T>
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
12 | p'_, ub structContextWrapper<'a,T>
| +++
For more information about this error, try `rustc --explainE0726`.
I'm guessing the error being pointed to is in the procedural macro generated code, but that's not immediately clear as it points to my struct definition. This code compiles when I remove SortBy and its attribute.
changed the title [-]E0726 makes invalid mid-keyword suggestion with proc-macro-derived on struct[/-][+]E0726 makes invalid mid-keyword suggestion with proc-macro derived on struct[/+]on Feb 20, 2023
sort_by_derive Is effectively using the wrong span on their expanded code. If they were doing nothing then #109082 would eliminate the issue, but the best bet we have here is to modify sort_by_derive itself, instead of adding more heuristics to rustc to detect that the macros of the Token Stream coming out of a proc-macro might be misleading (at least in the short term).
If the lifetimes suggestion is meant to be in the expanded code, then the
error message pointing to the expanded code/the derive macro would be
sufficient for me, since I would be able to pinpoint the issue there is in
the other crate and bring it to them, and probably figure out that the
spans are wrong. (The original issue was that I couldn't tell where to look
until I started removing code.)
If rustc run on sort_by_derive itself can warn that the spans are wrong,
that's a bonus.
Indeed the problem is on my side and lifetimes were missing from the expanded code, so I fixed that and released the fix. I should probably check if I can highlight the derive macro itself when it generated something invalid, but it's going to be of limited value to the users, except indeed signaling that it's not their fault.
Activity
[-]E0726 makes invalid mid-keyword suggestion with proc-macro-derived on struct[/-][+]E0726 makes invalid mid-keyword suggestion with proc-macro derived on struct[/+]estebank commentedon Mar 14, 2023
sort_by_derive Is effectively using the wrong span on their expanded code. If they were doing nothing then #109082 would eliminate the issue, but the best bet we have here is to modify sort_by_derive itself, instead of adding more heuristics to rustc to detect that the macros of the Token Stream coming out of a proc-macro might be misleading (at least in the short term).
Zannick commentedon Mar 14, 2023
valsteen commentedon Jun 17, 2023
hi, crate author here 👋
Indeed the problem is on my side and lifetimes were missing from the expanded code, so I fixed that and released the fix. I should probably check if I can highlight the derive macro itself when it generated something invalid, but it's going to be of limited value to the users, except indeed signaling that it's not their fault.