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

stabilize int_error_matching #76455

Closed
wants to merge 3 commits into from
Closed

Conversation

eopb
Copy link
Contributor

@eopb eopb commented Sep 7, 2020

The original PR was my first std contribution. Since then a few people have called for it to be stabilized. See discussion on #22639

A significant number of people seem to be using this feature in their projects https://github.com/search?p=2&q=%23%21%5Bfeature%28int_error_matching%29%5D&type=Code

Unanswered questions

If this is to be stabilized, I think that the terminology has to be improved: IntErrorKind uses Underflow to refer to negative overflow, but underflow usually means when the absolute value of a floating-point number is so small it becomes 0 (or a subnormal).

Originally posted by @tspiteri in #22639 (comment)

Maybe PosOverflow and NegOverflow?

Originally posted by @JarrettBillingsley in #22639 (comment)

I personally don't think it needs to change as in this position underflow is clearly associated with integers and seems consistent with other uses of the word underflow in std. I am interested to hear others thoughts.

@rust-highfive
Copy link
Collaborator

r? @KodrAus

(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 Sep 7, 2020
@jonas-schievink jonas-schievink added needs-fcp This change is insta-stable, so needs a completed FCP to proceed. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 7, 2020
@KodrAus
Copy link
Contributor

KodrAus commented Sep 9, 2020

I definitely don’t think we should call the variant Underflow, because even though we’re not really consistent internally, the term does refer to a specific failure mode that doesn’t apply here. I don’t think that’s a reason to repurpose the term, just so that we don’t leave any doubt for callers trying to interpret these error messages.

In general though I think this is a useful stabilization! I’ll kick off the FCP and add my concern for underflow to let others weigh in.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Sep 9, 2020

Team member @KodrAus has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 9, 2020
@KodrAus
Copy link
Contributor

KodrAus commented Sep 9, 2020

@rfcbot concern underflow vs negative overflow

See #76455 (comment) I think we should use an accurate name for the negative overflow variant, rather than repurposing the term underflow, which has a specific meaning for floating point numbers.

@withoutboats
Copy link
Contributor

I've always used the term "underflow" for ints wrapping beyond their lower bound and didn't realize this was not common usage.

@KodrAus
Copy link
Contributor

KodrAus commented Sep 9, 2020

I actually didn’t even know underflow had a special meaning and used it the same way until I think I got assigned a docs PR once to use overflow for integers that would exceed their upper or lower bound. It turns out underflow specifically refers to floating point numbers that are too close to zero to distinguish from it.

@bors
Copy link
Contributor

bors commented Sep 16, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@Darksonn
Copy link
Contributor

This was discussed on the users forum: link.

@eopb
Copy link
Contributor Author

eopb commented Sep 25, 2020

I will open a new PR soon addressing these issues rather than continuing this one.

I will also need to take a good look at the parsing code to ensure it produces the correct errors.

As I am rather busy right now I will have an update within the next few weeks.

@KodrAus
Copy link
Contributor

KodrAus commented Oct 5, 2020

Thanks for working through all this @ethanboxx!

If you don't need to make many changes then we could probably continue on this PR, since it's already got its FCP going.

@eopb
Copy link
Contributor Author

eopb commented Oct 11, 2020

Closing in favour of #77640

@eopb eopb closed this Oct 11, 2020
@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 11, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 8, 2020
…t_2, r=KodrAus

Refactor IntErrorKind to avoid "underflow" terminology

This PR is a continuation of rust-lang#76455

# Changes

- `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in rust-lang#76455
- Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178
- Carry the problem `char` with the `InvalidDigit` variant.
- Necessary changes were made to the compiler as it depends on `int_error_matching`.
- Redid tests to match on specific errors.

r? `@KodrAus`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 8, 2020
…t_2, r=KodrAus

Refactor IntErrorKind to avoid "underflow" terminology

This PR is a continuation of rust-lang#76455

# Changes

- `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in rust-lang#76455
- Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178
- Carry the problem `char` with the `InvalidDigit` variant.
- Necessary changes were made to the compiler as it depends on `int_error_matching`.
- Redid tests to match on specific errors.

r? ``@KodrAus``
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 9, 2020
…t_2, r=KodrAus

Refactor IntErrorKind to avoid "underflow" terminology

This PR is a continuation of rust-lang#76455

# Changes

- `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in rust-lang#76455
- Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178
- Carry the problem `char` with the `InvalidDigit` variant.
- Necessary changes were made to the compiler as it depends on `int_error_matching`.
- Redid tests to match on specific errors.

r? ```@KodrAus```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants