Skip to content

Error messages for where impl Trait is allowed do not account for return-position-impl-trait-in-trait (RPITIT) #119629

Closed
@shepmaster

Description

@shepmaster

Code

fn repro(a: impl Fn() -> impl Drop) {}

Current output

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
 --> src/lib.rs:1:26
  |
1 | fn repro(a: impl Fn() -> impl Drop) {}
  |                          ^^^^^^^^^

Desired output

I believe this message should mention the newly-stabilized possibilities of RPITIT. For example, this is not a function or an inherent method:

trait Moo {
    fn moo() -> impl Drop;
}

Rationale and extra context

No response

Other cases

My gut tells me that there are other errors with the same now-incorrect subset of locations.

Anything else?

Seen in nightly (2024-01-04 f688dd6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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