-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
9b2c84b
to
cd4cf1f
Compare
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return eliminated; | |
eliminated |
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. |
r? @jackh726 |
…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 😅
☔ The latest upstream changes (presumably #97896) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after rebase |
cd4cf1f
to
b177c9b
Compare
@bors r=jackh726 |
📌 Commit b177c9bef1a3e756a8c4c97d6382b340c361e9ce has been approved by |
b177c9b
to
f2277e0
Compare
@bors r=jackh726 |
📌 Commit f2277e0 has been approved by |
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
…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
…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
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:
break 'label
to escape it.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 fromin_progress_typeck_results
._
.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 #97557cc @jackh726 as author of #92364, and @estebank as reviewer of the PR.
fixes #97484