Commit Graph

6701 Commits

Author SHA1 Message Date
Michael Kohl
867ed2e17d Doc changes for assert macros
See #29381
2017-06-05 16:46:12 +07:00
king6cong
018722e485 doc rewording 2017-06-05 11:02:38 +08:00
Scott McMurray
808a08a363 Add overflow checking for str::get with inclusive ranges
Fixes #42401
2017-06-04 11:08:25 -07:00
Scott McMurray
18612b21d0 Delegate str:Index(Mut) to SliceIndex<str>
Move any extra logic that the former had into the latter, so they're consistent.
2017-06-04 01:47:21 -07:00
bors
0b17b4c084 Auto merge of #42265 - Zoxc:for-sugar, r=eddyb
Change for-loop desugar to not borrow the iterator during the loop

This is enables the use of suspend points inside for-loops in movable generators. This is illegal in the current desugaring as `iter` is borrowed across the body.
2017-06-04 05:44:39 +00:00
Mark Simulacrum
1316281f2d Rollup merge of #42310 - scottmcm:deprecate-range-stepby, r=alexcrichton
Deprecate range-specific `step_by`

Deprecation attributes and test updates only.

Was replaced by an any-iterator version in https://github.com/rust-lang/rust/pull/41439

Last follow-up (this release) to https://github.com/rust-lang/rust/pull/42110#issuecomment-303210138

r? @alexcrichton
2017-06-02 09:10:42 -06:00
bors
558cd1e393 Auto merge of #41670 - scottmcm:slice-rotate, r=alexcrichton
Add an in-place rotate method for slices to libcore

A helpful primitive for moving chunks of data around inside a slice.

For example, if you have a range selected and are drag-and-dropping it somewhere else (Example from [Sean Parent's talk](https://youtu.be/qH6sSOr-yk8?t=560)).

(If this should be an RFC instead of a PR, please let me know.)

Edit: changed example
2017-06-02 07:51:20 +00:00
bors
668e698bba Auto merge of #41418 - hirschenberger:prefetch-intrinsic, r=nagisa
Adding support for the llvm `prefetch` intrinsic

Optimize `slice::binary_search` by using prefetching.
2017-06-02 04:58:09 +00:00
John Kåre Alsaker
cfdbff7c12 Change for-loop desugar to not borrow the iterator during the loop 2017-06-01 18:33:47 +02:00
Falco Hirschenberger
f83901bb89 Adding support for the llvm prefetch intrinsic
Related to #37251
2017-06-01 08:34:16 +02:00
Scott McMurray
15dff84dc3 Avoid range::step_by in another test 2017-05-31 22:35:35 -07:00
Scott McMurray
1723e063c9 Deprecate iter::range::StepBy
Only exposed as DeprecatedStepBy (as of PR 41439)
2017-05-31 22:35:34 -07:00
Scott McMurray
0967e2495d Deprecate Range*::step_by
Changed all the tests except test_range_step to use Iterator::step_by.
2017-05-31 22:35:34 -07:00
Corey Farwell
dbc9d71b17 Rollup merge of #42275 - scottmcm:try-trait, r=nikomatsakis
Lower `?` to `Try` instead of `Carrier`

The easy parts of https://github.com/rust-lang/rfcs/pull/1859, whose FCP completed without further comments.

Just the trait and the lowering -- neither the error message improvements nor the insta-stable impl for Option nor exhaustive docs.

Based on a [github search](https://github.com/search?l=rust&p=1&q=question_mark_carrier&type=Code&utf8=%E2%9C%93), this will break the following:

- 00206e34c6/src/serialize.rs (L38)
- b1325898f4/src/result.rs (L50)

The other results appear to be files from libcore or its tests.  I could also leave Carrier around after stage0 and `impl<T:Carrier> Try for T` if that would be better.

r? @nikomatsakis

Edit: Oh, and it might accidentally improve perf, based on https://github.com/rust-lang/rust/issues/37939#issuecomment-265803670, since `Try::into_result` for `Result` is an obvious no-op, unlike `Carrier::translate`.
2017-06-01 00:09:20 -04:00
Irfan Hudda
18fadb61c4 Simplify helper functions
Based on @scottmcm 's suggestion
2017-05-31 22:25:15 +05:30
Mark Simulacrum
0c339ffbc0 Rollup merge of #42329 - rap2hpoutre:patch-6, r=steveklabnik
fix links to "module-level documentation"

see https://github.com/rust-lang/rust/issues/42267
2017-05-31 10:52:49 -06:00
Mark Simulacrum
b62eb7fed8 Rollup merge of #42315 - scottmcm:rangefrom-sizehint, r=alexcrichton
RangeFrom should have an infinite size_hint

Before,
```rust
(0..).take(4).size_hint() == (0, Some(4))
```

With this change,
```rust
(0..).take(4).size_hint() == (4, Some(4))
```
2017-05-31 10:52:48 -06:00
Mark Simulacrum
c0df1d4e80 Rollup merge of #42252 - stjepang:clarify-alignof-docs, r=nikomatsakis
Clarify the docs for align_of and its variants

It's okay to have unaligned raw pointers and then use `ptr::write_unaligned` and `ptr::read_unaligned`.
However, using unaligned `&T` and `&mut T` would be undefined behavior.

The current documentation seems to indicate that everything has to be aligned, but in reality only references do. This PR changes the text of docs accordingly.

r? @sfackler
2017-05-31 10:52:46 -06:00
Mark Simulacrum
d5a7fd585f Rollup merge of #42126 - clarcharr:into_docs, r=steveklabnik
Clarify docs on implementing Into.

This was suggested by @dtolnay in #40380.

This explicitly clarifies in what circumstances you should implement `Into` instead of `From`.
2017-05-31 10:52:44 -06:00
Raphaël Huchet
69f822524f fix links to "module-level documentation" 2017-05-31 11:38:19 +02:00
Scott McMurray
7a87469af7 Give the try_trait feature its own tracking issue 2017-05-31 01:30:13 -07:00
Stjepan Glavina
c25e271858 Add 'the' 2017-05-30 21:34:50 +02:00
Scott McMurray
265dce66b6 RangeFrom should have an infinite size_hint
This makes the size_hint from things like `take` more precise.
2017-05-30 09:15:25 -07:00
Clar Charr
54bbe23b2e Clarify docs on implementing Into. 2017-05-28 16:13:56 -04:00
Djzin
b795b7b43b restore old behaviour 2017-05-28 18:10:12 +01:00
Djzin
8a973dfa24 restore old behaviour for sizes < 128 2017-05-28 15:39:47 +01:00
bors
bcf95067e4 Auto merge of #42167 - scottmcm:iter-stepby-sizehint, r=alexcrichton
Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of https://github.com/rust-lang/rust/pull/42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
2017-05-28 14:26:52 +00:00
Mark Simulacrum
423b410fce Rollup merge of #42260 - stjepang:document-cmp-traits-agreement, r=alexcrichton
Docs: impls of PartialEq/PartialOrd/Ord must agree

Fixes #41270.

This PR brings two improvements to the docs:

1. Docs for `PartialEq`, `PartialOrd`, and `Ord` clarify that their implementations must agree.
2. Fixes a subtle bug in the Dijkstra example for `BinaryHeap`, where the impls are inconsistent.
Thanks @Rufflewind for spotting the bug!

r? @alexcrichton
cc @frankmcsherry
2017-05-27 20:54:04 -06:00
Djzin
d4d3f53468 better respect alignment for copying tail 2017-05-27 16:39:51 +01:00
Stjepan Glavina
f5421367a2 Docs: impls of PartialEq/PartialOrd/Ord must agree 2017-05-27 17:15:32 +02:00
Djzin
74751358e6 Merge remote-tracking branch 'upstream/master' into fast-swap 2017-05-27 14:31:47 +01:00
Djzin
c6307a2fa5 copy tail bytes better for aligned types 2017-05-27 14:29:41 +01:00
Stjepan Glavina
b559507680 Clarify the docs for align_of and its variants 2017-05-27 00:49:38 +02:00
bors
256e497fe6 Auto merge of #42245 - frewsxcv:rollup, r=frewsxcv
Rollup of 7 pull requests

- Successful merges: #42169, #42215, #42216, #42224, #42230, #42236, #42241
- Failed merges:
2017-05-26 15:31:49 +00:00
Corey Farwell
7e47327d90 Rollup merge of #42169 - scottmcm:new-step-trait-issue, r=alexcrichton
Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: https://github.com/rust-lang/rust/issues/27741
New issue: https://github.com/rust-lang/rust/issues/42168

r? @alexcrichton (another follow-up to closed PR https://github.com/rust-lang/rust/pull/42110#issuecomment-303176049)
2017-05-26 10:20:25 -04:00
bors
c732446edd Auto merge of #42014 - tbu-:pr_scan_not_fused, r=alexcrichton
Remove `FusedIterator` implementation of `iter::Scan`

Fixes #41964.

This is a breaking change.
2017-05-26 12:54:11 +00:00
Scott McMurray
ecde1e1d3b Lower ? to Try instead of Carrier
The easy parts of RFC 1859.  (Just the trait and the lowering, none of
the error message improvements nor the insta-stable impl for Option.)
2017-05-25 00:47:30 -07:00
Mark Simulacrum
a78a0dbe5f Rollup merge of #42195 - SamWhited:fix_broken_link, r=steveklabnik
fix broken link to nomicon in Unsize docs

Add a missing link that is currently broken in the docs (see the last sentence of https://doc.rust-lang.org/std/marker/trait.Unsize.html)
2017-05-24 19:50:09 -06:00
Mark Simulacrum
ca0860df66 Rollup merge of #42159 - Havvy:doc-drop, r=steveklabnik
Document drop more.

Adds two examples to Drop and describes the recursive drop on types that contain fields.
2017-05-24 19:50:06 -06:00
Mark Simulacrum
00c87a6486 Rollup merge of #42134 - scottmcm:rangeinclusive-struct, r=aturon
Make RangeInclusive just a two-field struct

Not being an enum improves ergonomics and consistency, especially since NonEmpty variant wasn't prevented from being empty.  It can still be iterable without an extra "done" bit by making the range have !(start <= end), which is even possible without changing the Step trait.

Implements merged https://github.com/rust-lang/rfcs/pull/1980; tracking issue https://github.com/rust-lang/rust/issues/28237.

This is definitely a breaking change to anything consuming `RangeInclusive` directly (not as an Iterator) or constructing it without using the sugar.  Is there some change that would make sense before this so compilation failures could be compatibly fixed ahead of time?

r? @aturon (as FCP proposer on the RFC)
2017-05-24 19:50:01 -06:00
Sam Whited
f6d935b455 fix broken link to nomicon in Unsize docs 2017-05-24 11:55:05 -05:00
Irfan Hudda
93219a2627 Add comments to explain helper functions 2017-05-23 23:04:23 +05:30
Scott McMurray
794e5724a8 Give step_trait a distinct tracking issue from step_by
iterator_step_by has decoupled their futures, so the tracking issue should split.
2017-05-23 03:08:18 -07:00
Scott McMurray
fcb3a7109c Update description of iter::StepBy 2017-05-23 02:25:08 -07:00
Scott McMurray
57f260d418 Override size_hint and propagate ExactSizeIterator for iter::StepBy
Generally useful, but also a prerequisite for moving a bunch of unit tests off Range::step_by.
2017-05-23 02:24:25 -07:00
Havvy
b41b2947d5 Suggested changes by birkenfeld 2017-05-22 23:49:35 -07:00
projektir
6e27bd8c01 Adding links to option::Option 2017-05-22 21:59:42 -04:00
Havvy
5f4b0ffe59 Fix trailing whitespace. 2017-05-22 16:33:55 -07:00
Havvy
d7927ffb8f Add description of how values are dropped to Drop trait. 2017-05-22 15:59:00 -07:00
Havvy
ca909c836f Add example of variable declaration drop order to Drop trait. 2017-05-22 15:15:04 -07:00