Skip to content

Using type with local type parameters has confusing error #37892

Description

@bluss

Using type with local type parameters or Self should have a clearer error.

Reproduce with: (playpen link)

struct Foo;

impl Foo {
    fn method<T>(&self) {
        type X = (Self, T);
    }
}

Current errors have a suggestion ("try..") that doesn't apply.

error[E0401]: can't use type parameters from outer function; try using a local type parameter instead
 --> <anon>:6:19
  |
6 |         type X = (Self, T);
  |                   ^^^^ use of type variable from outer function

error[E0401]: can't use type parameters from outer function; try using a local type parameter instead
 --> <anon>:6:25
  |
6 |         type X = (Self, T);
  |                         ^ use of type variable from outer function

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-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.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