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

With over-parenthesized method call, E0615 suggests adding parentheses in the wrong place #88803

Closed
jruderman opened this issue Sep 10, 2021 · 0 comments · Fixed by #88841
Closed
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.

Comments

@jruderman
Copy link
Contributor

Given the following code:

fn main() {
    let a = Some(42);
    println!(
        "The value is {}.",
        (a.unwrap)()
    );
}

The current output is:

error[E0615]: attempted to take value of method `unwrap` on type `Option<{integer}>`
 --> src/main.rs:5:12
  |
5 |         (a.unwrap)()
  |            ^^^^^^ method, not a field
  |
help: use parentheses to call the method
  |
5 |         (a.unwrap)()()
  |                   ++

Ideally the output should look like:

help: remove these parentheses

(a.unwrap)()
^^^^^^^^^^ 

But at least adding parentheses right next to the method name would be an improvement:

help: use parentheses to call the method
  |
5 |         (a.unwrap())()
  |                  ++
@jruderman jruderman 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 Sep 10, 2021
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 14, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 14, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 14, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 14, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 14, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 14, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 15, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 15, 2021
…r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes rust-lang#88803
@bors bors closed this as completed in 5dab3c5 Sep 16, 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 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