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
This commit is contained in:
commit
b5ff4ad02c
@ -768,7 +768,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let second_input_ty =
|
let second_input_ty =
|
||||||
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
|
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
|
||||||
let third_input_ty =
|
let third_input_ty =
|
||||||
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
|
self.resolve_vars_if_possible(expected_input_tys[third_idx]);
|
||||||
let span = if third_idx < provided_arg_count {
|
let span = if third_idx < provided_arg_count {
|
||||||
let first_arg_span = provided_args[first_idx].span;
|
let first_arg_span = provided_args[first_idx].span;
|
||||||
let third_arg_span = provided_args[third_idx].span;
|
let third_arg_span = provided_args[third_idx].span;
|
||||||
@ -809,16 +809,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
missing_idxs => {
|
missing_idxs => {
|
||||||
let first_idx = *missing_idxs.first().unwrap();
|
let first_idx = *missing_idxs.first().unwrap();
|
||||||
let second_idx = *missing_idxs.last().unwrap();
|
let last_idx = *missing_idxs.last().unwrap();
|
||||||
// NOTE: Because we might be re-arranging arguments, might have extra arguments, etc.
|
// NOTE: Because we might be re-arranging arguments, might have extra arguments, etc.
|
||||||
// It's hard to *really* know where we should provide this error label, so this is a
|
// It's hard to *really* know where we should provide this error label, so this is a
|
||||||
// decent heuristic
|
// decent heuristic
|
||||||
let span = if first_idx < provided_arg_count {
|
let span = if last_idx < provided_arg_count {
|
||||||
let first_arg_span = provided_args[first_idx].span;
|
let first_arg_span = provided_args[first_idx].span;
|
||||||
let second_arg_span = provided_args[second_idx].span;
|
let last_arg_span = provided_args[last_idx].span;
|
||||||
Span::new(
|
Span::new(
|
||||||
first_arg_span.lo(),
|
first_arg_span.lo(),
|
||||||
second_arg_span.hi(),
|
last_arg_span.hi(),
|
||||||
first_arg_span.ctxt(),
|
first_arg_span.ctxt(),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
6
src/test/ui/argument-suggestions/issue-97197.rs
Normal file
6
src/test/ui/argument-suggestions/issue-97197.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
fn main() {
|
||||||
|
g((), ());
|
||||||
|
//~^ ERROR this function takes 6 arguments but 2 arguments were supplied
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
|
19
src/test/ui/argument-suggestions/issue-97197.stderr
Normal file
19
src/test/ui/argument-suggestions/issue-97197.stderr
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
error[E0061]: this function takes 6 arguments but 2 arguments were supplied
|
||||||
|
--> $DIR/issue-97197.rs:2:5
|
||||||
|
|
|
||||||
|
LL | g((), ());
|
||||||
|
| ^-------- multiple arguments are missing
|
||||||
|
|
|
||||||
|
note: function defined here
|
||||||
|
--> $DIR/issue-97197.rs:6:8
|
||||||
|
|
|
||||||
|
LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
|
||||||
|
| ^ ------ -------- -------- -------- -------- ------
|
||||||
|
help: provide the arguments
|
||||||
|
|
|
||||||
|
LL | g((), {bool}, {bool}, {bool}, {bool}, ());
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0061`.
|
@ -293,7 +293,7 @@ error[E0061]: this function takes 5 arguments but 2 arguments were supplied
|
|||||||
--> $DIR/missing_arguments.rs:39:3
|
--> $DIR/missing_arguments.rs:39:3
|
||||||
|
|
|
|
||||||
LL | complex( 1, "" );
|
LL | complex( 1, "" );
|
||||||
| ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `i32` are missing
|
| ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `f32` are missing
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> $DIR/missing_arguments.rs:7:4
|
--> $DIR/missing_arguments.rs:7:4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user