Skip to content

Commit

Permalink
Rollup merge of rust-lang#136583 - Jarcho:fn_ctxt2, r=compiler-errors
Browse files Browse the repository at this point in the history
Only highlight unmatchable parameters at the definition site

Followup to rust-lang#136497

This generally results more focused messages in the same vein as rust-lang#99635 (see `test/ui/argument-suggestions/complex.rs`). There are still some cases (e.g. `test/ui/argument-suggestions/permuted_arguments.rs`) where it might be worth highlighting the arguments. This is mitigated by the fact that a suggestion with a suggested rearrangement is given.

r? `@compiler-errors`
  • Loading branch information
workingjubilee authored Feb 6, 2025
2 parents ffa67f9 + 4718cb4 commit 736f902
Show file tree
Hide file tree
Showing 28 changed files with 246 additions and 312 deletions.
316 changes: 155 additions & 161 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/ui/argument-suggestions/basic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ note: function defined here
--> $DIR/basic.rs:16:4
|
LL | fn swapped(_i: u32, _s: &str) {}
| ^^^^^^^ ------- --------
| ^^^^^^^
help: swap these arguments
|
LL | swapped(1, "");
Expand All @@ -76,7 +76,7 @@ note: function defined here
--> $DIR/basic.rs:17:4
|
LL | fn permuted(_x: X, _y: Y, _z: Z) {}
| ^^^^^^^^ ----- ----- -----
| ^^^^^^^^
help: reorder these arguments
|
LL | permuted(X {}, Y {}, Z {});
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/argument-suggestions/complex.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ note: function defined here
--> $DIR/complex.rs:11:4
|
LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {}
| ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- -----
| ^^^^^^^ ------- -----
help: did you mean
|
LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {});
Expand Down
34 changes: 17 additions & 17 deletions tests/ui/argument-suggestions/extra_arguments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra argument
|
LL - one_arg(1, 1);
Expand All @@ -61,7 +61,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra argument
|
LL - one_arg(1, "");
Expand All @@ -80,7 +80,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra arguments
|
LL - one_arg(1, "", 1.0);
Expand All @@ -97,7 +97,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - two_arg_same(1, 1, 1);
Expand All @@ -114,7 +114,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - two_arg_same(1, 1, 1.0);
Expand All @@ -131,7 +131,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - two_arg_diff(1, 1, "");
Expand All @@ -148,7 +148,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - two_arg_diff(1, "", "");
Expand All @@ -167,7 +167,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
| ^^^^^^^^^^^^
help: remove the extra arguments
|
LL - two_arg_diff(1, 1, "", "");
Expand All @@ -186,7 +186,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
| ^^^^^^^^^^^^
help: remove the extra arguments
|
LL - two_arg_diff(1, "", 1, "");
Expand All @@ -203,7 +203,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - two_arg_same(1, 1, "");
Expand All @@ -220,7 +220,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - two_arg_diff(1, 1, "");
Expand All @@ -240,7 +240,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - 1,
Expand All @@ -261,7 +261,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
| ^^^^^^^^^^^^
help: remove the extra argument
|
LL - 1,
Expand Down Expand Up @@ -335,7 +335,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra argument
|
LL - one_arg(1, panic!());
Expand All @@ -352,7 +352,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra argument
|
LL - one_arg(panic!(), 1);
Expand All @@ -369,7 +369,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra argument
|
LL - one_arg(stringify!($e), 1);
Expand All @@ -386,7 +386,7 @@ note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg<T>(_a: T) {}
| ^^^^^^^ -----
| ^^^^^^^
help: remove the extra argument
|
LL - one_arg(for _ in 1.. {}, 1);
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/argument-suggestions/invalid_arguments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ note: function defined here
--> $DIR/invalid_arguments.rs:8:4
|
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
| ^^^^^^^^^^^^^^ ------- ------- --------
| ^^^^^^^^^^^^^^ ------- -------

error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:29:3
Expand All @@ -164,7 +164,7 @@ note: function defined here
--> $DIR/invalid_arguments.rs:8:4
|
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
| ^^^^^^^^^^^^^^ ------- ------- --------
| ^^^^^^^^^^^^^^ ------- --------

error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:30:3
Expand All @@ -178,7 +178,7 @@ note: function defined here
--> $DIR/invalid_arguments.rs:8:4
|
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
| ^^^^^^^^^^^^^^ ------- ------- --------
| ^^^^^^^^^^^^^^ ------- --------

error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:32:3
Expand Down Expand Up @@ -249,7 +249,7 @@ note: function defined here
--> $DIR/invalid_arguments.rs:9:4
|
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
| ^^^^^^^^^^^^^^^^ ------- ------- --------
| ^^^^^^^^^^^^^^^^ ------- -------

error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:39:3
Expand All @@ -263,7 +263,7 @@ note: function defined here
--> $DIR/invalid_arguments.rs:9:4
|
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
| ^^^^^^^^^^^^^^^^ ------- ------- --------
| ^^^^^^^^^^^^^^^^ ------- --------

error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:40:3
Expand All @@ -277,7 +277,7 @@ note: function defined here
--> $DIR/invalid_arguments.rs:9:4
|
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
| ^^^^^^^^^^^^^^^^ ------- ------- --------
| ^^^^^^^^^^^^^^^^ ------- --------

error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:42:3
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/argument-suggestions/issue-100478.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: function defined here
--> $DIR/issue-100478.rs:30:4
|
LL | fn three_diff(_a: T1, _b: T2, _c: T3) {}
| ^^^^^^^^^^ ------ ------ ------
| ^^^^^^^^^^ ------ ------
help: provide the arguments
|
LL | three_diff(/* T1 */, T2::new(0), /* T3 */);
Expand All @@ -31,7 +31,7 @@ note: function defined here
--> $DIR/issue-100478.rs:31:4
|
LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
| ^^^^^^^^^^^^ ------ ------ ------ ------
| ^^^^^^^^^^^^
help: did you mean
|
LL | four_shuffle(T1::default(), T2::default(), T3::default(), T4::default());
Expand All @@ -50,7 +50,7 @@ note: function defined here
--> $DIR/issue-100478.rs:31:4
|
LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
| ^^^^^^^^^^^^ ------ ------ ------ ------
| ^^^^^^^^^^^^ ------
help: swap these arguments
|
LL | four_shuffle(T1::default(), T2::default(), T3::default(), /* T4 */);
Expand All @@ -69,7 +69,7 @@ note: function defined here
--> $DIR/issue-100478.rs:29:4
|
LL | fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {}
| ^^^ ------ ----------- ------ ----------- ------ ------ ------ -----------
| ^^^ -----------
help: provide the argument
|
LL | foo(p1, /* Arc<T2> */, p3, p4, p5, p6, p7, p8);
Expand Down
56 changes: 2 additions & 54 deletions tests/ui/argument-suggestions/issue-101097.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ note: function defined here
|
LL | fn f(
| ^
LL | a1: A,
| -----
LL | a2: A,
| -----
LL | b1: B,
| -----
LL | b2: B,
| -----
LL | c1: C,
| -----
LL | c2: C,
| -----
help: did you mean
|
LL | f(A, A, B, B, C, C);
Expand All @@ -41,18 +29,6 @@ note: function defined here
|
LL | fn f(
| ^
LL | a1: A,
| -----
LL | a2: A,
| -----
LL | b1: B,
| -----
LL | b2: B,
| -----
LL | c1: C,
| -----
LL | c2: C,
| -----
help: did you mean
|
LL | f(A, A, B, B, C, C);
Expand All @@ -72,14 +48,7 @@ note: function defined here
|
LL | fn f(
| ^
LL | a1: A,
| -----
LL | a2: A,
| -----
LL | b1: B,
| -----
LL | b2: B,
| -----
...
LL | c1: C,
| -----
LL | c2: C,
Expand All @@ -104,18 +73,6 @@ note: function defined here
|
LL | fn f(
| ^
LL | a1: A,
| -----
LL | a2: A,
| -----
LL | b1: B,
| -----
LL | b2: B,
| -----
LL | c1: C,
| -----
LL | c2: C,
| -----
help: did you mean
|
LL | f(A, A, B, B, C, C);
Expand All @@ -137,18 +94,9 @@ note: function defined here
|
LL | fn f(
| ^
LL | a1: A,
| -----
LL | a2: A,
| -----
...
LL | b1: B,
| -----
LL | b2: B,
| -----
LL | c1: C,
| -----
LL | c2: C,
| -----
help: did you mean
|
LL | f(A, A, /* B */, B, C, C);
Expand Down
Loading

0 comments on commit 736f902

Please sign in to comment.