Skip to content

Commit 0a2d181

Browse files
Dylan-DPCehuss
authored andcommitted
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
1 parent 0723488 commit 0a2d181

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
@@ -769,7 +769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
769769
let second_input_ty =
770770
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
771771
let third_input_ty =
772-
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
772+
self.resolve_vars_if_possible(expected_input_tys[third_idx]);
773773
let span = if third_idx < provided_arg_count {
774774
let first_arg_span = provided_args[first_idx].span;
775775
let third_arg_span = provided_args[third_idx].span;
@@ -810,16 +810,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
810810
}
811811
missing_idxs => {
812812
let first_idx = *missing_idxs.first().unwrap();
813-
let second_idx = *missing_idxs.last().unwrap();
813+
let last_idx = *missing_idxs.last().unwrap();
814814
// NOTE: Because we might be re-arranging arguments, might have extra arguments, etc.
815815
// It's hard to *really* know where we should provide this error label, so this is a
816816
// decent heuristic
817-
let span = if first_idx < provided_arg_count {
817+
let span = if last_idx < provided_arg_count {
818818
let first_arg_span = provided_args[first_idx].span;
819-
let second_arg_span = provided_args[second_idx].span;
819+
let last_arg_span = provided_args[last_idx].span;
820820
Span::new(
821821
first_arg_span.lo(),
822-
second_arg_span.hi(),
822+
last_arg_span.hi(),
823823
first_arg_span.ctxt(),
824824
None,
825825
)
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)