Skip to content

Derive macro doesn't keep the struct's generics #268

Open

Description

@ADD-SP

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,
   |                        ++++

Activity

  1. changed the title [-]struct's generics aren't kept[/-] [+]Derive macro doesn't keep the struct's generics[/+] on Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions