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 message does not include function it refers to, only says "this function" (E0061) #45633

Closed
codyps opened this issue Oct 30, 2017 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics

Comments

@codyps
Copy link
Contributor

codyps commented Oct 30, 2017

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/main.rs:63:13
   |
63 |             std::net::SocketAddr::new(ia, 0u16)
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters

error: aborting due to previous error

In this case, this function is tokio_core::net::UdpSocket::bind, but without looking at the code no hint is given:

        let sock = tokio_core::net::UdpSocket::bind(
            std::net::SocketAddr::new(ia, 0u16)
        ).unwrap();

Originally, this function call contained a match statement to calculate the value of ia, which caused the newline-following paren style to be used.

This appears to occur whenever both:

  • using a newline-following paren style (such that the function name does not get included in the context output)
  • calling a function from outside the current crate (so that it's definition is not printed)
@codyps codyps changed the title error message does not include function it refers to, only say "this function" (E0061) error message does not include function it refers to, only says "this function" (E0061) Oct 30, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Oct 30, 2017

Duplicate of #42855

The span should point to ia

@codyps
Copy link
Contributor Author

codyps commented Oct 31, 2017

closing as dup of #42855

@codyps codyps closed this as completed Oct 31, 2017
@codyps
Copy link
Contributor Author

codyps commented Oct 31, 2017

Actually, this looks like a slightly different issue.

ia isn't the problem here. std::net::SocketAddr::new() takes two arguments, but tokio_core::net::UdpSocket::bind also takes 2 arguments, but isn't mentioned in the error message. (this function is tokio_core::net::UdpSocket::bind).

@codyps codyps reopened this Oct 31, 2017
@TimNN TimNN added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Oct 31, 2017
@estebank estebank added E-needs-mentor WG-diagnostics Working group: Diagnostics labels Dec 7, 2017
bors added a commit that referenced this issue Dec 14, 2017
Point at whole method call instead of args

To avoid confusion in cases where the code is

```rust
fn foo() {}
/ foo(
|     bar()
|     ^^^ current diagnostics point here for arg count mismatch
| );
|_^ new diagnostic span points here
```

as this leads to confusion making people think that the diagnostic is
talking about `bar`'s arg count, not `foo`'s.

Point at `fn`s definition on arg mismatch, just like we do for closures.

Re #42855, Fix #45633.
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

4 participants