Skip to content

assoc type impl mismatch with trait assoc type doesnt mention where clauses #99206

Open
@BoxyUwU

Description

@BoxyUwU

Given the following code:

#![feature(generic_associated_types)]

trait Trait {
    type Assoc<'a>;
}

impl<'b> Trait for &'b () {
    type Assoc<'a>
    = &'a &'b ()
    where
        Self: 'a;
}

The current output is:

error: `impl` associated type signature for `Assoc` doesn't match `trait` associated type signature
 --> src/lib.rs:8:5
  |
4 |     type Assoc<'a>;
  |     -------------- expected
...
8 |     type Assoc<'a>
  |     ^^^^^^^^^^^^^^ found

Ideally the output should look like:

error: `impl` associated type signature for `Assoc` doesn't match `trait` associated type signature
 --> src/lib.rs:8:5
  |
4 |     type Assoc<'a>;
  |     -------------- expected no where clause
...
8 |     type Assoc<'a>
  |     ...
  |     where
  |         Self: 'a;
  |         ^^^^^^^^ found where clause not present on trait definition
note: consider adding where clause to trait definition
  |
4 |    type Assoc<'a>
  |    where
  |        Self: 'a;
  |    +++++++++++++

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-diagnosticsArea: Messages for errors, warnings, and lintsT-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