Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use typed indices in argument mismatch algorithm #97542

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented May 30, 2022

I kinda went overboard with the renames, but in general, "arg" is renamed to "expected", and "input" is renamed to "provided", and we use new typed indices to make sure we're indexing into the right sized array.

Other drive-by changes:

  1. Factor this logic into a new function, so we don't need to break 'label to escape it.
  2. Factored out dependence on final_arg_types, which is never populated for arguments greater than the number of expected args. Instead, we just grab the final coerced expression type from in_progress_typeck_results.
  3. Adjust the criteria we use to print (provided) type names, before we didn't suggest anything that had infer vars, but now we suggest thing that have infer vars but aren't _.

Also, sorry in advance, I kinda want to backport this but I know I have folded in a lot of unnecessary drive-by changes that might discourage that. I would be open to brainstorming how to get some of these changes on beta at least. edit: Minimized the ICE-fixing changes to #97557

cc @jackh726 as author of #92364, and @estebank as reviewer of the PR.
fixes #97484

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 30, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 30, 2022
if matches!(self.compatibility_matrix[i][i], Compatibility::Compatible) {
eliminated.push((self.provided_indices[i], self.expected_indices[i]));
self.satisfy_input(i, i);
}
}
return eliminated;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return eliminated;
eliminated

@jackh726
Copy link
Member

Overall, I like this. But it's going to take me a bit to review.

This is too big to backport imo. I'd prefer a much more targeted fix.

@petrochenkov
Copy link
Contributor

r? @jackh726

compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jun 8, 2022
…r=jackh726

Fix indices and remove some unwraps in arg mismatch algorithm

This is a more conservative fix than rust-lang#97542, addressing some indices which were used incorectly and unwraps which are bound to panic (e.g. when the provided and expected arg counts differ). Beta nominating this as it's quite easy to cause ICEs -- I wrote a fuzzer and found hundreds of examples of ICEs.

cc `@jackh726` as author of rust-lang#92364, and `@estebank` as reviewer of that PR.
fixes rust-lang#97484
r? `@jackh726` this should be _much_ easier to review than the other PR 😅
@bors
Copy link
Contributor

bors commented Jun 9, 2022

☔ The latest upstream changes (presumably #97896) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726
Copy link
Member

r=me after rebase

@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 26, 2022
@compiler-errors
Copy link
Member Author

@bors r=jackh726

@bors
Copy link
Contributor

bors commented Jun 28, 2022

📌 Commit b177c9bef1a3e756a8c4c97d6382b340c361e9ce has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 28, 2022
@compiler-errors
Copy link
Member Author

@bors r=jackh726

@bors
Copy link
Contributor

bors commented Jun 28, 2022

📌 Commit f2277e0 has been approved by jackh726

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 29, 2022
Rollup of 7 pull requests

Successful merges:

 - rust-lang#97423 (Simplify memory ordering intrinsics)
 - rust-lang#97542 (Use typed indices in argument mismatch algorithm)
 - rust-lang#97786 (Account for `-Z simulate-remapped-rust-src-base` when resolving remapped paths)
 - rust-lang#98277 (Fix trait object reborrow suggestion)
 - rust-lang#98525 (Add regression test for rust-lang#79224)
 - rust-lang#98549 (interpret: do not prune requires_caller_location stack frames quite so early)
 - rust-lang#98603 (Some borrowck diagnostic fixes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit dee9aed into rust-lang:master Jun 29, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jun 29, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 29, 2022
…on, r=oli-obk

Clean up arg mismatch diagnostic, generalize tuple wrap suggestion

This is based on top of rust-lang#97542, so just look at the last commit which contains the relevant changes.

1. Remove `final_arg_types` which was one of the last places we were using raw (`usize`) indices instead of typed indices in the arg mismatch suggestion code.
2. Improve the tuple wrap suggestion, now we suggest things like `call(a, b, c, d)` -> `call(a, (b, c), d)` 😺
3. Folded in fix rust-lang#98645
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 29, 2022
…on, r=oli-obk

Clean up arg mismatch diagnostic, generalize tuple wrap suggestion

This is based on top of rust-lang#97542, so just look at the last commit which contains the relevant changes.

1. Remove `final_arg_types` which was one of the last places we were using raw (`usize`) indices instead of typed indices in the arg mismatch suggestion code.
2. Improve the tuple wrap suggestion, now we suggest things like `call(a, b, c, d)` -> `call(a, (b, c), d)` 😺
3. Folded in fix rust-lang#98645
@compiler-errors compiler-errors deleted the arg-mismatch branch August 11, 2023 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broke rustc while refactoring method args in async yolo code
8 participants