prometheus / prometheus/client_rust
Derive macro doesn't keep the struct's generics
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 606
- Forks
- 113
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 8
Description
For this code snippet
struct CpuUsageLabelsSet<'a> {
mode: CpuMode, // <- an enum
service: &'a str,
}
which emits compilation error
error[E0726]: implicit elided lifetime not allowed here
--> xxxxx
|
48 | struct CpuUsageLabelSet<'a> { // <-- `'a` lifetime is used in the struct,
| ^^^^^^^^^^^^^^^^ expected lifetime parameter
|
help: indicate the anonymous lifetime
|
48 | struct CpuUsageLabelSet<'_><'a> { // <-- `'a` lifetime is used in the struct,
| ++++
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the E0726 error using the CpuUsageLabelsSet example and inspect the derive-macro expansion that handles the struct. The work is done when the generated code preserves the struct's lifetime and other generics so this example compiles without requiring an extra anonymous lifetime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100