Skip to content

Commit b5ff4ad

Browse files
authored
Rollup merge of #97303 - compiler-errors:arg-typos, r=jackh726
Fix some typos in arg checking algorithm Fixes #97197 Also fixes a typo where if we're missing args A, B, C, we actually say A, B, B
2 parents 06e89fd + 21a7b4c commit b5ff4ad

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
768768
let second_input_ty =
769769
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
770770
let third_input_ty =
771-
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
771+
self.resolve_vars_if_possible(expected_input_tys[third_idx]);
772772
let span = if third_idx < provided_arg_count {
773773
let first_arg_span = provided_args[first_idx].span;
774774
let third_arg_span = provided_args[third_idx].span;
@@ -809,16 +809,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
809809
}
810810
missing_idxs => {
811811
let first_idx = *missing_idxs.first().unwrap();
812-
let second_idx = *missing_idxs.last().unwrap();
812+
let last_idx = *missing_idxs.last().unwrap();
813813
// NOTE: Because we might be re-arranging arguments, might have extra arguments, etc.
814814
// It's hard to *really* know where we should provide this error label, so this is a
815815
// decent heuristic
816-
let span = if first_idx < provided_arg_count {
816+
let span = if last_idx < provided_arg_count {
817817
let first_arg_span = provided_args[first_idx].span;
818-
let second_arg_span = provided_args[second_idx].span;
818+
let last_arg_span = provided_args[last_idx].span;
819819
Span::new(
820820
first_arg_span.lo(),
821-
second_arg_span.hi(),
821+
last_arg_span.hi(),
822822
first_arg_span.ctxt(),
823823
None,
824824
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
g((), ());
3+
//~^ ERROR this function takes 6 arguments but 2 arguments were supplied
4+
}
5+
6+
pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0061]: this function takes 6 arguments but 2 arguments were supplied
2+
--> $DIR/issue-97197.rs:2:5
3+
|
4+
LL | g((), ());
5+
| ^-------- multiple arguments are missing
6+
|
7+
note: function defined here
8+
--> $DIR/issue-97197.rs:6:8
9+
|
10+
LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
11+
| ^ ------ -------- -------- -------- -------- ------
12+
help: provide the arguments
13+
|
14+
LL | g((), {bool}, {bool}, {bool}, {bool}, ());
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0061`.

src/test/ui/argument-suggestions/missing_arguments.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ error[E0061]: this function takes 5 arguments but 2 arguments were supplied
293293
--> $DIR/missing_arguments.rs:39:3
294294
|
295295
LL | complex( 1, "" );
296-
| ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `i32` are missing
296+
| ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `f32` are missing
297297
|
298298
note: function defined here
299299
--> $DIR/missing_arguments.rs:7:4

0 commit comments

Comments
 (0)