diff options
| author | bors <bors@rust-lang.org> | 2020-02-10 15:24:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-10 15:24:59 +0000 |
| commit | e6ec0d125eba4074122b187032474b4174fb9d31 (patch) | |
| tree | 6068680ebdd11e46ff0e16cf29872db95469f4a9 /src/test/rustdoc-ui/coverage/json.rs | |
| parent | 4d1241f5158ffd66730e094d8f199ed654ed52ae (diff) | |
| parent | 136008c15bbd2f9517dab54b87cddf2023df38a3 (diff) | |
| download | rust-e6ec0d125eba4074122b187032474b4174fb9d31.tar.gz rust-e6ec0d125eba4074122b187032474b4174fb9d31.zip | |
Auto merge of #68835 - CAD97:sound-range-inclusive, r=Mark-Simulacrum
Remove problematic specialization from RangeInclusive Fixes #67194 using the approach [outlined by Mark-Simulacrum](https://github.com/rust-lang/rust/issues/67194#issuecomment-581669549). > I believe the property we want is that if `PartialEq(&self, &other) == true`, then `self.next() == other.next()`. It is true that this is satisfied by removing the specialization and always doing `is_empty.unwrap_or_default()`; the "wrong" behavior there arises from calling `next()` having an effect on initially empty ranges, as we should be in `is_empty = true` but are not (yet) there. It might be possible to detect that the current state is always empty (i.e., `start > end`) and then not fill in the empty slot. I think this might solve the problem without regressing tests; however, this could have performance implications. > That approach essentially states that we only use the `is_empty` slot for cases where `start <= end`. That means that `Idx: !Step` and `start > end` would both behave the same, and correctly -- we do not need the boolean if we're not ever going to emit any values from the iterator. This is implemented here by replacing the `is_empty: Option<bool>` slot with an `exhausted: bool` slot. This flag is - `false` upon construction, - `false` when iteration has not yielded an element -- importantly, this means it is always `false` for an iterator empty by construction, - `false` when iteration has yielded an element and the iterator is not exhausted, and - only `true` when iteration has been used to exhaust the iterator. For completeness, this also adds a note to the `Debug` representation to note when the range is exhausted.
Diffstat (limited to 'src/test/rustdoc-ui/coverage/json.rs')
0 files changed, 0 insertions, 0 deletions
