Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
for (idx, arg) in matched_inputs.iter().enumerate() {
let suggestion_text = if let Some(arg) = arg {
let arg_span = provided_args[*arg].span;
let arg_span = provided_args[*arg].span.source_callsite();
let arg_text = source_map.span_to_snippet(arg_span).unwrap();
arg_text
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/typeck/remove-extra-argument.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// run-rustfix
// Check that the HELP suggestion is `l(vec![])` instead of `l($crate::vec::Vec::new())`
fn l(_a: Vec<u8>) {}

fn main() {
l(vec![])
//~^ ERROR this function takes 1 argument but 2 arguments were supplied
//~| HELP remove the extra argument
}
9 changes: 9 additions & 0 deletions src/test/ui/typeck/remove-extra-argument.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// run-rustfix
// Check that the HELP suggestion is `l(vec![])` instead of `l($crate::vec::Vec::new())`
fn l(_a: Vec<u8>) {}

fn main() {
l(vec![], vec![])
//~^ ERROR this function takes 1 argument but 2 arguments were supplied
//~| HELP remove the extra argument
}
19 changes: 19 additions & 0 deletions src/test/ui/typeck/remove-extra-argument.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/remove-extra-argument.rs:6:5
|
LL | l(vec![], vec![])
| ^ ------ argument unexpected
|
note: function defined here
--> $DIR/remove-extra-argument.rs:3:4
|
LL | fn l(_a: Vec<u8>) {}
| ^ -----------
help: remove the extra argument
|
LL | l(vec![])
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.