-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #96646 - estebank:issue-96638, r=jackh726
Mitigate impact of subtle invalid call suggestion logic There's some subtle interaction between inferred expressions being passed as an argument to fn calls with fewer than expected arguments. To avoid the ICE, I'm changing indexing operations with `.get(idx)`, but the underlying logic still needs to be audited as it was written with the assumption that `final_arg_types` and `provided_args` have the right length. Address #96638.
- Loading branch information
Showing
3 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
fn f(_: usize, _: &usize, _: usize) {} | ||
|
||
fn arg<T>() -> T { todo!() } | ||
|
||
fn main() { | ||
let x = arg(); // `x` must be inferred | ||
// The reference on `&x` is important to reproduce the ICE | ||
f(&x, ""); //~ ERROR this function takes 3 arguments but 2 arguments were supplied | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0061]: this function takes 3 arguments but 2 arguments were supplied | ||
--> $DIR/issue-96638.rs:8:5 | ||
| | ||
LL | f(&x, ""); | ||
| ^ -- an argument of type `usize` is missing | ||
| | ||
note: function defined here | ||
--> $DIR/issue-96638.rs:1:4 | ||
| | ||
LL | fn f(_: usize, _: &usize, _: usize) {} | ||
| ^ -------- --------- -------- | ||
help: provide the argument | ||
| | ||
LL | f({usize}, &x, {usize}); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0061`. |