-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix substraction with overflow in wrong_number_of_generic_args.rs
#104467
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix substraction with overflow in wrong_number_of_generic_args.rs
#104467
Conversation
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
Should I squash the commits? |
Yes please. |
Also this needs a test: https://rustc-dev-guide.rust-lang.org/tests/ui.html |
@compiler-errors Sure, I couldn't figure out how to do that kind of testing. Cool guide. I'm on it. |
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
@rustbot ready |
@bors r+ rollup |
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
Fixes #104287
This issue happens in the
suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path
function, 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?).