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

E0060 and E0061 improvement #35983

Merged
merged 1 commit into from
Sep 6, 2016
Merged

Conversation

GuillaumeGomez
Copy link
Member

err.note(&format!("the following parameter type{} expected: {}",
if expected_count == 1 {" was"} else {"s were"},
input_types.join(", ")));
err.span_label(sp, &format!("the following parameter type{} expected: {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to make this a label, can we make it smaller? Maybe something like it simply:

"parameter type{} expected: {}"

Makes we wish we had a span_label for the definition site, so they could see where the requirements were coming from (if we don't have that already)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about my proposition of list? A type a line if more than one type and it makes a nice output, easy to read. What do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A list in the label or in a note? I think it would work better in the note. Do you have an heuristic in mind?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. I can try both and show the result in here if you want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing here sounds good

@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Aug 31, 2016

First test with list in the span message:

./x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/compile-fail/E0061.rs
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/test/compile-fail/E0061.rs:14:5
   |
14 |     f(0);
   |     ^^^^ the following parameter types were expected: 
* u16
* &str

error: aborting due to previous error

Not very beautiful.

@GuillaumeGomez
Copy link
Member Author

And inside a note it gives:

./x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/compile-fail/E0061.rs
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/test/compile-fail/E0061.rs:14:5
   |
14 |     f(0);
   |     ^^^^
   |
   = note: the following parameter types were expected: 
* u16
* &str

error: aborting due to previous error

Not very beautiful either...

I think that the errors should keep the indent if there is a newline. If you want I can add it @jonathandturner.

@sophiajt
Copy link
Contributor

Maybe:

./x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/compile-fail/E0061.rs
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/test/compile-fail/E0061.rs:14:5
   |
14 |     f(0);
   |     ^^^^
   |
   = note: the following parameter types were expected:
   = note:   (u16, &str)

@sophiajt
Copy link
Contributor

sophiajt commented Sep 1, 2016

Another alternative (after chatting on IRC) might be:

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/test/compile-fail/E0061.rs:14:5
   |
11 | fn f(a: u16, b: &str) {}
   | - when calling this function
...
14 |     f(0);
   |     ^^^^ expected 2 parameters
   |

I wish we could point at the function name in the definition, but iirc, that span isn't yet available.

@GuillaumeGomez
Copy link
Member Author

Updated.

@sophiajt
Copy link
Contributor

sophiajt commented Sep 3, 2016

Tidy failure:

/build/src/test/compile-fail/variadic-ffi-3.rs:20: tab character

@GuillaumeGomez
Copy link
Member Author

Updated.

@@ -15,6 +15,6 @@ fn main() {
});
//~^^ ERROR this function takes 2 parameters but 1 parameter was supplied
//~| NOTE the following parameter types were expected
//~| NOTE expected 2 parameters
//~| NOTE _, _
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, this one got worse. I wish I'd fixed the type variable names also. Once they're fixed, this should look better

@sophiajt
Copy link
Contributor

sophiajt commented Sep 4, 2016

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 4, 2016

📌 Commit 1eda14e has been approved by jonathandturner

Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 5, 2016
bors added a commit that referenced this pull request Sep 6, 2016
Rollup of 6 pull requests

- Successful merges: #35845, #35983, #36065, #36102, #36242, #36245
- Failed merges:
@bors bors merged commit 1eda14e into rust-lang:master Sep 6, 2016
@GuillaumeGomez GuillaumeGomez deleted the e0060_bonus branch September 6, 2016 11:27
@acrrd
Copy link
Contributor

acrrd commented Sep 6, 2016

This broke the non bonus part of #35214

Edit: moving the err.span_label out of the if chain fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants