113 Commits

Author SHA1 Message Date
pravic
830ac8c87f
Fix a typo in unsize.rs
RfC -> RFC
2018-07-31 16:28:50 +03:00
kennytm
6093128ef3
Changed implementation of the third field to make LLVM optimize it better. 2018-07-13 13:26:07 +08:00
kennytm
6e0dd9ec03
Include is_empty() in PartialEq and Hash.
When the index is not PartialOrd, always treat the range as empty.
2018-07-13 09:53:37 +08:00
kennytm
0d7e9933d3
Change RangeInclusive to a three-field struct.
Fix #45222.
2018-07-13 09:53:36 +08:00
Esteban Küber
776544f011 Add message to rustc_on_unimplemented attributes in core 2018-06-19 15:19:13 -07:00
Cory Sherman
1440f300d8 stabilize RangeBounds collections_range #30877
rename RangeBounds::start() -> start_bound()
rename RangeBounds::end() -> end_bound()
2018-05-24 05:01:40 -07:00
varkor
ff0f00d318 Add doc comments mentioning unspecified behaviour upon exhaustion 2018-05-17 20:58:28 +01:00
varkor
1b3ecbcebb Stabilise into_inner 2018-05-17 20:58:28 +01:00
varkor
edad2eff0c Stabilise inclusive_range_methods 2018-05-17 20:58:28 +01:00
Mark Simulacrum
9e3432447a Switch to 1.26 bootstrap compiler 2018-05-17 08:47:25 -06:00
Sebastian Köln
23aa483102 add fn into_inner(self) -> (Idx, Idx) to RangeInclusive (#49022) 2018-05-09 18:03:13 +02:00
kennytm
f70b2ebd08
new() should be const; start()/end() after iteration is unspecified. 2018-05-01 01:45:18 +08:00
kennytm
c916ee8511
Removed direct field usage of RangeInclusive in rustc itself. 2018-05-01 01:45:18 +08:00
kennytm
fba903a435
Make the fields of RangeInclusive private.
Added new()/start()/end() methods to RangeInclusive.

Changed the lowering of `..=` to use RangeInclusive::new().
2018-04-30 21:01:13 +08:00
bors
1eb0cef62b Auto merge of #50149 - aaronaaeng:master, r=estebank
Added warning for unused arithmetic expressions

The compiler now displays a warning when a binary arithmetic operation is evaluated but not used.  This resolves #50124  by following the instructions outlined in the issue.  The changes are as follows:

- Added new pattern matching for unused arithmetic expressions in `src/librustc_lint/unused.rs`
- Added `#[must_use]` attributes to the binary operation methods in `src/libcore/internal_macros.rs`
- Added `#[must_use]` attributes to the non-assigning binary operators in `src/libcore/ops/arith.rs`
2018-04-28 04:14:12 +00:00
Guillaume Gomez
30e3f1a620 Add more doc aliases 2018-04-26 12:56:10 +02:00
Aaron Aaeng
91aa267eda Make must_use lint cover all binary/unary operators 2018-04-22 17:16:33 -06:00
Guillaume Gomez
84b91d6f5c add more aliases 2018-04-21 22:02:53 +02:00
bors
883bf4ba2e Auto merge of #49630 - npmccallum:shl, r=alexcrichton
Update Rhs on ShlAssign to default to Self

This matches the behavior on ShrAssign and all other *Assign operations.
2018-04-19 03:53:32 +00:00
bors
49317cd511 Auto merge of #49130 - smmalis37:range, r=alexcrichton
Move Range*::contains to a single default impl on RangeBounds

Per the ongoing discussion in #32311.

This is my first PR to Rust (woo!), so I don't know if this requires an amendment to the original range_contains RFC, or not, or if we can just do a psuedo-RFC here. While this may no longer follow the explicit decision made in that RFC, I believe this better follows its spirit by adding the new contains method to all Ranges. It also allows users to be generic over all ranges and use this method without writing it themselves (my personal desired use case).

This also somewhat answers the unanswered question about Wrapping ranges in the above issue by instead just punting it to the question of what those types should return for start() & end(), or if they should implement RangeArgument at all. Those types could also implement their own contains method without implementing this trait, in which case the question remains the same.

This does add a new contains method to types that already implemented RangeArgument but not contains. These types are RangeFull, (Bound<T>, Bound<T>), (Bound<&'a T>, Bound<&'a T>). No tests have been added for these types yet. No inherent method has been added either.

r? @alexcrichton
2018-04-16 16:07:10 +00:00
Andre Bogus
b744e3d7f5 [doc] note the special type inference handling for shifts 2018-04-13 18:30:57 +02:00
Steven Malis
51f24ec7f0 Add symmetric requirement of PartialOrd. 2018-04-10 19:41:10 -07:00
Steven Malis
249dc9e5cd Add float NaN tests. 2018-04-07 23:51:12 -07:00
Steven Malis
16f30c2da2 fix tests 2018-04-07 18:34:12 -07:00
Steven Malis
f5a367c7bb Update based on RangeBounds trait being moved to libcore. 2018-04-07 15:47:18 -07:00
Nathaniel McCallum
587098abf9 Consistently default operator Rhs/RHS to Self
Operator traits seem to be inconsistent regarding the right hand side
generic. Most default Rhs/RHS to Self, but a few omit this. This patch
modifies them all to default to Self. This should not have any backwards
compatibility issues because we are only enabling code that previously
wouldn't compile.
2018-04-06 09:41:05 -04:00
Aidan Hobson Sayers
9b5859aea1 Remove all unstable placement features
Closes #22181, #27779
2018-04-03 11:02:34 +02:00
Anders Pitman
da9e18b3db
Update drop.rs 2018-04-01 16:19:42 -07:00
kennytm
d06abdbfd8
Rollup merge of #49446 - frewsxcv:frewsxcv-mention-optiono, r=GuillaumeGomez
Explicitly mention `Option` in `?` error message.

Save users the time/effort of having to lookup what types implement
the `Try` trait.
2018-03-30 01:31:13 +02:00
Simon Sapin
124453e6fe impl RangeBounds<T> for Range{,From,To,Inclusive,ToInclusive}<&T> 2018-03-29 13:12:49 +02:00
Simon Sapin
16d3ba1b23 Move RangeArguments to {core::std}::ops and rename to RangeBounds
These unstable items are deprecated:

* The `std::collections::range::RangeArgument` reexport
* The `std::collections::range` module.
2018-03-29 13:12:49 +02:00
Simon Sapin
c3a63970de Move alloc::Bound to {core,std}::ops
The stable reexport `std::collections::Bound` is now deprecated.

Another deprecated reexport could be added in `alloc`,
but that crate is unstable.
2018-03-29 13:12:49 +02:00
Corey Farwell
1f143bc46f Explicitly mention Option in ? error message.
Save users the time/effort of having to lookup what types implement
the `Try` trait.
2018-03-28 13:04:44 +02:00
John Kåre Alsaker
57896abc38 Make resuming generators unsafe instead of the creation of immovable generators. Fixes #47787 2018-03-21 00:09:58 +01:00
kennytm
939cfa251a
Keep the fields of RangeInclusive unstable. 2018-03-15 17:01:30 +08:00
kennytm
92d1f8d8e4
Stabilize inclusive_range_syntax language feature.
Stabilize the syntax `a..=b` and `..=b`.
2018-03-15 16:58:02 +08:00
kennytm
b5913f2e76
Stabilize inclusive_range library feature.
Stabilize std::ops::RangeInclusive and std::ops::RangeInclusiveTo.
2018-03-15 16:58:01 +08:00
kennytm
c4b211bdba
Rollup merge of #48151 - echochamber:update_range_example, r=estebank
Update ops range example to avoid confusion between indexes and values.

Makes clearer the numbers in the range refer to indexes, not the values at those indexes.
2018-02-14 18:25:19 +08:00
kennytm
bd3674e4de
Rollup merge of #48087 - scottmcm:range_is_empty, r=kennytm,alexcrichton
Add Range[Inclusive]::is_empty

During https://github.com/rust-lang/rfcs/pull/1980, it was discussed that figuring out whether a range is empty was subtle, and thus there should be a clear and obvious way to do it.  It can't just be ExactSizeIterator::is_empty (also unstable) because not all ranges are ExactSize -- such as `Range<i64>` and `RangeInclusive<usize>`.

Things to ponder:
- Unless this is stabilized first, this makes stabilizing ExactSizeIterator::is_empty more icky, since this hides that.
- This is only on `Range` and `RangeInclusive`, as those are the only ones where it's interesting.  But one could argue that it should be on more for consistency, or on RangeArgument instead.
- The bound on this is PartialOrd, since that works ok (see tests for float examples) and is consistent with `contains`.  But ranges like `NAN..=NAN`_are_ kinda weird.
- [x] ~~There's not a real issue number on this yet~~
2018-02-14 16:14:33 +08:00
Jason Schein
bd426f1d69 Update ops range example to avoid confusion between indexes and values. 2018-02-11 17:54:44 -08:00
Scott McMurray
22b0489f80 Add the emptiness condition to the docs; add a PartialOrd example with NAN 2018-02-10 16:32:05 -08:00
Scott McMurray
6f70a11a83 range_is_empty tracking issue is #48111 2018-02-09 18:01:12 -08:00
Scott McMurray
b5cb393cf5 Use is_empty in range iteration exhaustion tests 2018-02-09 17:54:27 -08:00
Matthias Krüger
e6f910e31e fix typo: substract -> subtract. 2018-02-10 00:56:33 +01:00
Scott McMurray
4f8049a2b0 Add Range[Inclusive]::is_empty
During the RFC, it was discussed that figuring out whether a range is empty was subtle, and thus there should be a clear and obvious way to do it.  It can't just be ExactSizeIterator::is_empty (also unstable) because not all ranges are ExactSize -- not even Range<i32> or RangeInclusive<usize>.
2018-02-09 01:47:18 -08:00
Esteban Küber
2dee07b12a Remove cast suggestions 2018-02-01 15:06:22 -08:00
Esteban Küber
4c92a02b64 Change rustc_on_unimplemented for Iterator and binops 2018-02-01 15:06:21 -08:00
Esteban Küber
c1383e4dc4 Add filtering options to rustc_on_unimplemented
- filter error on the evaluated value of `Self`
 - filter error on the evaluated value of the type arguments
 - add argument to include custom note in diagnostic
 - allow the parser to parse `Self` when processing attributes
 - add custom message to binops
2018-02-01 15:06:20 -08:00
Taylor Cramer
f25f468709 Adjust wording of Placer trait safety requirements 2018-01-16 08:51:24 -08:00
Taylor Cramer
25574e58b6 Make core::ops::Place an unsafe trait 2018-01-09 11:39:23 -08:00