-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rename RangeArgument to RangeBounds, move it and Bound to libcore #49163
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
Conversation
a3037f5
to
3f64375
Compare
I think that adding I remember something along those lines was what I was trying to solve in previous PRs, but with limited success when using |
I tried adding this: impl<'a, R, T: ?Sized + 'a> RangeBounds<T> for R where R: RangeBounds<&'a T> {
// …
} and got: error[E0275]: overflow evaluating the requirement `ops::range::RangeFull: ops::range::RangeBounds<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&_>`
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: required because of the requirements on the impl of `ops::range::RangeBounds<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&_>` for `ops::range::RangeFull`
= note: required because of the requirements on the impl of `ops::range::RangeBounds<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&_>` for `ops::range::RangeFull`
[…]
= note: required because of the requirements on the impl of `ops::range::RangeBounds<&&_>` for `ops::range::RangeFull`
= note: required because of the requirements on the impl of `ops::range::RangeBounds<&_>` for `ops::range::RangeFull`
error: aborting due to previous error |
Oh, huh. I'm a bit confused why that's failing, considering how |
@clarcharr: 🔑 Insufficient privileges: Not in reviewers |
@clarcharr: 🔑 Insufficient privileges: not in try users |
|
Added |
@clarcharr You comment #44518 (comment) suggests that the thing with ranges of strings is not just adding I’ve just pushed another commit that generalizes the impls to: impl<T: ?Sized> RangeBounds<T> for RangeFull
impl<T: ?Sized, U: Borrow<T>> RangeBounds<T> for RangeFrom<U>
impl<T: ?Sized, U: Borrow<T>> RangeBounds<T> for RangeTo<U>
impl<T: ?Sized, U: Borrow<T>> RangeBounds<T> for Range<U>
impl<T: ?Sized, U: Borrow<T>> RangeBounds<T> for RangeInclusive<U>
impl<T: ?Sized, U: Borrow<T>> RangeBounds<T> for RangeToInclusive<U>
impl<T: ?Sized, U: Borrow<T>> RangeBounds<T> for (Bound<U>, Bound<U>) Does this seem like a good idea? |
(As a reminder: |
Ah, this was probably the issue you meant: ---- btree/map.rs - btree::map::BTreeMap<K, V>::range_mut (line 818) stdout ----
error[E0283]: type annotations required: cannot resolve `_: std::cmp::Ord`
--> btree/map.rs:824:25
|
9 | for (_, balance) in map.range_mut("B".."Cheryl") {
| ^^^^^^^^^
thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:296:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
btree/map.rs - btree::map::BTreeMap<K, V>::range_mut (line 818) I think that code has two possible concrete types ( Undoing that commit. |
8663ca7
to
fa7ed65
Compare
Ah, yeah, that's why I could never complete the original PR. It's truly unfortunate that I guess that the best option is to just stabilise it as-is and deal with what we've got. I appreciate the name change and the effort, though! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, thanks @SimonSapin!
@@ -420,7 +420,8 @@ | |||
#![stable(feature = "rust1", since = "1.0.0")] | |||
|
|||
#[stable(feature = "rust1", since = "1.0.0")] | |||
pub use alloc::Bound; | |||
#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to also tag this with #[doc(hidden)]
to prevent it showing up in the docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, done.
@rfcbot fcp merge Since this is touching and moving stable items I'd like to get some more eyes on this, but I'm not expecting anything surprising here |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), 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. |
If we’re doing the FCP dance, should we also propose to stabilize? If we decide on a dedicated trait (over |
I'd personally prefer to land this first and then have a separate discussion about the various bounds/impls/such |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
💔 Test failed - status-travis |
This has broken clippy's |
I can reproduce this but I have no idea why it happens :( |
The stable reexport `std::collections::Bound` is now deprecated. Another deprecated reexport could be added in `alloc`, but that crate is unstable.
These unstable items are deprecated: * The `std::collections::range::RangeArgument` reexport * The `std::collections::range` module.
62309b8
to
6c9b3cc
Compare
Rebased and fixed. I'll deal with getting the clippy stuff landed correctly. @bors r=alexcrichton |
📌 Commit 6c9b3cc has been approved by |
Rename RangeArgument to RangeBounds, move it and Bound to libcore As proposed in the tracking issue: #30877 Changes to *stable* items: * `core::ops::Bound` / `std::ops::Bound` is new * `std::collections::Bound` is a deprecated reexport of it (does this actually cause a warning?) Changes to *unstable* items * `alloc::Bound` is gone * `alloc::range::RangeArgument` is moved to `core::ops::RangeBounds` / `std::ops::RangeBounds` * `alloc::range` is gone * `std::collections::range::RangeArgument` is deprecated reexport, to be removed later * `std::collections::range` is deprecated, to be removed later * `impl RangeBounds<T> for Range{,From,To,Inclusive,ToInclusive}<&T>` are added The idea of replacing this trait with a type to be used with `Into<_>` is left for future consideration / work. (Fixes rust-lang/rust-clippy#2552.)
☀️ Test successful - status-appveyor, status-travis |
Tested on commit rust-lang/rust@ae544ee. Direct link to PR: <rust-lang/rust#49163> 💔 clippy-driver on windows: test-pass → test-fail (cc @Manishearth @llogiq @mcarton @oli-obk). 💔 clippy-driver on linux: test-pass → test-fail (cc @Manishearth @llogiq @mcarton @oli-obk).
Unsure why that didn't work, but it let it land, so that's good enough for now. Will fix later. |
stabilize RangeBounds collections_range #30877 The FCP for #30877 closed last month, with the decision to: 1. move from `collections::range::RangeArgument` to `ops::RangeBounds`, and 2. rename `start()` and `end()` to `start_bounds()` and `end_bounds()`. Simon Sapin already moved it to `ops::RangeBounds` in #49163. I renamed the functions, and removed the old `collections::range::RangeArgument` alias. This is my first Rust PR, please let me know if I can improve anything. This passes all tests for me, except the `clippy` tool (which uses `RangeArgument::start()`). I considered deprecating `start()` and `end()` instead of removing them, but the contribution guidelines indicate we can break `clippy` temporarily. I thought it was best to remove the functions, since we're worried about name collisions with `Range::start` and `end`. Closes #30877.
As proposed in the tracking issue: #30877
Changes to stable items:
core::ops::Bound
/std::ops::Bound
is newstd::collections::Bound
is a deprecated reexport of it (does this actually cause a warning?)Changes to unstable items
alloc::Bound
is gonealloc::range::RangeArgument
is moved tocore::ops::RangeBounds
/std::ops::RangeBounds
alloc::range
is gonestd::collections::range::RangeArgument
is deprecated reexport, to be removed laterstd::collections::range
is deprecated, to be removed laterimpl RangeBounds<T> for Range{,From,To,Inclusive,ToInclusive}<&T>
are addedThe idea of replacing this trait with a type to be used with
Into<_>
is left for future consideration / work.(Fixes rust-lang/rust-clippy#2552.)