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

Bad suggestion for _ in associated const #82158

Closed
estebank opened this issue Feb 15, 2021 · 0 comments · Fixed by #86355
Closed

Bad suggestion for _ in associated const #82158

estebank opened this issue Feb 15, 2021 · 0 comments · Fixed by #86355
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. D-papercut Diagnostics: An error or lint that needs small tweaks. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

As noted in #81914, given the following:

fn main() {}
struct MyStruct;

trait Test {
}

impl Test for MyStruct {
    const TEST: fn() -> _ = 42; 
}

we emit

error[E0438]: const `TEST` is not a member of trait `Test`
  --> main_test.rs:10:5
   |
10 |     const TEST: fn() -> _ = 42; 
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Test`

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> main_test.rs:10:25
   |
10 |     const TEST: fn() -> _ = 42; 
   |                         ^
   |                         |
   |                         not allowed in type signatures
   |                         help: use type parameters instead: `T`

Follow up to #81885.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. D-papercut Diagnostics: An error or lint that needs small tweaks. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Feb 15, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 16, 2021
Remove invalid suggestions for assoc consts on placeholder type error

Fixes rust-lang#82158
This also moves some tests to typeck.
r? `@estebank`
@bors bors closed this as completed in aff7994 Jun 17, 2021
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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. D-papercut Diagnostics: An error or lint that needs small tweaks. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant