Point arg num mismatch errors back to their definition #38121

Merged
merged 1 commit into from Dec 6, 2016

Projects

None yet

4 participants

@jonathandturner
Contributor

This PR updates the arg num errors (like E0061) to point back at the function definition where they were defined.

Before:

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> E0061.rs:18:7
   |
18 |     f(0);
   |       ^
   |
   = note: the following parameter types were expected:
   = note: u16, &str

Now:

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> E0061.rs:18:7
   |
11 | fn f(a: u16, b: &str) {}
   | ------------------------ defined here
...
18 |     f(0);
   |       ^ expected 2 parameters

This is an incremental improvement. We probably want to underline only the function name and also have support for functions defined in crates outside of the current crate.

r? @nikomatsakis

@jonathandturner jonathandturner Point arg num mismatch errors back to their definition
c735d7f
@nikomatsakis
Contributor

This is an incremental improvement. We probably want to underline only the function name and also have support for functions defined in crates outside of the current crate.

Hmm. Perhaps. I like seeing the full span here because it shows me the arguments inline.

@nikomatsakis
Contributor

@bors r+

@bors
Contributor
bors commented Dec 2, 2016

📌 Commit c735d7f has been approved by nikomatsakis

+ expected_count,
+ if expected_count == 1 {""} else {"s"}));
+ if let Some(def_s) = def_span {
+ err.span_label(def_s, &format!("defined here"));
@estebank
estebank Dec 5, 2016 Contributor

Would it make sense to keep lines 2543-2549 in the else for cases where the method was defined in a separate crate and we don't have access to the definition span?

@bors
Contributor
bors commented Dec 6, 2016

⌛️ Testing commit c735d7f with merge 0999124...

@bors bors added a commit that referenced this pull request Dec 6, 2016
@bors bors Auto merge of #38121 - jonathandturner:better_e0061, r=nikomatsakis
Point arg num mismatch errors back to their definition

This PR updates the arg num errors (like E0061) to point back at the function definition where they were defined.

Before:

```
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> E0061.rs:18:7
   |
18 |     f(0);
   |       ^
   |
   = note: the following parameter types were expected:
   = note: u16, &str
```

Now:

```
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> E0061.rs:18:7
   |
11 | fn f(a: u16, b: &str) {}
   | ------------------------ defined here
...
18 |     f(0);
   |       ^ expected 2 parameters
```

This is an incremental improvement.  We probably want to underline only the function name and also have support for functions defined in crates outside of the current crate.

r? @nikomatsakis
0999124
@bors bors merged commit c735d7f into rust-lang:master Dec 6, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@jonathandturner
Contributor

@estebank - possibly. we could do an additional PR and take a look (since this landed before we could discuss)

@jonathandturner jonathandturner deleted the jonathandturner:better_e0061 branch Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment