Skip to content

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

Merged

Conversation

fuzzypixelz
Copy link
Contributor

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?).

@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2022

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.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 16, 2022
@lcnr
Copy link
Contributor

lcnr commented Nov 16, 2022

r? @compiler-errors

@fuzzypixelz
Copy link
Contributor Author

Should I squash the commits?

@compiler-errors
Copy link
Member

Yes please.

@compiler-errors
Copy link
Member

compiler-errors commented Nov 16, 2022

Also this needs a test: https://rustc-dev-guide.rust-lang.org/tests/ui.html

@fuzzypixelz
Copy link
Contributor Author

@compiler-errors Sure, I couldn't figure out how to do that kind of testing. Cool guide.

I'm on it.

@compiler-errors
Copy link
Member

Use @rustbot ready to mark this as ready for review when you've added a UI test.

@compiler-errors compiler-errors 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 Nov 16, 2022
fuzzypixelz and others added 2 commits November 19, 2022 18:53
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
@fuzzypixelz fuzzypixelz force-pushed the fix/attempt-to-substract-with-overflow branch from edb7f1f to 3046af0 Compare November 19, 2022 17:59
@fuzzypixelz
Copy link
Contributor Author

@rustbot ready

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

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 19, 2022

📌 Commit 3046af0 has been approved by compiler-errors

It is now in the queue for this repository.

@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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2022
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
@bors bors merged commit 3e937d0 into rust-lang:master Nov 20, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 20, 2022
@fuzzypixelz fuzzypixelz deleted the fix/attempt-to-substract-with-overflow branch November 22, 2022 17:25
# for free to join this conversation on GitHub. Already have an account? # 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.

"Attempt to subtract with overflow" in suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path
5 participants