Skip to content

Lifetime parameters in type aliases do not need to be used in the definition #82365

Description

@Darksonn

The following code compiles, even though it would emit an error about the lifetime being unused in any other context:

type Huh<'a> = String;

Interestingly enough,

type Huh<'a> = String;

struct MyStruct<'a> {
    foo: Huh<'a>,
}

fails to compile with

error[E0392]: parameter `'a` is never used
 --> src/lib.rs:3:17
  |
3 | struct MyStruct<'a> {
  |                 ^^ unused parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

I'm not sure what exactly is going on here, but if nothing else, this error message seems pretty confusing.

context: link

Activity

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

    A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions