Commit graph

953 commits

Author SHA1 Message Date
bors
f76eda3f01 Auto merge of #76395 - dylni:adjust-documentation-for-slice-check-range, r=jyn514
Adjust documentation for slice_check_range

Adjust documentation for #76393.
2020-09-07 09:16:46 +00:00
Tobias Rapp
246d3271fe Implement Seek::stream_position() for BufReader
Optimization over BufReader::seek() for getting the current position
without flushing the internal buffer.

Related to #31100. Based on code in #70577.
2020-09-07 09:26:48 +02:00
bors
e114d6228b Auto merge of #76368 - ayushmishra2005:move_str_contact_library, r=jyn514
Added str tests in library

Added str tests in library  as a part of #76268

r? @matklad
2020-09-07 05:20:46 +00:00
bors
c133aac1e9 Auto merge of #76409 - jonas-schievink:fix-r-a-on-libcore, r=Mark-Simulacrum
Remove unneeded `#[cfg(not(test))]` from libcore

This fixes rust-analyzer inside these modules (currently it does not analyze them, assuming they're configured out).
2020-09-07 02:20:44 +00:00
Dylan DPC
5d8925905c
Rollup merge of #76358 - Wilfred:patch-3, r=lcnr
Minor grammar fix in doc comment for soft-deprecated methods
2020-09-07 01:18:15 +02:00
Dylan DPC
d444913840
Rollup merge of #76346 - gillespiecd:nlinks-docs, r=Dylan-DPC
Docs: nlink example typo

Small typo fix for the `nlink` function, extra whitespace before the `use` declaration
2020-09-07 01:18:13 +02:00
Dylan DPC
346d54d1f8
Rollup merge of #76344 - camelid:patch-6, r=KodrAus
Improve docs for `std::env::args()`

@rustbot modify labels: T-doc
2020-09-07 01:18:12 +02:00
Dylan DPC
9f69a232a6
Rollup merge of #76338 - euclio:intra-link-iterator, r=jyn514
add some intra-doc links to `Iterator`
2020-09-07 01:18:08 +02:00
Dylan DPC
1b24f1401d
Rollup merge of #76324 - ayushmishra2005:move_vec_tests_in_library, r=matklad
Move Vec slice UI tests in library

Moved some of Vec slice UI tests in Library as a part of #76268

r? @matklad
2020-09-07 01:18:07 +02:00
Dylan DPC
acd33e1d14
Rollup merge of #76318 - scottmcm:one-control-flow, r=ecstatic-morse
Use ops::ControlFlow in rustc_data_structures::graph::iterate

Since I only know about this because you mentioned it,
r? @ecstatic-morse

If we're not supposed to use new `core` things in compiler for a while then feel free to close, but it felt reasonable to merge the two types since they're the same, and it might be convenient for people to use `?` in their traversal code.

(This doesn't do the type parameter swap; NoraCodes has signed up to do that one.)
2020-09-07 01:18:05 +02:00
Dylan DPC
e735247289
Rollup merge of #76312 - numbermaniac:patch-1, r=shepmaster
time.rs: Make spelling of "Darwin" consistent

On line 89 of this file, the OS name is written as "Darwin", but on line 162 it is written in all-caps. Darwin is usually spelt as a standard proper noun, i.e. "Darwin", rather than in all-caps.

This change makes that form consistent in both places.
2020-09-07 01:18:03 +02:00
Dylan DPC
8ff13f4fd2
Rollup merge of #76309 - lzutao:indent-note, r=jyn514
Indent a note to make folding work nicer

Sublime Text folds code based on indentation. It maybe an unnecessary change, but does it look nicer after that ?
2020-09-07 01:18:01 +02:00
Dylan DPC
52d9162645
Rollup merge of #76305 - CDirkx:const-tests, r=matklad
Move various ui const tests to `library`

Move:
 - `src\test\ui\consts\const-nonzero.rs` to `library\core`
 - `src\test\ui\consts\ascii.rs` to `library\core`
 - `src\test\ui\consts\cow-is-borrowed` to `library\alloc`

Part of #76268

r? @matklad
2020-09-07 01:17:59 +02:00
Dylan DPC
5b8f76d564
Rollup merge of #76303 - jyn514:vec-assert-doc, r=Dylan-DPC
Link to `#capacity-and-reallocation` when using with_capacity

Follow up to https://github.com/rust-lang/rust/pull/76058#discussion_r479655750.
r? @pickfire
2020-09-07 01:17:56 +02:00
Dylan DPC
ee840db718
Rollup merge of #76302 - jyn514:peekable-2, r=Dylan-DPC
Address review comments on `Peekable::next_if`

r? @pickfire
See https://github.com/rust-lang/rust/pull/72310#pullrequestreview-480895893 for context.
2020-09-07 01:17:54 +02:00
Dylan DPC
2c62189db1
Rollup merge of #76299 - CDirkx:ip-tests, r=matklad
Make `Ipv4Addr` and `Ipv6Addr` const tests unit tests under `library`

These tests are about the standard library, not the compiler itself, thus should live in `library`, see #76268.
2020-09-07 01:17:52 +02:00
Dylan DPC
7ad2b3ab29
Rollup merge of #76287 - lzutao:rm-allowed, r=jyn514
Remove an unnecessary allowed lint

It is outdated.
2020-09-07 01:17:48 +02:00
Dylan DPC
e488c4f187
Rollup merge of #76273 - CraftSpider:master, r=matklad
Move some Vec UI tests into alloc unit tests

A bit of work towards #76268, makes a number of the Vec UI tests that are simply running code into unit tests. Ensured that they are being run when testing liballoc locally.
2020-09-07 01:17:45 +02:00
bors
73dc675b94 Auto merge of #76157 - ArekPiekarz:const_caller_location_tracking_issue, r=joshtriplett
Update tracking issue for const_caller_location

Update the tracking issue to https://github.com/rust-lang/rust/issues/76156, as suggested in https://github.com/rust-lang/rust/issues/76105.
2020-09-06 20:27:51 +00:00
bors
5d74e88006 Auto merge of #75949 - vext01:filter-docs, r=jyn514
Try to improve the documentation of `filter()` and `filter_map()`.

I believe the documentation is currently a little misleading.

For example, in the docs for `filter()`:

> If the closure returns `false`, it will try again, and call the closure on
> the next element, seeing if it passes the test.

This kind of implies that if the closure returns true then we *don't* "try
again" and no further elements are considered. In actuality that's not the
case, every element is tried regardless of what happened with the previous
element.

This change tries to clarify that by removing the uses of "try again"
altogether.
2020-09-06 18:26:33 +00:00
Jonas Schievink
24dc182f20 Remove unneeded #[cfg(not(test))] from libcore 2020-09-06 16:00:28 +02:00
bors
aa81d32165 Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus
Use Arc::clone and Rc::clone in documentation

This PR replaces uses of `x.clone()` by `Rc::clone(&x)` (or `Arc::clone(&x)`) to better match the documentation for those types.

@rustbot modify labels: T-doc
2020-09-06 12:34:31 +00:00
bors
23e49ddafb Auto merge of #76370 - fusion-engineering-forks:synconcecell-soundness, r=nagisa
Fix dropck issue of SyncOnceCell.

Fixes #76367.
2020-09-06 10:29:54 +00:00
Ayush Kumar Mishra
05d22c8519 Move test-cases in string.rs 2020-09-06 09:23:40 +05:30
dylni
cf529c767e Adjust documentation for slice_check_range 2020-09-05 19:53:35 -04:00
bors
cdc8f0606d Auto merge of #76217 - RalfJung:maybe-uninit-slice, r=KodrAus
rename MaybeUninit slice methods

The `first` methods conceptually point to the whole slice, not just its first element, so rename them to be consistent with the raw ptr methods on ref-slices.

Also, do the equivalent of https://github.com/rust-lang/rust/pull/76047 for the slice reference getters, and make them part of https://github.com/rust-lang/rust/issues/63569 (so far they somehow had no tracking issue).

* first_ptr -> slice_as_ptr
* first_ptr_mut -> slice_as_mut_ptr
* slice_get_ref -> slice_assume_init_ref
* slice_get_mut -> slice_assume_init_mut
2020-09-05 21:02:18 +00:00
bors
de921ab3c3 Auto merge of #75428 - the8472:fix-copy-eopnotsupp, r=joshtriplett
Workarounds for copy_file_range issues

fixes #75387
fixes #75446
2020-09-05 19:09:22 +00:00
Edd Barrett
8af85fa1f7 Improve the documentation of filter() and filter_map().
I believe the documentation is currently a little misleading.

For example, in the docs for `filter()`:

> If the closure returns `false`, it will try again, and call the closure on
> the next element, seeing if it passes the test.

This kind of implies that if the closure returns true then we *don't* "try
again" and no further elements are considered. In actuality that's not the
case, every element is tried regardless of what happened with the previous
element.

This change tries to clarify that by removing the uses of "try again"
altogether.
2020-09-05 19:59:30 +01:00
bors
04f44fb923 Auto merge of #75872 - mati865:pgo-tests, r=petrochenkov
Enable some of profiler tests on Windows-gnu

CC https://github.com/rust-lang/rust/issues/61266

Because of force-push GitHub didn't let me reopen https://github.com/rust-lang/rust/pull/75184

Because of the GCC miscompilation, generated binaries either segfault or `.profraw` is malformed. Clang works fine but we can't use it on the CI.
However we can still test the IR for the proper instrumentation so let's do it.
2020-09-05 17:18:26 +00:00
Ralf Jung
35068326b5 document remaining unsafety in maybe_uninit.rs 2020-09-05 17:24:22 +02:00
Ralf Jung
cff5f56886 rename MaybeUninit slice methods
first_ptr -> slice_as_ptr
first_ptr_mut -> slice_as_mut_ptr
slice_get_ref -> slice_assume_init_ref
slice_get_mut -> slice_assume_init_mut
2020-09-05 17:24:22 +02:00
Dylan DPC
86cf7976e2
Rollup merge of #76060 - pickfire:patch-12, r=jyn514
Link vec doc to & reference

It is not always obvious that people could see the docs for `&`
especially for beginners, it also helps learnability.
2020-09-05 16:28:24 +02:00
Dylan DPC
4bd3f266b0
Rollup merge of #75994 - mental32:impl-rc-new-cyclic, r=KodrAus
`impl Rc::new_cyclic`

References #75861

r? @Dylan-DPC
2020-09-05 16:28:22 +02:00
Mara Bos
e56ea68db5 Add compile_fail test for SyncOnceCell's dropck issue. 2020-09-05 15:55:20 +02:00
Mara Bos
578e714393 Fix dropck issue of SyncOnceCell.
Fixes #76367.
2020-09-05 14:10:10 +02:00
Ayush Kumar Mishra
5a0a58bbef Added str tests in library 2020-09-05 17:18:45 +05:30
Josh Stone
86b9f710d0 Move ArrayChunksMut::get_unchecked per #73565 2020-09-04 20:08:12 -07:00
Josh Stone
21903532ee Build the slice directly in array_chunks_mut
Review discussion found that the concern about aliasing was overblown,
so we can simplify this to cast from one slice to another directly.
2020-09-04 19:51:29 -07:00
Josh Stone
864a28e01d Re-export ArrayChunksMut in alloc 2020-09-04 19:51:29 -07:00
Josh Stone
b9fd6734e8 Add tests for array_chunks_mut 2020-09-04 19:51:29 -07:00
Josh Stone
f6a6d2fef6 Add slice::array_chunks_mut 2020-09-04 19:51:29 -07:00
Wilfred Hughes
4806e0ac93
Minor grammar fix in doc comment for soft-deprecated methods 2020-09-04 19:50:54 -07:00
Lzu Tao
dfd219d6e7 Indent a note to make folding work nicer
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-05 02:17:22 +00:00
Scott McMurray
59e37332b0 Add BREAK too, and improve the comments 2020-09-04 16:28:23 -07:00
bors
70c5f6efc4 Auto merge of #75200 - ssomers:btree_valmut, r=Mark-Simulacrum
BTreeMap: introduce marker::ValMut and reserve Mut for unique access

The mutable BTreeMap iterators (apart from `DrainFilter`) are double-ended, meaning they have to rely on a front and a back handle that each represent a reference into the tree. Reserve a type category `marker::ValMut` for them, so that we guarantee that they cannot reach operations on handles with borrow type `marker::Mut`and that these operations can assume unique access to the tree.

Including #75195, benchmarks report no genuine change:
```
benchcmp old new --threshold 5
 name                                 old ns/iter  new ns/iter  diff ns/iter   diff %  speedup
 btree::map::iter_100                 3,333        3,023                -310   -9.30%   x 1.10
 btree::map::range_unbounded_vs_iter  36,624       31,569             -5,055  -13.80%   x 1.16
```

r? @Mark-Simulacrum
2020-09-04 23:16:23 +00:00
Chris Gillespie
5456414d91 Fix nlink example typo 2020-09-04 14:41:27 -07:00
Camelid
85b11d50b2
Improve docs for std::env::args() 2020-09-04 14:00:09 -07:00
bors
c59199efca Auto merge of #76292 - Aaron1011:fix/proc-macro-panic-hide, r=petrochenkov
Respect `-Z proc-macro-backtrace` flag for panics inside libproc_macro

Fixes #76270

Previously, any panic occuring during a call to a libproc_macro method
(e.g. calling `Ident::new` with an invalid identifier) would always
cause an ICE message to be printed.
2020-09-04 20:58:37 +00:00
Andy Russell
2ed1a21790
add some intra-doc links to Iterator 2020-09-04 15:51:58 -04:00
Mateusz Mikuła
1ea121c74f Fix warning whe building profiler_builtins crate 2020-09-04 15:10:29 +02:00
bors
ef55a0a92f Auto merge of #75207 - dylni:add-slice-check-range, r=KodrAus
Add `slice::check_range`

This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](22ee68dc58/src/librustc_data_structures/sorted_map.rs (L214)) [many](22ee68dc58/library/alloc/src/vec.rs (L1299)) [times](22ee68dc58/library/core/src/slice/mod.rs (L2441)) in the standard library, sometimes assuming that the bounds won't be [`usize::MAX`].

For example, [`Vec::drain`] creates an empty iterator when [`usize::MAX`] is used as an inclusive end bound:

```rust
assert!(vec![1].drain(..=usize::max_value()).eq(iter::empty()));
```

If this PR is merged, I'll create another to use it for those methods.

[`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html
[`usize::MAX`]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.MAX
[`Vec::drain`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain
2020-09-04 12:21:43 +00:00
Ayush Kumar Mishra
d16bbd1cb0 Move Vec slice UI tests in library 2020-09-04 17:18:26 +05:30
Scott McMurray
fac272688e Use ops::ControlFlow in graph::iterate 2020-09-04 01:45:10 -07:00
numbermaniac
8f11127d89
time.rs: Make spelling of "Darwin" consistent 2020-09-04 14:21:52 +10:00
Lzu Tao
a3ee65f87e Remove a useless allowed attr 2020-09-04 02:42:50 +00:00
Ivan Tham
85146b9db7
Add slice primitive link to vec 2020-09-04 09:50:50 +08:00
Christiaan Dirkx
538e198193 Move various ui const tests to library
Move:
 - `src\test\ui\consts\const-nonzero.rs` to `library\core`
 - `src\test\ui\consts\ascii.rs` to `library\core`
 - `src\test\ui\consts\cow-is-borrowed` to `library\alloc`

Part of #76268
2020-09-04 02:35:27 +02:00
Joshua Nelson
7b823df489 Link to #capacity-and-reallocation when using with_capacity 2020-09-03 18:08:25 -04:00
Joshua Nelson
8c93125c17 Address review comments on Peekable::next_if 2020-09-03 18:03:33 -04:00
bors
0d0f6b1130 Auto merge of #70793 - the8472:in-place-iter-collect, r=Amanieu
specialize some collection and iterator operations to run in-place

This is a rebase and update of #66383 which was closed due inactivity.

Recent rustc changes made the compile time regressions disappear, at least for webrender-wrench. Running a stage2 compile and the rustc-perf suite takes hours on the hardware I have at the moment, so I can't do much more than that.

![Screenshot_2020-04-05 rustc performance data](https://user-images.githubusercontent.com/1065730/78462657-5d60f100-76d4-11ea-8a0b-4f3962707c38.png)

In the best case of the `vec::bench_in_place_recycle` synthetic microbenchmark these optimizations can provide a 15x speedup over the regular implementation which allocates a new vec for every benchmark iteration. [Benchmark results](https://gist.github.com/the8472/6d999b2d08a2bedf3b93f12112f96e2f). In real code the speedups are tiny, but it also depends on the allocator used, a system allocator that uses a process-wide mutex will benefit more than one with thread-local pools.

## What was changed

* `SpecExtend` which covered `from_iter` and `extend` specializations was split into separate traits
* `extend` and `from_iter` now reuse the `append_elements` if passed iterators are from slices.
* A preexisting `vec.into_iter().collect::<Vec<_>>()` optimization that passed through the original vec has been generalized further to also cover cases where the original has been partially drained.
* A chain of *Vec<T> / BinaryHeap<T> / Box<[T]>* `IntoIter`s  through various iterator adapters collected into *Vec<U>* and *BinaryHeap<U>* will be performed in place as long as `T` and `U` have the same alignment and size and aren't ZSTs.
* To enable above specialization the unsafe, unstable `SourceIter` and `InPlaceIterable` traits have been added. The first allows reaching through the iterator pipeline to grab a pointer to the source memory. The latter is a marker that promises that the read pointer will advance as fast or faster than the write pointer and thus in-place operation is possible in the first place.
* `vec::IntoIter` implements `TrustedRandomAccess` for `T: Copy` to allow in-place collection when there is a `Zip` adapter in the iterator. TRA had to be made an unstable public trait to support this.

## In-place collectible adapters

* `Map`
* `MapWhile`
* `Filter`
* `FilterMap`
* `Fuse`
* `Skip`
* `SkipWhile`
* `Take`
* `TakeWhile`
* `Enumerate`
* `Zip` (left hand side only, `Copy` types only)
* `Peek`
* `Scan`
* `Inspect`

## Concerns

`vec.into_iter().filter(|_| false).collect()` will no longer return a vec with 0 capacity, instead it will return its original allocation. This avoids the cost of doing any allocation or deallocation but could lead to large allocations living longer than expected.
If that's not acceptable some resizing policy at the end of the attempted in-place collect would be necessary, which in the worst case could result in one more memcopy than the non-specialized case.

## Possible followup work

* split liballoc/vec.rs to remove `ignore-tidy-filelength`
* try to get trivial chains such as `vec.into_iter().skip(1).collect::<Vec<)>>()` to compile to a `memmove` (currently compiles to a pile of SIMD, see #69187 )
* improve up the traits so they can be reused by other crates, e.g. itertools. I think currently they're only good enough for internal use
* allow iterators sourced from a `HashSet` to be in-place collected into a `Vec`
2020-09-03 21:20:21 +00:00
Christiaan Dirkx
a2e077e405 Make Ipv4Addr and Ipv6Addr const tests unit tests under library
These tests are about the standard library, not the compiler itself, thus should live in `library`, see #76268.
2020-09-03 23:17:21 +02:00
The8472
2f23a0fcca fix debug assertion
The InPlaceIterable debug assert checks that the write pointer
did not advance beyond the read pointer. But TrustedRandomAccess
never advances the read pointer, thus triggering the assert.
Skip the assert if the source pointer did not change during iteration.
2020-09-03 22:15:47 +02:00
Rune Tynan
2278c7255a
Remove vec-to_str.rs, merge the remaining test in with vec 2020-09-03 15:43:07 -04:00
bors
62dad457bc Auto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomez
rustdoc: do not use plain summary for trait impls

Fixes #38386.
Fixes #48332.
Fixes #49430.
Fixes #62741.
Fixes #73474.

Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy.

(In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.)

Ideally this could be fixed with intra-doc links ~~but it isn't working for me: I am currently investigating if it's possible to solve it this way.~~ Opened #73829.

EDIT: This is now ready!
2020-09-03 19:07:38 +00:00
The8472
8e5fe5569b improve comments and naming 2020-09-03 20:59:37 +02:00
The8472
6464586542 add explanation to specialization marker 2020-09-03 20:59:36 +02:00
The8472
acdd441cc3 remove separate no-drop code path since it resulted in more LLVM IR 2020-09-03 20:59:36 +02:00
The8472
435219dd82 remove empty Vec extend optimization
The optimization meant that every extend code path had to emit llvm
IR for from_iter and extend spec_extend, which likely impacts
compile times while only improving a few edge-cases
2020-09-03 20:59:35 +02:00
The8472
7492f76f77 please tidy 2020-09-03 20:59:34 +02:00
The8472
9aeea00222 get things to work under min_specialization by leaning more heavily on #[rustc_unsafe_specialization_marker] 2020-09-03 20:59:34 +02:00
The8472
a62cd1b44c fix benchmark compile errors 2020-09-03 20:59:33 +02:00
The8472
bec9f9223c apply required min_specialization attributes 2020-09-03 20:59:32 +02:00
The8472
80638330f2 support in-place collect for MapWhile adapters 2020-09-03 20:59:32 +02:00
The8472
55d1296a55 pacify tidy 2020-09-03 20:59:31 +02:00
The8472
5530858a08 generalize in-place collect to types of same size and alignment 2020-09-03 20:59:31 +02:00
The8472
fa34b39cd6 increase comment verbosity 2020-09-03 20:59:30 +02:00
The8472
872ab780c0 work around compiler overhead around lambdas in generics by extracting them into free functions 2020-09-03 20:59:29 +02:00
The8472
771b8ecc83 extract IntoIter drop/forget used by specialization into separate methods 2020-09-03 20:59:29 +02:00
The8472
6ad133443a add benchmark to cover in-place extend 2020-09-03 20:59:28 +02:00
The8472
a7a8b52e91 remove redundant cast 2020-09-03 20:59:28 +02:00
The8472
470bf54f94 test drops during in-place iteration 2020-09-03 20:59:27 +02:00
The8472
fe350dd82d move unsafety into method, not relevant to caller 2020-09-03 20:59:27 +02:00
The8472
0d2d033415 replace unsafe ptr::write with deref-write, benchmarks show no difference 2020-09-03 20:59:26 +02:00
The8472
9596e5a2f2 pacify tidy 2020-09-03 20:59:26 +02:00
The8472
6ed05fd995 replace drop flag with ManuallyDrop 2020-09-03 20:59:25 +02:00
The8472
ab382b7661 mark as_inner as unsafe and update comments 2020-09-03 20:59:24 +02:00
The8472
2a51e579f5 avoid exposing that binary heap's IntoIter is backed by vec::IntoIter, use a private trait instead 2020-09-03 20:59:24 +02:00
The8472
c731648e77 fix: bench didn't black_box its results 2020-09-03 20:59:23 +02:00
The8472
0856771248 fix build issue due to stabilized feature 2020-09-03 20:59:23 +02:00
The8472
e85cfa4f22 impl TrustedRandomAccess for vec::IntoIter 2020-09-03 20:59:22 +02:00
The8472
e1151844fa bench larger allocations 2020-09-03 20:59:22 +02:00
The8472
fd16202e36 include in-place .zip() in test 2020-09-03 20:59:21 +02:00
The8472
fbb3371e5b remove unecessary feature flag
# Conflicts:
#	library/alloc/src/lib.rs
2020-09-03 20:59:21 +02:00
The8472
70293c658f make tidy happy 2020-09-03 20:59:20 +02:00
The8472
21a17d105c support in-place iteration for most adapters
`Take` is not included since users probably call it with small constants
and it doesn't make sense to hold onto huge allocations in that case
2020-09-03 20:59:20 +02:00
The8472
085eb20a61 move free-standing method into trait impl 2020-09-03 20:59:19 +02:00
The8472
0f122e1119 add in-place iteration for Zip
this picks the left hand side as source since it might be more natural to
consume that as IntoIter source
2020-09-03 20:59:19 +02:00
The8472
3d5e9f1904 bench in-place zip 2020-09-03 20:59:18 +02:00
The8472
2b0b2ae9f6 additional specializations tests 2020-09-03 20:59:17 +02:00
The8472
00a32eb54f fix some in-place-collect edge-cases
- it's an allocation optimization, so don't attempt to do it on ZSTs
- drop the tail of partially exhausted iters
2020-09-03 20:59:17 +02:00
The8472
8c816b96dd remove redundant code 2020-09-03 20:59:16 +02:00
The8472
cc67c8eb91 improve comments 2020-09-03 20:59:16 +02:00
The8472
290fe895ba specialize creating a Vec from a slice iterator where T: Copy
this was already implemented for Extend but not for FromIterator
2020-09-03 20:59:15 +02:00
The8472
dac0edfaaa restore SpecFrom<T, TrustedLen<Item=T>> specialization by nesting
specializations
2020-09-03 20:59:15 +02:00
The8472
582fbb1d62 use From specializations on extend if extended Vec is empty
this enables in-place iteration and allocation reuse in additional cases
2020-09-03 20:59:14 +02:00
The8472
a596ff36b5 exercise more of the in-place pipeline in the bench 2020-09-03 20:59:14 +02:00
The8472
a9c78e371e bench in-place collect of droppables 2020-09-03 20:59:13 +02:00
The8472
8ac96e6a98 cyclic in-place reuse bench 2020-09-03 20:59:13 +02:00
The8472
bb4f888a59 return the things under test so they get black_box()'ed 2020-09-03 20:59:12 +02:00
The8472
2f700d085a add benches from bluss' gists 2020-09-03 20:59:12 +02:00
The8472
a4e385a0d0 use memmove instead of generic in-place iteration for IntoIter source
this is the original SpecExtend<_, IntoIter> logic except generalizing
the fast-path to include a memmove
2020-09-03 20:59:11 +02:00
The8472
631543dcb4 restore Vec::extend specialization for vec::IntoIter sources that
was lost during refactoring
2020-09-03 20:59:11 +02:00
The8472
07a8c1b95a hide binary_heap::IntoIter internals behind impl Trait 2020-09-03 20:59:10 +02:00
The8472
b90816deb7 remove example that relied on non-public trait 2020-09-03 20:59:10 +02:00
The8472
232065074d recover vectorization
switch to try_fold and segregate the drop handling to keep
collect::<Vec<u8>>() and similar optimizer-friendly

It comes at the cost of less accurate debug_asserts and code complexity
2020-09-03 20:59:09 +02:00
The8472
6c5c47b82b update benches 2020-09-03 20:59:09 +02:00
The8472
bead910b21 simplify pointer arithmetic 2020-09-03 20:59:08 +02:00
The8472
f904d0339a fix doc link 2020-09-03 20:59:07 +02:00
The8472
328a75f766 use add instead of offset 2020-09-03 20:59:07 +02:00
The8472
88b7ae642c implement drop handling 2020-09-03 20:59:06 +02:00
The8472
73a982e9ec assert that SourceIter requirements have not been violated by the pipeline 2020-09-03 20:59:06 +02:00
The8472
2a327394e4 mark SourceIter as unsafe, document invariants 2020-09-03 20:59:05 +02:00
The8472
bb2d533bb9 in-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters 2020-09-03 20:59:03 +02:00
The8472
038394a330 bench 2020-09-03 20:56:34 +02:00
The8472
076417e978 unrelated typo fix 2020-09-03 20:56:34 +02:00
Aaron Hill
53cce257ae
Respect -Z proc-macro-backtrace flag for panics inside libproc_macro
Fixes #76270

Previously, any panic occuring during a call to a libproc_macro method
(e.g. calling `Ident::new` with an invalid identifier) would always
cause an ICE message to be printed.
2020-09-03 12:13:26 -04:00
Ivan Tham
4df64905ea
Link & primitive using relative link 2020-09-03 23:02:27 +08:00
Jethro Beekman
0b5e681f5a Improve SGX RWLock initializer test 2020-09-03 10:29:49 +02:00
bors
08deb863bd Auto merge of #76235 - jyn514:std-intra-links, r=poliorcetics
Convert many files to intra-doc links

Helps with https://github.com/rust-lang/rust/issues/75080
r? @poliorcetics
I recommend reviewing one commit at a time, but the diff is small enough you can do it all at once if you like :)
2020-09-03 05:53:48 +00:00
Rune Tynan
3e29fdb0fb
Remove a number of vec UI tests, make them unit tests in the alloc library 2020-09-03 01:40:15 -04:00
bors
1e33c742ca Auto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum
Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi

partial fix for #73904

There are still more that was not applied in [mod.rs]( 38fab2ea92/library/std/src/sys/wasi/mod.rs) and that is due to its using files from `../unsupported`

like:
```
#[path = "../unsupported/cmath.rs"]
pub mod cmath;
```
2020-09-03 02:15:16 +00:00
Amjad Alsharafi
559679b8c3 Applied #![deny(unsafe_op_in_unsafe_fn)] in library/std/src/wasi
All refactoring needed was only in `alloc.rs`, changed part of the code
in `alloc` method to satisfy the SAFETY statement
2020-09-03 08:27:59 +08:00
Dylan DPC
af331a2d01
Rollup merge of #76261 - camelid:intra-doc-links-for-core-marker, r=jyn514
Use intra-doc links in `core::marker`

Part of #75080.

Also cleaned up a few things.

---

@rustbot modify labels: A-intra-doc-links T-doc
2020-09-03 02:22:18 +02:00
Dylan DPC
3368f5c820
Rollup merge of #76243 - ama0:patch-1, r=jonas-schievink
Fix typos in vec try_reserve(_exact) docs

`try_reserve` and `try_reserve_exact` docs refer to calling `reserve` and `reserve_exact`.
`try_reserve_exact` example uses `try_reserve` method instead of `try_reserve_exact`.
2020-09-03 02:22:13 +02:00
Dylan DPC
6d2b885112
Rollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC
Read: adjust a FIXME reference

There's already another reference to https://github.com/rust-lang/rust/issues/42788 for basically the same problem, so lets reuse it here:
5e208efaa8/library/std/src/io/mod.rs (L369-L376)

r? @Dylan-DPC
2020-09-03 02:22:11 +02:00
Dylan DPC
4918ed96ee
Rollup merge of #76238 - denisvasilik:intra-doc-links-core-iterator, r=jyn514
Move to intra-doc links for library/core/src/iter/traits/iterator.rs

Helps with #75080.

@jyn514 We're almost finished with this issue. Thanks for mentoring. If you have other topics to work on just let me know, I will be around in Discord.

@rustbot modify labels: T-doc, A-intra-doc-links

Known issues:

* Link from `core` to `std` (#74481):

    [`OsStr`]
    [`String`]
    [`VecDeque<T>`]
2020-09-03 02:22:10 +02:00
Dylan DPC
d059f2619f
Rollup merge of #76204 - NoraCodes:nora/control_flow_enum, r=scottmcm
Rename and expose LoopState as ControlFlow

Basic PR for #75744. Addresses everything there except for documentation; lots of examples are probably a good idea.
2020-09-03 02:22:07 +02:00
Dylan DPC
3e156cfe90
Rollup merge of #76164 - lzutao:slice-array, r=ehuss
Link to slice pattern in array docs

Fix a todo in https://github.com/rust-lang/reference/issues/739#issuecomment-578408449
2020-09-03 02:22:04 +02:00
Dylan DPC
9605f94f69
Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morse
Make all methods of `std::net::Ipv4Addr` const

Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature:
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_global` (unstable)
 - `is_shared` (unstable)
 - `is_ietf_protocol_assignment` (unstable)
 - `is_benchmarking` (unstable)
 - `is_reserved` (unstable)
 - `is_multicast`
 - `is_broadcast`
 - `is_documentation`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

This would make all methods of `Ipv6Addr` const.

Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation.

Part of #76205
2020-09-03 02:22:02 +02:00
Dylan DPC
10aa3d3f89
Rollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum
Add `[T; N]::as_[mut_]slice`

Part of me trying to populate arrays with a couple of basic useful methods, like slices already have. The ability to add methods to arrays were added in #75212.  Tracking issue: #76118

This adds:

```rust
impl<T, const N: usize> [T; N] {
    pub fn as_slice(&self) -> &[T];
    pub fn as_mut_slice(&mut self) -> &mut [T];
}
```

These methods are like the ones on `std::array::FixedSizeArray` and in the crate `arraytools`.
2020-09-03 02:22:00 +02:00
Dylan DPC
536b0c0c90
Rollup merge of #75150 - nanpuyue:deprecate_to_ipv6_compatible, r=LukasKalbertodt
Add a note for Ipv4Addr::to_ipv6_compatible

Previous discussion: #75019

> I think adding a comment saying "This isn't typically the method you want; these addresses don't typically function on modern systems. Use `to_ipv6_mapped` instead." would be a good first step, whether this method gets marked as deprecated or not.

_Originally posted by @joshtriplett in https://github.com/rust-lang/rust/pull/75150#issuecomment-680267745_
2020-09-03 02:21:58 +02:00
Camelid
7926435317
Add back missing link 2020-09-02 15:48:35 -07:00
Camelid
2908ed64aa Use intra-doc links in core::marker 2020-09-02 15:22:40 -07:00
Joshua Nelson
bb103476a9 Fix incorrect link in prelude 2020-09-02 17:38:21 -04:00
Joshua Nelson
44bacc3ffa Revert change to MaybeUninit until rustdoc bugs are fixed
https://github.com/rust-lang/rust/issues/76106
2020-09-02 17:38:21 -04:00
Joshua Nelson
59a1a05bff Convert many files to intra-doc links
- Use intra-doc links for `std::io` in `std::fs`
- Use intra-doc links for File::read in unix/ext/fs.rs
- Remove explicit intra-doc links for `true` in `net/addr.rs`
- Use intra-doc links in alloc/src/sync.rs
- Use intra-doc links in src/ascii.rs
- Switch to intra-doc links in alloc/rc.rs
- Use intra-doc links in core/pin.rs
- Use intra-doc links in std/prelude
- Use shorter links in `std/fs.rs`

  `io` is already in scope.
2020-09-02 17:37:40 -04:00
Leonora Tindall
96eb5e1751 Format ControlFlow changes with rustfmt 2020-09-02 14:12:21 -05:00
bors
a167485e27 Auto merge of #75960 - camelid:patch-6, r=jyn514
Improve docs for the `const` keyword

@rustbot modify labels: T-doc
2020-09-02 17:35:46 +00:00
Denis Vasilik
89e7fb3bbd Revert link removal of Some(T) 2020-09-02 19:11:19 +02:00
Denis Vasilik
83143a1ef4 Revert link removal of 2020-09-02 19:07:32 +02:00