Fix substraction with overflow in wrong_number_of_generic_args.rs#104467
Merged
bors merged 2 commits intorust-lang:masterfrom Nov 20, 2022
Merged
Fix substraction with overflow in wrong_number_of_generic_args.rs#104467bors merged 2 commits intorust-lang:masterfrom
wrong_number_of_generic_args.rs#104467bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @lcnr (or someone else) soon. Please see the contribution instructions for more information. |
compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs
Outdated
Show resolved
Hide resolved
Contributor
Contributor
Author
|
Should I squash the commits? |
Contributor
|
Yes please. |
Contributor
|
Also this needs a test: https://rustc-dev-guide.rust-lang.org/tests/ui.html |
Contributor
Author
|
@compiler-errors Sure, I couldn't figure out how to do that kind of testing. Cool guide. I'm on it. |
Contributor
|
Use |
Rarranging the substration and equality check into an addition and an equality check is sufficient. Algebra is cool, isn't it? Co-authored-by: Michael Goulet <michael@errs.io>
This relies on the CI testing a rustc that's compiled with overflow-checks = true
edb7f1f to
3046af0
Compare
Contributor
Author
|
@rustbot ready |
Contributor
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 20, 2022
Rollup of 6 pull requests Successful merges: - rust-lang#103901 (Add tracking issue for `const_arguments_as_str`) - rust-lang#104112 (rustdoc: Add copy to the description of repeat) - rust-lang#104435 (`VecDeque::resize` should re-use the buffer in the passed-in element) - rust-lang#104467 (Fix substraction with overflow in `wrong_number_of_generic_args.rs`) - rust-lang#104608 (Cleanup macro matching recovery) - rust-lang#104626 (Fix doctest errors related to rustc_middle) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #104287
This issue happens in the
suggest_moving_args_from_assoc_fn_to_trait_for_qualified_pathfunction, which seems to run before the error checking facilities can catch an invalid use of generic arguments. Thus we get a subtraction with overflow because the code implicitly assumes that the source program makes sense (or is this assumption not true even if the program is correct?).