-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Insufficient arguments error E0061 & E0050 would be more helpful if it printed what arguments are needed #33649
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
Comments
Showing which parameter isn't supplied is quite difficult. It could be any and rustc should guess what argument you forgot between all arguments. Quite difficult. However, showing the function definition in a note seems a nice idea. |
@GuillaumeGomez the function definition might be in another crate, so you'd have to reconstruct it from metadata. |
@GuillaumeGomez I think it'd be sufficient to list remaining arguments only (if I supplied 3, but 5 are required, show last 2). That's because if I got order of arguments wrong, it'll hopefully be picked by type checker, and that's a different error. Listing names (and types) of all arguments would be OK too. |
Like I said, how do rustc can guess if you entered the 3 first or the 3 last? Or that they're even in the good order?
That was just a guess. 😉 |
Could you also add the Rust version info here to your post? You'll help to make this issue tracker a more useful archive/reference in the future. |
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
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
Thank you @estebank for fixing this :) |
Uh oh!
There was an error while loading. Please reload this page.
When I call a function with insufficient arguments, rustc just says the number of arguments is wrong.
This would be much more helpful if it said which arguments, and what they are, e.g.:
or at least show the funcition definition in a note:
Similar problem applies to E0050 ("error: method
foo
has 1 parameter but the declaration in traitbar
has 2").rustc 1.10.0-nightly (2b79e05 2016-05-13)
The text was updated successfully, but these errors were encountered: