]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoNightly is currently 1.48
scottmcm [Sat, 5 Sep 2020 19:02:21 +0000 (19:02 +0000)]
Nightly is currently 1.48

3 years agoAdd `[T; N]: TryFrom<Vec<T>>`
Scott McMurray [Fri, 4 Sep 2020 02:59:51 +0000 (19:59 -0700)]
Add `[T; N]: TryFrom<Vec<T>>`

This is very similar to the existing `Box<[T; N]>: TryFrom<Box<[T]>>`, but allows avoiding the `shrink_to_fit` if you have a vector and not a boxed slice.

3 years agoAuto merge of #70793 - the8472:in-place-iter-collect, r=Amanieu
bors [Thu, 3 Sep 2020 21:20:21 +0000 (21:20 +0000)]
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`

3 years agofix debug assertion
The8472 [Thu, 3 Sep 2020 20:15:47 +0000 (22:15 +0200)]
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.

3 years agoAuto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomez
bors [Thu, 3 Sep 2020 19:07:38 +0000 (19:07 +0000)]
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!

3 years agoimprove comments and naming
The8472 [Wed, 2 Sep 2020 19:40:19 +0000 (21:40 +0200)]
improve comments and naming

3 years agoadd explanation to specialization marker
The8472 [Sun, 30 Aug 2020 00:15:45 +0000 (02:15 +0200)]
add explanation to specialization marker

3 years agoremove separate no-drop code path since it resulted in more LLVM IR
The8472 [Wed, 26 Aug 2020 21:32:09 +0000 (23:32 +0200)]
remove separate no-drop code path since it resulted in more LLVM IR

3 years agoremove empty Vec extend optimization
The8472 [Wed, 26 Aug 2020 21:24:34 +0000 (23:24 +0200)]
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

3 years agoplease tidy
The8472 [Fri, 21 Aug 2020 21:56:23 +0000 (23:56 +0200)]
please tidy

3 years agoget things to work under min_specialization by leaning more heavily on #[rustc_unsafe...
The8472 [Fri, 21 Aug 2020 21:53:13 +0000 (23:53 +0200)]
get things to work under min_specialization by leaning more heavily on #[rustc_unsafe_specialization_marker]

3 years agoavoid applying in-place collect specialization in type-length test
The8472 [Sun, 24 May 2020 01:23:15 +0000 (03:23 +0200)]
avoid applying in-place collect specialization in type-length test

the test was sized to match external iteration only, since
vec's in-place collect now uses internal iteration we collect into
a different type now.
Note that any other try-fold based operation such as count() would also
have exceeded the type length limit for that iterator.

3 years agofix benchmark compile errors
The8472 [Wed, 20 May 2020 23:34:05 +0000 (01:34 +0200)]
fix benchmark compile errors

3 years agoapply required min_specialization attributes
The8472 [Mon, 18 May 2020 22:44:16 +0000 (00:44 +0200)]
apply required min_specialization attributes

3 years agosupport in-place collect for MapWhile adapters
The8472 [Sat, 4 Apr 2020 16:34:18 +0000 (18:34 +0200)]
support in-place collect for MapWhile adapters

3 years agopacify tidy
The8472 [Sun, 2 Feb 2020 19:24:40 +0000 (20:24 +0100)]
pacify tidy

3 years agogeneralize in-place collect to types of same size and alignment
The8472 [Tue, 28 Jan 2020 14:14:55 +0000 (15:14 +0100)]
generalize in-place collect to types of same size and alignment

3 years agoincrease comment verbosity
The8472 [Sun, 26 Jan 2020 19:52:59 +0000 (20:52 +0100)]
increase comment verbosity

3 years agowork around compiler overhead around lambdas in generics by extracting them into...
The8472 [Sun, 26 Jan 2020 19:51:57 +0000 (20:51 +0100)]
work around compiler overhead around lambdas in generics by extracting them into free functions

3 years agoextract IntoIter drop/forget used by specialization into separate methods
The8472 [Sun, 26 Jan 2020 19:50:05 +0000 (20:50 +0100)]
extract IntoIter drop/forget used by specialization into separate methods

3 years agoadd benchmark to cover in-place extend
The8472 [Sat, 25 Jan 2020 19:08:46 +0000 (20:08 +0100)]
add benchmark to cover in-place extend

3 years agoremove redundant cast
The8472 [Sat, 25 Jan 2020 16:58:34 +0000 (17:58 +0100)]
remove redundant cast

3 years agotest drops during in-place iteration
The8472 [Sat, 25 Jan 2020 16:55:47 +0000 (17:55 +0100)]
test drops during in-place iteration

3 years agomove unsafety into method, not relevant to caller
The8472 [Sat, 25 Jan 2020 14:02:13 +0000 (15:02 +0100)]
move unsafety into method, not relevant to caller

3 years agoreplace unsafe ptr::write with deref-write, benchmarks show no difference
The8472 [Sat, 25 Jan 2020 14:01:39 +0000 (15:01 +0100)]
replace unsafe ptr::write with deref-write, benchmarks show no difference

3 years agopacify tidy
The8472 [Wed, 15 Jul 2020 18:53:03 +0000 (20:53 +0200)]
pacify tidy

3 years agoreplace drop flag with ManuallyDrop
The8472 [Sat, 18 Jan 2020 15:13:28 +0000 (16:13 +0100)]
replace drop flag with ManuallyDrop

3 years agomark as_inner as unsafe and update comments
The8472 [Sat, 18 Jan 2020 15:03:58 +0000 (16:03 +0100)]
mark as_inner as unsafe and update comments

3 years agoavoid exposing that binary heap's IntoIter is backed by vec::IntoIter, use a private...
The8472 [Fri, 20 Dec 2019 19:28:10 +0000 (20:28 +0100)]
avoid exposing that binary heap's IntoIter is backed by vec::IntoIter, use a private trait instead

3 years agofix: bench didn't black_box its results
The8472 [Sat, 30 Nov 2019 18:40:28 +0000 (19:40 +0100)]
fix: bench didn't black_box its results

3 years agofix build issue due to stabilized feature
The8472 [Sat, 30 Nov 2019 14:35:18 +0000 (15:35 +0100)]
fix build issue due to stabilized feature

3 years agoimpl TrustedRandomAccess for vec::IntoIter
The8472 [Fri, 29 Nov 2019 00:11:14 +0000 (01:11 +0100)]
impl TrustedRandomAccess for vec::IntoIter

3 years agobench larger allocations
The8472 [Wed, 27 Nov 2019 21:19:15 +0000 (22:19 +0100)]
bench larger allocations

3 years agoinclude in-place .zip() in test
The8472 [Wed, 27 Nov 2019 21:19:06 +0000 (22:19 +0100)]
include in-place .zip() in test

3 years agoremove unecessary feature flag
The8472 [Mon, 24 Aug 2020 20:09:44 +0000 (22:09 +0200)]
remove unecessary feature flag

# Conflicts:
# library/alloc/src/lib.rs

3 years agomake tidy happy
The8472 [Sat, 23 Nov 2019 18:34:26 +0000 (19:34 +0100)]
make tidy happy

3 years agosupport in-place iteration for most adapters
The8472 [Sat, 23 Nov 2019 17:59:18 +0000 (18:59 +0100)]
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

3 years agomove free-standing method into trait impl
The8472 [Sat, 23 Nov 2019 17:30:32 +0000 (18:30 +0100)]
move free-standing method into trait impl

3 years agoadd in-place iteration for Zip
The8472 [Sat, 23 Nov 2019 17:29:47 +0000 (18:29 +0100)]
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

3 years agobench in-place zip
The8472 [Sat, 23 Nov 2019 17:26:52 +0000 (18:26 +0100)]
bench in-place zip

3 years agoadditional specializations tests
The8472 [Sat, 23 Nov 2019 13:34:58 +0000 (14:34 +0100)]
additional specializations tests

3 years agofix some in-place-collect edge-cases
The8472 [Sat, 23 Nov 2019 13:32:20 +0000 (14:32 +0100)]
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

3 years agoremove redundant code
The8472 [Sat, 23 Nov 2019 13:30:10 +0000 (14:30 +0100)]
remove redundant code

3 years agoimprove comments
The8472 [Thu, 21 Nov 2019 12:44:28 +0000 (13:44 +0100)]
improve comments

3 years agospecialize creating a Vec from a slice iterator where T: Copy
The8472 [Thu, 21 Nov 2019 12:43:53 +0000 (13:43 +0100)]
specialize creating a Vec from a slice iterator where T: Copy

this was already implemented for Extend but not for FromIterator

3 years agorestore SpecFrom<T, TrustedLen<Item=T>> specialization by nesting
The8472 [Thu, 21 Nov 2019 12:40:49 +0000 (13:40 +0100)]
restore SpecFrom<T, TrustedLen<Item=T>> specialization by nesting
specializations

3 years agouse From specializations on extend if extended Vec is empty
The8472 [Thu, 21 Nov 2019 12:24:48 +0000 (13:24 +0100)]
use From specializations on extend if extended Vec is empty

this enables in-place iteration and allocation reuse in additional cases

3 years agoexercise more of the in-place pipeline in the bench
The8472 [Thu, 21 Nov 2019 00:01:35 +0000 (01:01 +0100)]
exercise more of the in-place pipeline in the bench

3 years agobench in-place collect of droppables
The8472 [Wed, 20 Nov 2019 23:06:31 +0000 (00:06 +0100)]
bench in-place collect of droppables

3 years agocyclic in-place reuse bench
The8472 [Wed, 20 Nov 2019 22:37:50 +0000 (23:37 +0100)]
cyclic in-place reuse bench

3 years agoreturn the things under test so they get black_box()'ed
The8472 [Wed, 20 Nov 2019 02:09:30 +0000 (03:09 +0100)]
return the things under test so they get black_box()'ed

3 years agoadd benches from bluss' gists
The8472 [Tue, 19 Nov 2019 22:10:43 +0000 (23:10 +0100)]
add benches from bluss' gists

3 years agouse memmove instead of generic in-place iteration for IntoIter source
The8472 [Sun, 17 Nov 2019 13:50:48 +0000 (14:50 +0100)]
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

3 years agorestore Vec::extend specialization for vec::IntoIter sources that
The8472 [Sun, 17 Nov 2019 11:49:18 +0000 (12:49 +0100)]
restore Vec::extend specialization for vec::IntoIter sources that
was lost during refactoring

3 years agohide binary_heap::IntoIter internals behind impl Trait
The8472 [Sun, 17 Nov 2019 11:04:12 +0000 (12:04 +0100)]
hide binary_heap::IntoIter internals behind impl Trait

3 years agoremove example that relied on non-public trait
The8472 [Sun, 17 Nov 2019 00:32:36 +0000 (01:32 +0100)]
remove example that relied on non-public trait

3 years agorecover vectorization
The8472 [Sat, 16 Nov 2019 21:31:23 +0000 (22:31 +0100)]
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

3 years agoupdate benches
The8472 [Sat, 16 Nov 2019 16:27:39 +0000 (17:27 +0100)]
update benches

3 years agosimplify pointer arithmetic
The8472 [Fri, 15 Nov 2019 20:02:54 +0000 (21:02 +0100)]
simplify pointer arithmetic

3 years agofix doc link
The8472 [Fri, 15 Nov 2019 20:01:13 +0000 (21:01 +0100)]
fix doc link

3 years agouse add instead of offset
The8472 [Fri, 15 Nov 2019 02:54:44 +0000 (03:54 +0100)]
use add instead of offset

3 years agoimplement drop handling
The8472 [Fri, 15 Nov 2019 01:37:55 +0000 (02:37 +0100)]
implement drop handling

3 years agoassert that SourceIter requirements have not been violated by the pipeline
The8472 [Fri, 15 Nov 2019 00:27:41 +0000 (01:27 +0100)]
assert that SourceIter requirements have not been violated by the pipeline

3 years agomark SourceIter as unsafe, document invariants
The8472 [Fri, 15 Nov 2019 00:18:30 +0000 (01:18 +0100)]
mark SourceIter as unsafe, document invariants

3 years agoin-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters
The8472 [Fri, 11 Oct 2019 18:43:25 +0000 (20:43 +0200)]
in-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters

3 years agobench
The8472 [Fri, 18 Oct 2019 22:00:45 +0000 (00:00 +0200)]
bench

3 years agounrelated typo fix
The8472 [Fri, 11 Oct 2019 18:42:32 +0000 (20:42 +0200)]
unrelated typo fix

3 years agoAuto merge of #76283 - RalfJung:miri, r=RalfJung
bors [Thu, 3 Sep 2020 16:00:55 +0000 (16:00 +0000)]
Auto merge of #76283 - RalfJung:miri, r=RalfJung

update miri

Fixes https://github.com/rust-lang/rust/issues/76190
Cc @rust-lang/miri r? @ghost

3 years agoupdate miri
Ralf Jung [Thu, 3 Sep 2020 10:41:27 +0000 (12:41 +0200)]
update miri

3 years agoAuto merge of #76235 - jyn514:std-intra-links, r=poliorcetics
bors [Thu, 3 Sep 2020 05:53:48 +0000 (05:53 +0000)]
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 :)

3 years agoAuto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum
bors [Thu, 3 Sep 2020 02:15:16 +0000 (02:15 +0000)]
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]( https://github.com/rust-lang/rust/blob/38fab2ea92a48980219989817201bf2094ae826a/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;
```

3 years agoApplied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi
Amjad Alsharafi [Thu, 27 Aug 2020 02:43:58 +0000 (10:43 +0800)]
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

3 years agoAuto merge of #76265 - Dylan-DPC:rollup-j3i509l, r=Dylan-DPC
bors [Thu, 3 Sep 2020 00:24:50 +0000 (00:24 +0000)]
Auto merge of #76265 - Dylan-DPC:rollup-j3i509l, r=Dylan-DPC

Rollup of 12 pull requests

Successful merges:

 - #75150 (Add a note for Ipv4Addr::to_ipv6_compatible)
 - #76120 (Add `[T; N]::as_[mut_]slice`)
 - #76142 (Make all methods of `std::net::Ipv4Addr` const)
 - #76164 (Link to slice pattern in array docs)
 - #76167 (Replace MinGW library hack with heuristic controlling link mode)
 - #76204 (Rename and expose LoopState as ControlFlow)
 - #76238 (Move to intra-doc links for library/core/src/iter/traits/iterator.rs)
 - #76242 (Read: adjust a FIXME reference)
 - #76243 (Fix typos in vec try_reserve(_exact) docs)
 - #76245 (inliner: Avoid query cycles when optimizing generators)
 - #76255 (Update books)
 - #76261 (Use intra-doc links in `core::marker`)

Failed merges:

r? @ghost

3 years agoRollup merge of #76261 - camelid:intra-doc-links-for-core-marker, r=jyn514
Dylan DPC [Thu, 3 Sep 2020 00:22:18 +0000 (02:22 +0200)]
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

3 years agoRollup merge of #76255 - ehuss:update-books, r=ehuss
Dylan DPC [Thu, 3 Sep 2020 00:22:16 +0000 (02:22 +0200)]
Rollup merge of #76255 - ehuss:update-books, r=ehuss

Update books

## reference

4 commits in 1b6c4b0afab97c0230433466c97167bbbe8445f6..25391dba46262f882fa846beefaff54a966a8fa5
2020-08-18 17:04:28 -0700 to 2020-09-02 07:22:55 -0700
- clarify when reading uninititalized memory is allowed (rust-lang-nursery/reference#852)
- Update patterns chapter, add rest patterns. (rust-lang-nursery/reference#876)
- Improve Type-Coersion Documentation (rust-lang-nursery/reference#843)
- Added variable back into example. (rust-lang-nursery/reference#880)

## book

3 commits in c0a6a61b8205da14ac955425f74258ffd8ee065d..e5ed97128302d5fa45dbac0e64426bc7649a558c
2020-08-14 14:21:49 -0500 to 2020-08-31 12:53:40 -0500
- Fix type mismatch in listing 10-5 (rust-lang/book#2441)
- Update ppendix-06-translation.md (rust-lang/book#2437)
- Correct no-listing-10-result-in-tests: Take tests module out of the main function (rust-lang/book#2430)

## rust-by-example

3 commits in 80a10e22140e28392b99d24ed02f4c6d8cb770a0..19f0a0372af497b34369cf182d9d16156cab2969
2020-08-08 09:56:46 -0300 to 2020-08-26 09:38:48 -0300
- prefer `length` over `size` when talking about number of elements vs. bytesize (rust-lang/rust-by-example#1372)
- Split out variable shadowing into a separate example (rust-lang/rust-by-example#1370)
- Update extern crate related sections (rust-lang/rust-by-example#1369)

## edition-guide

1 commits in bd6e4a9f59c5c1545f572266af77f5c7a5bad6d1..81f16863014de60b53de401d71ff904d163ee030
2020-07-12 17:37:08 -0500 to 2020-08-27 13:56:31 -0700
- Fix a small typo. (rust-lang/edition-guide#218)

3 years agoRollup merge of #76245 - tmiasko:inline-generators, r=ecstatic-morse
Dylan DPC [Thu, 3 Sep 2020 00:22:14 +0000 (02:22 +0200)]
Rollup merge of #76245 - tmiasko:inline-generators, r=ecstatic-morse

inliner: Avoid query cycles when optimizing generators

The HIR Id trick is insufficient to prevent query cycles when optimizing
generators, since merely requesting a layout of a generator also
computes its `optimized_mir`.

Make no attempts to inline functions into generators within the same
crate to avoid query cycles.

Fixes #76181.

3 years agoRollup merge of #76243 - ama0:patch-1, r=jonas-schievink
Dylan DPC [Thu, 3 Sep 2020 00:22:13 +0000 (02:22 +0200)]
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`.

3 years agoRollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC
Dylan DPC [Thu, 3 Sep 2020 00:22:11 +0000 (02:22 +0200)]
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:
https://github.com/rust-lang/rust/blob/5e208efaa850efaa97495e81c49cf0f5767e8f49/library/std/src/io/mod.rs#L369-L376

r? @Dylan-DPC

3 years agoRollup merge of #76238 - denisvasilik:intra-doc-links-core-iterator, r=jyn514
Dylan DPC [Thu, 3 Sep 2020 00:22:10 +0000 (02:22 +0200)]
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>`]

3 years agoRollup merge of #76204 - NoraCodes:nora/control_flow_enum, r=scottmcm
Dylan DPC [Thu, 3 Sep 2020 00:22:07 +0000 (02:22 +0200)]
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.

3 years agoRollup merge of #76167 - mati865:mingw-self-contained-heuristic, r=petrochenkov
Dylan DPC [Thu, 3 Sep 2020 00:22:06 +0000 (02:22 +0200)]
Rollup merge of #76167 - mati865:mingw-self-contained-heuristic, r=petrochenkov

Replace MinGW library hack with heuristic controlling link mode

Depends on https://github.com/rust-lang/rust/pull/76158
Closes https://github.com/rust-lang/rust/issues/68887

3 years agoRollup merge of #76164 - lzutao:slice-array, r=ehuss
Dylan DPC [Thu, 3 Sep 2020 00:22:04 +0000 (02:22 +0200)]
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

3 years agoRollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morse
Dylan DPC [Thu, 3 Sep 2020 00:22:02 +0000 (02:22 +0200)]
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

3 years agoRollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum
Dylan DPC [Thu, 3 Sep 2020 00:22:00 +0000 (02:22 +0200)]
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`.

3 years agoRollup merge of #75150 - nanpuyue:deprecate_to_ipv6_compatible, r=LukasKalbertodt
Dylan DPC [Thu, 3 Sep 2020 00:21:58 +0000 (02:21 +0200)]
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_

3 years agoAdd back missing link
Camelid [Wed, 2 Sep 2020 22:48:35 +0000 (15:48 -0700)]
Add back missing link

3 years agoUse intra-doc links in `core::marker`
Camelid [Wed, 2 Sep 2020 22:22:40 +0000 (15:22 -0700)]
Use intra-doc links in `core::marker`

3 years agoAuto merge of #76233 - cuviper:unhasher, r=Mark-Simulacrum
bors [Wed, 2 Sep 2020 22:16:22 +0000 (22:16 +0000)]
Auto merge of #76233 - cuviper:unhasher, r=Mark-Simulacrum

Avoid rehashing Fingerprint as a map key

This introduces a no-op `Unhasher` for map keys that are already hash-
like, for example `Fingerprint` and its wrapper `DefPathHash`. For these
we can directly produce the `u64` hash for maps. The first use of this
is `def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>`.

cc #56308
r? @eddyb

3 years agoFix incorrect link in prelude
Joshua Nelson [Wed, 2 Sep 2020 21:36:56 +0000 (17:36 -0400)]
Fix incorrect link in prelude

3 years agoRevert change to MaybeUninit until rustdoc bugs are fixed
Joshua Nelson [Wed, 2 Sep 2020 12:46:02 +0000 (08:46 -0400)]
Revert change to MaybeUninit until rustdoc bugs are fixed

https://github.com/rust-lang/rust/issues/76106

3 years agoConvert many files to intra-doc links
Joshua Nelson [Wed, 2 Sep 2020 03:39:16 +0000 (23:39 -0400)]
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.

3 years agoAuto merge of #76160 - scileo:format-recovery, r=petrochenkov
bors [Wed, 2 Sep 2020 19:29:27 +0000 (19:29 +0000)]
Auto merge of #76160 - scileo:format-recovery, r=petrochenkov

Improve recovery on malformed format call

The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues.

r? @petrochenkov

3 years agoFormat ControlFlow changes with rustfmt
Leonora Tindall [Wed, 2 Sep 2020 19:12:21 +0000 (14:12 -0500)]
Format ControlFlow changes with rustfmt

3 years agoUpdate books
Eric Huss [Wed, 2 Sep 2020 18:10:36 +0000 (11:10 -0700)]
Update books

3 years agoAuto merge of #75960 - camelid:patch-6, r=jyn514
bors [Wed, 2 Sep 2020 17:35:46 +0000 (17:35 +0000)]
Auto merge of #75960 - camelid:patch-6, r=jyn514

Improve docs for the `const` keyword

@rustbot modify labels: T-doc

3 years agoRevert link removal of Some(T)
Denis Vasilik [Wed, 2 Sep 2020 17:11:19 +0000 (19:11 +0200)]
Revert link removal of Some(T)

3 years agoRevert link removal of
Denis Vasilik [Wed, 2 Sep 2020 17:07:32 +0000 (19:07 +0200)]
Revert link removal of

3 years agoRevert link removal
Denis Vasilik [Wed, 2 Sep 2020 16:51:53 +0000 (18:51 +0200)]
Revert  link removal

3 years agoRevert module level documentation link
Denis Vasilik [Wed, 2 Sep 2020 16:51:08 +0000 (18:51 +0200)]
Revert module level documentation link

3 years agoApply suggestions from review
Denis Vasilik [Wed, 2 Sep 2020 16:32:46 +0000 (18:32 +0200)]
Apply suggestions from review