-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Point arg num mismatch errors back to their definition #38121
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
Conversation
Hmm. Perhaps. I like seeing the full span here because it shows me the arguments inline. |
@bors r+ |
📌 Commit c735d7f has been approved by |
expected_count, | ||
if expected_count == 1 {""} else {"s"})); | ||
if let Some(def_s) = def_span { | ||
err.span_label(def_s, &format!("defined here")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
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
@estebank - possibly. we could do an additional PR and take a look (since this landed before we could discuss) |
This PR updates the arg num errors (like E0061) to point back at the function definition where they were defined.
Before:
Now:
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