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

Don't suggest associated function call for associated const #104801

Closed
compiler-errors opened this issue Nov 24, 2022 · 0 comments · Fixed by #104856
Closed

Don't suggest associated function call for associated const #104801

compiler-errors opened this issue Nov 24, 2022 · 0 comments · Fixed by #104856
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-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

Follow-up from this comment: #104422 (comment)

Given the following code:

fn main() {
    1i32.MAX()
}

The current output is:

error[E0599]: no method named `MAX` found for type `i32` in the current scope
 --> src/main.rs:2:10
  |
2 |     1i32.MAX()
  |     -----^^^--
  |     |    |
  |     |    this is an associated function, not a method
  |     help: use associated function syntax instead: `i32::MAX()`
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
  = note: the candidate is defined in an impl for the type `i32`

For more information about this error, try `rustc --explain E0599`.

Ideally the output should not mention i32::MAX(), since that is an associated constant and not an associated function. However, it seems like some parts of method probing don't consider the associate item's kind when collecting candidates for diagnostics.

This should be investigated and fixed. While investigating, similar code should also be inspected and fixed if this can be triggered in other ways, for example.

@compiler-errors compiler-errors 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. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Nov 24, 2022
@bors bors closed this as completed in 785b47d Dec 4, 2022
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-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. 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