-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
RangeInclusive::contains doesn't consider exhaustion #77941
Comments
It is a bit unfortunate that this is likely also a regression performance wise, but correctness does seem more important :) I think we should do this as well, though given the (potential) breakage it would want t-libs FCP. |
It should be noted that #78109 doesn't fix Digging deeper it looks like the same problem happens when using the range to index after it has been exhausted (which doesn't use |
That's an interesting thought -- maybe it should return an exclusive end when the iterator is exhausted? |
This would have to be addressed in |
I tried this code:
I expected to see this happen: all assertions pass.
Instead, this happened: the last assertion fails.
Meta
Playground link
The behavior is the same across stable
1.47.0
,1.48.0-beta.2
, and1.49.0-nightly (2020-10-13 adef9da30f1ecbfeb813)
.Analysis
The implementation of
is_empty
includes a check for the exhausted flag:But
contains
only looks at the raw bounds:It would be easy to insert
!self.exhausted && ...
in there, as long as we're OK with the behavior change, which I consider a bug fix. I think the exhausted state of start/end is unspecified, so nobody should be depending oncontains
beingtrue
then.The text was updated successfully, but these errors were encountered: