rust-lang / rust-lang/rust

Nit: E0599 help suggests removing arguments instead of argument list

Open
#129,133 3 comments 0 reactions 1 assignee View on GitHub

@chansuke is already working on this.

Since Aug 17, 2024.

A-diagnostics T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#[allow(dead_code)]
fn main() {
    struct X {
        y: bool,
    }
    let y = true;
    let _ = X{ y }.y();
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `y` found for struct `X` in the current scope
 --> src/main.rs:7:20
  |
3 |     struct X {
  |     -------- method `y` not found for this struct
...
7 |     let _ = X{ y }.y();
  |                    ^-- help: remove the arguments
  |                    |
  |                    field, not a method

For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `y` found for struct `X` in the current scope
 --> src/main.rs:7:20
  |
3 |     struct X {
  |     -------- method `y` not found for this struct
...
7 |     let _ = X{ y }.y();
  |                    ^-- help: remove the argument list
  |                    |
  |                    field, not a method

For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Rationale and extra context

the arguments are the individual elements of the arguments list, this is technically incorrect.

Other cases

No response

Rust Version
1.80.1
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.