-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Show types of all args when missing args #34000
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
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jroesch (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
49aa08c
to
aa489af
Compare
&format!("the following parameter type{} expected: {}", | ||
if expected_arg_count == 1 {" was"} else {"s were"}, | ||
input_types.join(", "))); | ||
} |
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.
This should probably be in its own function to reduce code repetition (this would allow E0057
, E0060
and E0061
to be merged into a single error number).
Also it should be using the error builders, so you can attach the note to the main error.
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.
Done! I left the error codes separate because I feel changing that behaviour would be incorrect.
83fc815
to
8ab4aaa
Compare
r? @oli-obk |
Sorry ^^ I'm not a reviewer |
@oli-obk not a problem :) |
err.emit(); | ||
} | ||
|
||
|
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.
nit: just one newline here would be more idiomatic
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.
Done.
When there're missing arguments in a function call, present a list of all the expected types: ```rust fn main() { t(""); } fn t(a: &str, x: String) {} ``` ```bash % rustc file.rs file.rs:3:5: 2:8 error: this function takes 2 parameters but 0 parameters were supplied [E0061] file.rs:3 t(); ^~~ file.rs:3:5: 2:8 help: run `rustc --explain E0061` to see a detailed explanation file.rs:3:5: 2:8 note: the following parameter types were expected: &str, std::string::String error: aborting due to previous error ``` Fixes rust-lang#33649
Thanks! @bors r+ |
📌 Commit 1020e30 has been approved by |
Show types of all args when missing args When there're missing arguments in a function call, present a list of all the expected types: ```rust fn main() { t(""); } fn t(a: &str, x: String) {} ``` ```bash % rustc file.rs file.rs:3:5: 2:8 error: this function takes 2 parameters but 0 parameters were supplied [E0061] file.rs:3 t(); ^~~ file.rs:3:5: 2:8 help: run `rustc --explain E0061` to see a detailed explanation file.rs:3:5: 2:8 note: the following parameter types were expected: &str, std::string::String error: aborting due to previous error ``` Fixes #33649
When there're missing arguments in a function call, present a list of
all the expected types:
Fixes #33649