Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shepmaster opened this issue Jan 5, 2024 · 1 comment · Fixed by #119703
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@shepmaster
Copy link
Member

shepmaster commented Jan 5, 2024

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)

@shepmaster shepmaster added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 5, 2024
@compiler-errors
Copy link
Member

We probably should not make this diagnostic have an exhaustive list of allowed places anymore

@saethlin saethlin added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 7, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 7, 2024
… r=fmease

Impl trait tweaks

1. Tweak some names for `impl Trait` being used in the wrong position
2. Remove two helper functions that are no longer needed since RPITIT is stable, and which causes matches to be a bit obtuse.
3. Split and fix the part where the error notes that it's "only allowed in XX"

Fixes rust-lang#119629
@bors bors closed this as completed in 0207e24 Jan 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 8, 2024
Rollup merge of rust-lang#119703 - compiler-errors:impl-trait-tweaks, r=fmease

Impl trait diagnostic tweaks

1. Tweak some names for `impl Trait` being used in the wrong position
2. Remove two helper functions that are no longer needed since RPITIT is stable, and which causes matches to be a bit obtuse.
3. Split and fix the part where the error notes that it's "only allowed in XX"

Fixes rust-lang#119629
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants