Commit graph

543 commits

Author SHA1 Message Date
Guillaume Gomez
a3b45f3e54 Convert links to intra-doc links format 2020-08-21 20:28:57 +02:00
LeSeulArtichaut
97072c6b90 Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-21 19:31:00 +02:00
Denis Vasilik
37b6c249ed Rework imports used solely for docs 2020-08-21 19:19:58 +02:00
Denis Vasilik
0f6d95d1eb Apply auto-formatter 2020-08-21 18:50:09 +02:00
Denis Vasilik
0bccd9809e Incorporate suggestions from review 2020-08-21 18:35:17 +02:00
bors
efec7cde93 Auto merge of #75694 - RalfJung:miri-align-to, r=nagisa
enable align_to tests in Miri

With https://github.com/rust-lang/miri/issues/1074 resolved, we can enable these tests in Miri.

I also tweaked the test sized to get reasonable execution times with decent test coverage.
2020-08-21 15:40:48 +00:00
Tomasz Miąsko
78e094632e Remove wrapper type handling absent raw standard streams
Raw standard streams are always available.  Remove unused wrapper type
that was supposed to be responsible for handling their absence.
2020-08-21 13:17:20 +02:00
Tomasz Miąsko
4a00421ba4 Make raw standard stream constructors const 2020-08-21 13:17:20 +02:00
Tomasz Miąsko
479c23bb49 Remove result type from raw standard streams constructors
Raw standard streams constructors are infallible. Remove unnecessary
result type.
2020-08-21 13:17:20 +02:00
Yuki Okushi
2a7f868d7f
Rollup merge of #75750 - poliorcetics:intra-links-std-thread, r=jyn514
Move to intra doc links for std::thread documentation

Helps with #75080.

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

r? @jyn514
2020-08-21 17:55:15 +09:00
Yuki Okushi
cccb8892e9
Rollup merge of #75727 - camelid:intra-doc-links-for-core-result, r=jyn514
Switch to intra-doc links in `core::result`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-21 17:55:14 +09:00
Yuki Okushi
f2d25538d4
Rollup merge of #75324 - ericseppanen:master, r=JohnTitor
clarify documentation of remove_dir errors

remove_dir will error if the path doesn't exist or isn't a directory.

It's useful to clarify that this is "remove dir or fail" not "remove dir
if it exists".

I don't think this belongs in the title. "Removes an existing, empty
directory" is strangely worded-- there's no such thing as a non-existing
directory.  Better to just say explicitly it will return an error.
2020-08-21 17:55:08 +09:00
bors
d9d4d39612 Auto merge of #73565 - matthewjasper:core-min-spec, r=nagisa
Use min_specialization in libcore

Getting `TrustedRandomAccess` to work is the main interesting thing here.

- `get_unchecked` is now an unstable, hidden method on `Iterator`
- The contract for `TrustedRandomAccess` is made clearer in documentation
- Fixed a bug where `Debug` would create aliasing references when using the specialized zip impl
- Added tests for the side effects of `next_back` and `nth`.

closes #68536
2020-08-20 23:05:31 +00:00
LeSeulArtichaut
1ababd8794 Use intra-doc-links in alloc 2020-08-21 00:25:25 +02:00
Alexis Bourget
fb3f927131 Move to intra doc links for std::thread documentation 2020-08-20 22:03:00 +02:00
Camelid
5a307cf4bb
Fix intra-doc links
One of the original links was linking to the wrong thing as well.

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-20 12:39:12 -07:00
Josh Stone
6ac1523b23
Rollup merge of #75733 - pickfire:patch-3, r=matklad
Remove duplicated alloc vec bench push_all_move

push_all_move is the same as extend
2020-08-20 10:07:32 -07:00
Josh Stone
7ac126ec56
Rollup merge of #75703 - tmiasko:stack-overflow-musl, r=cuviper
Enable stack-overflow detection on musl for non-main threads
2020-08-20 10:07:24 -07:00
Josh Stone
f29f21285e
Rollup merge of #75672 - kofls:intradoc-fix, r=jyn514
Move to intra-doc links for task.rs and vec.rs

Partial fix for #75080

links for [`get`], [`get_mut`] skipped due to #75643
link for [`copy_from_slice`] skipped due to #63351
2020-08-20 10:07:19 -07:00
Ivan Tham
4f2e182c5f
Liballoc bench rename push_all extend_from_slice 2020-08-20 19:04:52 +08:00
Tim Diekmann
46b547cb58 Assume same alignment in RawVec 2020-08-20 11:56:46 +02:00
Ivan Tham
2932d4e634
Remove duplicated alloc vec bench push_all_move
push_all_move is the same as extend
2020-08-20 15:20:46 +08:00
Camelid
22c02bfdb1
Revert to old link since intra-doc link is broken
Can't link from `core` to `std` yet.
2020-08-19 18:17:55 -07:00
Tim Diekmann
303ee3fd83
Add debug assertion for equal alignment in RawVec 2020-08-20 01:01:46 +02:00
bors
5f6fcad644 Auto merge of #75563 - richkadel:llvm-coverage-map-gen-5.4, r=wesleywiser
Moved coverage counter injection from BasicBlock to Statement.

As discussed on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implement.20LLVM-compatible.20source-based.20cod.20compiler-team.23278
2020-08-19 22:48:40 +00:00
Camelid
e0430a8aa2 Switch to intra-doc links in core::result 2020-08-19 14:02:34 -07:00
Matthew Jasper
dbad8c9368 Use min_specialization in libcore 2020-08-19 20:08:02 +01:00
Tyler Mandry
ad3db41182
Rollup merge of #75696 - matklad:mirit, r=RalfJung
Remove `#[cfg(miri)]` from OnceCell tests

They were carried over from once_cell crate, but they are not entirely
correct (as miri now supports more things), and we don't run miri
tests for std, so let's just remove them.

Maybe one day we'll run miri in std, but then we can just re-install
these attributes.
2020-08-19 11:12:25 -07:00
Tyler Mandry
0fdc8c06dd
Rollup merge of #75674 - poliorcetics:intra-links-std-io, r=jyn514
Move to intra doc links for std::io

Helps with #75080.

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

r? @jyn514

I had no problems with those files so I added some small links here and there.
2020-08-19 11:12:23 -07:00
Tyler Mandry
4123237fa1
Rollup merge of #75648 - matklad:lazy-dropck, r=KodrAus
Make OnceCell<T> transparent to dropck

See the failed build in

https://github.com/rust-lang/rust/pull/75555#issuecomment-675016718

for an example where we need this in real life

r? @ghost
2020-08-19 11:12:20 -07:00
bors
443e177c7f Auto merge of #75480 - ssomers:btree_check_invariant, r=Mark-Simulacrum
BTreeMap: check some invariants in unit tests
2020-08-19 15:27:40 +00:00
Denis Vasilik
f71919c3db Fix anchor links 2020-08-19 16:44:20 +02:00
Alexis Bourget
dad8e11e9f Fix nits in intra-doc links for std io 2020-08-19 16:26:17 +02:00
Denis Vasilik
6e2f076917 Use intra-doc links for links with anchors 2020-08-19 15:22:04 +02:00
Denis Vasilik
d1838f6c73 Use intra-doc links for compare_exchange and compare_exchange_weak 2020-08-19 15:12:28 +02:00
Denis Vasilik
751e343ab2 Use intra-doc linkks 2020-08-19 14:13:53 +02:00
Denis Vasilik
d339cfe4a1 Use intra-doc links for ptr::* 2020-08-19 13:38:22 +02:00
bors
11a44adc6f Auto merge of #75600 - nagisa:improve_align_offset, r=KodrAus
Improve codegen for `align_offset`

In this PR the `align_offset` implementation is changed/improved to produce better code in certain scenarios such as when pointer type is has a stride of 1 or when building for low optimisation levels.

While these changes do not achieve the "ideal" codegen referenced in #75579, it gets significantly closer to it. I’m not actually sure if the codegen can actually be much better with this function returning the offset, rather than the aligned pointer.

See the descriptions for separate commits for further information.
2020-08-19 10:54:44 +00:00
Denis Vasilik
2c7998720c Use intra-doc links for mem::* 2020-08-19 12:38:32 +02:00
Denis Vasilik
45b4e1470c Use intra-doc links for sync::* 2020-08-19 12:16:16 +02:00
Denis Vasilik
fb7d9170f4 Use intra-doc links for f32::* and f64::* 2020-08-19 12:04:23 +02:00
Ralf Jung
6a06bfc252 enable align_to tests in Miri 2020-08-19 10:41:51 +02:00
Aleksey Kladov
34e7eac1ca Remove #[cfg(miri)] from OnceCell tests
They were carried over from once_cell crate, but they are not entirely
correct (as miri now supports more things), and we don't run miri
tests for std, so let's just remove them.

Maybe one day we'll run miri in std, but then we can just re-install
these attributes.
2020-08-19 10:28:22 +02:00
Denis Vasilik
a929738478 Use intra-doc links for u32::* 2020-08-19 10:19:06 +02:00
Denis Vasilik
7b5ec9e9e0 Use intra-doc links for AtomicU32::* 2020-08-19 09:58:41 +02:00
Denis Vasilik
2373dbce83 Use intra-doc links for AtomicI32::* 2020-08-19 09:52:19 +02:00
Yuki Okushi
07ea340e89
Rollup merge of #75685 - nixphix:docs/unix-ext, r=jyn514
Switch to intra-doc links in /src/sys/unix/ext/*.rs

Partial fix for #75080

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

r? @jyn514

These two links are not resolving to either `crate::fs::File...` or `fs::File...`
```
# unix/ext/fs.rs
   27:    /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read

  130:   /// [`File::write`]: ../../../../std/fs/struct.File.html#method.write
```
2020-08-19 15:54:39 +09:00
Yuki Okushi
9cf390357b
Rollup merge of #75646 - poliorcetics:intra-links-keywords, r=jyn514
Move to intra doc links for keyword documentation

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-19 15:54:32 +09:00
Yuki Okushi
ac264b53d1
Rollup merge of #75499 - jack-champagne:jack-champagne/issue-75412, r=Dylan-DPC
Fix documentation error

This should fix #75412. Just a quick >= to > sign replacement.
2020-08-19 15:54:28 +09:00
Yuki Okushi
1f4f31785e
Rollup merge of #75049 - janriemer:patch-1, r=poliorcetics
docs(marker/copy): provide example for `&T` being `Copy`

### Edited 2020-08-16 (most recent)
In the current documentation about the `Copy` marker trait, there is a section
with examples of structs that can implement `Copy`. Currently there is no example for
showing that shared references (`&T`) are also `Copy`.
It is worth to have a dedicated example for `&T` being `Copy`, because shared
references are an integral part of the language and it being `Copy` is not as
intuitive as other types that share this behaviour like `i32` or `bool`.

The example picks up on the previous non-`Copy` struct and shows that
structs can be `Copy`, even when they hold a shared reference to a non-`Copy` type.

-----------------------------------------
### Edited 2020-08-02, 3:28 p.m.
I've just realized that it says "in addition to the **implementors listed below**", which makes this PR kind of "wrong", because `&T` is indeed in the "implementors listed below".
Maybe we can instead show an example with `&T` in the [When can my type be Copy](https://doc.rust-lang.org/std/marker/trait.Copy.html#when-can-my-type-be-copy) section.

What I really want to achieve is that it becomes more obvious that `&T` is also `Copy`, because, I think, it is very valuable to know and it wasn't obvious for me, until I read something about it in a forum post.

What do you think? I would create another PR for that.
**Please feel free to close this PR.**

-----------------------------------
### Original post
In the current documentation about the `Copy` marker trait, there is a section
about "additional implementors", which list additional implementors of the `Copy` trait.
The fact that shared references are also `Copy` is mixed with another point,
which makes it hard to recognize and make it seem not as important.

This clarifies the fact that shared references are also `Copy`, by mentioning it as a
separate item in the list of "additional implementors".
2020-08-19 15:54:26 +09:00
Yuki Okushi
17d3ce457f
Rollup merge of #75038 - rust-lang:Havvy-patch-1, r=steveklabnik
See also X-Link mem::{swap, take, replace}

Since it's easy to end up at one of these functions when you really wanted the other one, cross link them with descriptions of why you'd want to use them.
2020-08-19 15:54:24 +09:00
Surya Midatala
632db79ad6 Apply suggestions from code review 2020-08-19 10:29:31 +05:30
Tim Diekmann
438c40efa1 Allow reallocation to different alignment 2020-08-19 06:46:47 +02:00
Rich Kadel
d129ac2655 Moved coverage counter injection from BasicBlock to Statement. 2020-08-18 21:06:45 -07:00
Lzu Tao
768509ff84 Minor changes to Ipv4Addr
* Impl IntoInner rather than AsInner for Ipv4Addr
* Add some comments
* Add test to show endiannes of Ipv4Addr display
2020-08-19 03:27:24 +00:00
bors
c03c213daf Auto merge of #75677 - cuviper:shrink-towel, r=Mark-Simulacrum
Don't panic in Vec::shrink_to_fit

We can help the compiler see that `Vec::shrink_to_fit` will never reach the panic case in `RawVec::shrink_to_fit`, just by guarding the call only for cases where the capacity is strictly greater. A capacity less than the length is only possible through an unsafe call to `set_len`, which would break the `Vec` invariants, so `shrink_to_fit` can just ignore that.

This removes the panicking code from the examples in both #71861 and #75636.
2020-08-19 02:56:59 +00:00
Prabakaran Kumaresshan
63d2e9b05f resolve comments 2020-08-19 06:19:35 +05:30
Prabakaran Kumaresshan
3e3a2c82f3 Switch to intra-doc links in /src/sys/unix/ext/*.rs 2020-08-19 05:43:55 +05:30
Tomasz Miąsko
6a80b1387f Enable stack-overflow detection on musl for non-main threads 2020-08-19 00:00:00 +00:00
Denis Vasilik
076ae25714 Use intra-doc links for AtomicIsize::* 2020-08-19 00:10:57 +02:00
Denis Vasilik
69e5a4ccaa Use intra-doc links for AtomicBool::* 2020-08-19 00:05:49 +02:00
Denis Vasilik
c159e1764a Use intra-doc links for Ordering::* 2020-08-18 23:42:38 +02:00
Josh Stone
7551f3fbbd Don't panic in Vec::shrink_to_fit 2020-08-18 11:45:40 -07:00
Alexis Bourget
5d49c0e55a Move to intra doc links for std::io 2020-08-18 19:36:52 +02:00
Jan Riemer
522d177f34 docs: add another derive for Copyable struct
This adds another `derive` for a `Copy`able struct, so that we are
consistent with `derive` annotations.
2020-08-18 18:40:19 +02:00
Surya Midatala
11f69796ee Move to intra-doc links for task.rs and vec.rs 2020-08-18 21:47:23 +05:30
Tim Diekmann
63d241a7b7 Make grow_impl unsafe 2020-08-18 15:22:10 +02:00
Stein Somers
8c4641b37f BTreeMap: check some invariants, avoid recursion in depth first search 2020-08-18 13:00:10 +02:00
Tim Diekmann
66a651244e Add comment, which was removed by accident (again) 2020-08-18 10:00:31 +02:00
Tim Diekmann
a9fe0ca47a Clean up AllocRef implementation and documentation 2020-08-18 09:53:22 +02:00
bors
515c9fa505 Auto merge of #75621 - TimDiekmann:no-fast-realloc, r=Amanieu
Remove fast path in reallocation for same layout sizes

r? @Amanieu

Before merging a perf-run should be done.

Closes https://github.com/rust-lang/wg-allocators/issues/70
2020-08-18 05:42:05 +00:00
Yuki Okushi
732bebd854
Rollup merge of #75629 - EllenNyan:ellen-intra-doc-links, r=jyn514
Use intra-doc links in `std::env`, `std::alloc` and `std::error`

This is partial fixes for #75080.
2020-08-18 09:27:51 +09:00
Yuki Okushi
d18719bbaf
Rollup merge of #75464 - poliorcetics:intra-links-panic-and-ascii, r=jyn514
Move to intra doc links for ascii.rs and panic.rs

Helps with #75080.

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

I also updated the doc to fix the wording in `AsciiExt` since it is now deprecated.
The two file are small changes so I bundled them together.

Some links could not be changed to make them work, I believe those are known issues with primitive types.
2020-08-18 09:27:43 +09:00
Yuki Okushi
5498367faf
Rollup merge of #75392 - TimDiekmann:non-null-uninit-slice, r=RalfJung
Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods

This adds a convenient method to retrieve a `&(mut) [MaybeUninit<T>]` from slice pointers (`*const [T]`, `*mut [T]`, `NonNull<[T]>`). See also https://github.com/rust-lang/wg-allocators/issues/66#issuecomment-671789105.

~I'll add a tracking issue as soon as it's reviewed and CI passed.~
Tracking Issue: #75402

r? @RalfJung
2020-08-18 09:27:42 +09:00
Aleksey Kladov
695d86f584 Make OnceCell<T> transparent to dropck
See the failed build in

https://github.com/rust-lang/rust/pull/75555#issuecomment-675016718

for an example where we need this in real life
2020-08-18 00:34:54 +02:00
bors
792c645ca7 Auto merge of #75145 - davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov
Reference lang items during AST lowering

Fixes #60607 and fixes #61019.

This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols:

- Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](a227c706b7 (diff-c0f791ead38d2d02916faaad0f56f41d)).
- ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~
- Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct.
- I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](a227c706b7 (r40107992)) but I'd prefer that be left for a follow-up.
- I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit.

r? @oli-obk
cc @matthewjasper
2020-08-17 20:51:59 +00:00
Alexis Bourget
431a465a8f Move to intra doc links for keyword documentation 2020-08-17 22:17:14 +02:00
Ellen
e7a7279750 Remove unnecessary links in env.rs 2020-08-17 15:16:09 +01:00
bors
e8df0b8932 Auto merge of #74940 - oli-obk:const_is_null, r=RalfJung
Make `<*const T>::is_null` const fn

r? @RalfJung

cc @rust-lang/wg-const-eval

tracking issue: #74939
2020-08-17 14:13:13 +00:00
Ellen
a2dfc3ec78 Switch to intra-doc links for std/src/alloc.rs 2020-08-17 14:42:40 +01:00
Ellen
b6d2868caa Switch to intra-doc links for std/src/env.rs 2020-08-17 14:42:23 +01:00
Ellen
509cad7f2f Switch to intra-doc links for std/src/error.rs 2020-08-17 14:42:16 +01:00
Tim Diekmann
c48f784418 Fix typo in comment 2020-08-17 15:05:19 +02:00
Tim Diekmann
93e074bc8a Add as_uninit-like methods to pointer types and unify documentation of as_ref methods
Fix example in `NonNull::as_uninit_slice`


Rename feature gate to "ptr_as_uninit"


Make methods more consistent with already stable methods


Make `pointer::as_uninit_slice` return an `Option`


Fix placement for `// SAFETY` section


Add `as_uninit_ref` and `as_uninit_mut` to pointers


Fix doctest


Update tracking issue


Fix doc links


Apply suggestions from review


Make wording about counterparts consistent


Fix doc links


Improve documentation

Fix doc-tests


Fix doc links ... again


Apply suggestions from review


Apply suggestions from Review


Apply suggestion from review to all affected files


Add missing words in safety sections in `as_uninit_slice_mut`


Fix safety-comment in `NonNull::as_uninit_slice_mut`
2020-08-17 14:23:14 +02:00
Tim Diekmann
c619b36975 Remove fast path in reallocation for same layout sizes 2020-08-17 13:23:38 +02:00
bors
67e7b9b8cf Auto merge of #75535 - denisvasilik:intra-doc-links-any, r=jyn514
Move to intra-doc links for /library/core/src/any.rs

Helps with #75080.

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

Known issues:

* Links from `core` to `std` (#74481):
    * `[Box]: ../../std/boxed/struct.Box.html`
2020-08-17 08:00:45 +00:00
bors
94d7660d59 Auto merge of #75468 - poliorcetics:intra-links-fs, r=jyn514
Move to intra doc links in std/src/fs.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-17 06:02:16 +00:00
bors
4bb4b96ee7 Auto merge of #74562 - pickfire:is_ascii_branchless, r=nagisa
Remove branch in optimized is_ascii

Performs slightly better in short or medium bytes by eliminating
the last branch check on `byte_pos == len` and always check the
last byte as it is always at most one `usize`.

Benchmark, before `libcore`, after `libcore_new`. It improves
medium and short by 1ns but regresses unaligned_tail by 2ns,
either way we can get unaligned_tail have a tiny chance of 1/8
on a 64 bit machine. I don't think we should bet on that, the
probability is worse than dice.

```
test long::case00_libcore                     ... bench:          38 ns/iter (+/- 1) = 183947 MB/s
test long::case00_libcore_new                 ... bench:          38 ns/iter (+/- 1) = 183947 MB/s
test long::case01_iter_all                    ... bench:         227 ns/iter (+/- 6) = 30792 MB/s
test long::case02_align_to                    ... bench:          40 ns/iter (+/- 1) = 174750 MB/s
test long::case03_align_to_unrolled           ... bench:          19 ns/iter (+/- 1) = 367894 MB/s
test medium::case00_libcore                   ... bench:           5 ns/iter (+/- 0) = 6400 MB/s
test medium::case00_libcore_new               ... bench:           4 ns/iter (+/- 0) = 8000 MB/s
test medium::case01_iter_all                  ... bench:          20 ns/iter (+/- 1) = 1600 MB/s
test medium::case02_align_to                  ... bench:           6 ns/iter (+/- 0) = 5333 MB/s
test medium::case03_align_to_unrolled         ... bench:           5 ns/iter (+/- 0) = 6400 MB/s
test short::case00_libcore                    ... bench:           7 ns/iter (+/- 0) = 1000 MB/s
test short::case00_libcore_new                ... bench:           6 ns/iter (+/- 0) = 1166 MB/s
test short::case01_iter_all                   ... bench:           5 ns/iter (+/- 0) = 1400 MB/s
test short::case02_align_to                   ... bench:           5 ns/iter (+/- 0) = 1400 MB/s
test short::case03_align_to_unrolled          ... bench:           5 ns/iter (+/- 1) = 1400 MB/s
test unaligned_both::case00_libcore           ... bench:           4 ns/iter (+/- 0) = 7500 MB/s
test unaligned_both::case00_libcore_new       ... bench:           4 ns/iter (+/- 0) = 7500 MB/s
test unaligned_both::case01_iter_all          ... bench:          26 ns/iter (+/- 0) = 1153 MB/s
test unaligned_both::case02_align_to          ... bench:          13 ns/iter (+/- 2) = 2307 MB/s
test unaligned_both::case03_align_to_unrolled ... bench:          11 ns/iter (+/- 0) = 2727 MB/s
test unaligned_head::case00_libcore           ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_head::case00_libcore_new       ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_head::case01_iter_all          ... bench:          19 ns/iter (+/- 1) = 1631 MB/s
test unaligned_head::case02_align_to          ... bench:          10 ns/iter (+/- 0) = 3100 MB/s
test unaligned_head::case03_align_to_unrolled ... bench:          14 ns/iter (+/- 0) = 2214 MB/s
test unaligned_tail::case00_libcore           ... bench:           3 ns/iter (+/- 0) = 10333 MB/s
test unaligned_tail::case00_libcore_new       ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_tail::case01_iter_all          ... bench:          19 ns/iter (+/- 0) = 1631 MB/s
test unaligned_tail::case02_align_to          ... bench:          10 ns/iter (+/- 0) = 3100 MB/s
test unaligned_tail::case03_align_to_unrolled ... bench:          13 ns/iter (+/- 0) = 2384 MB/s
```

Rough (unfair) maths on improvements for fun: 1ns * 7/8 - 2ns * 1/8 = 0.625ns

Inspired by fish and zsh clever trick to highlight missing linefeeds (⏎)
and branchless implementation of binary_search in rust.

cc @thomcc https://github.com/rust-lang/rust/pull/74066
r? @nagisa
2020-08-16 23:52:32 +00:00
Tyler Mandry
e46b1efd39
Rollup merge of #75596 - nixphix:docs/windows-ext, r=jyn514
Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rs

Partial fix for #75080

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

r? @jyn514
2020-08-16 14:59:36 -07:00
Tyler Mandry
8ba56afcc6
Rollup merge of #75485 - RalfJung:pin, r=nagisa
pin docs: add some forward references

@nagisa had some questions about pinning that were answered in the docs, which they did not realize because that discussion is below the examples. I still think it makes sense to introduce the examples before that discussion, since it give the discussion something concrete to refer to, but this PR adds some forward references so people don't think the examples conclude the docs.

@nagisa do you think this would have helped?
2020-08-16 14:59:32 -07:00
Tyler Mandry
18e3799dc8
Rollup merge of #75423 - denisvasilik:intra-doc-links-core-hint, r=dtolnay
Move to intra-doc links for /library/core/src/hint.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-16 14:59:30 -07:00
Jan Riemer
56daf63d10
docs: add derive for struct
Code blocks in doc comments are compiled and run, so we show `Copy` works in this example.

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2020-08-16 22:25:59 +02:00
Jan Riemer
9061da2e14
add empty line above code block
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2020-08-16 22:15:59 +02:00
Jan Riemer
dce864454c add back emojis that have been removed accidentally
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-16 20:48:44 +02:00
Simonas Kazlauskas
5d22b18bf2 Improve codegen of align_offset when stride == 1
Previously checking for `pmoda == 0` would get LLVM to generate branchy
code, when, for `stride = 1` the offset can be computed without such a
branch by doing effectively a `-p % a`.

For well-known (constant) alignments, with the new ordering of these
conditionals, we end up generating 2 to 3 cheap instructions on x86_64:

    movq    %rdi, %rax
    negl    %eax
    andl    $7, %eax

instead of 5+ as previously.

For unknown alignments the new code also generates just 3 instructions:

    negq    %rdi
    leaq    -1(%rsi), %rax
    andq    %rdi, %rax
2020-08-16 21:31:48 +03:00
Simonas Kazlauskas
e7271da69a Improve align_offset at opt-level <= 1
At opt-level <= 1, the methods such as `wrapping_mul` are not being
inlined, causing significant bloating and slowdowns of the
implementation at these optimisation levels.

With use of these intrinsics, the codegen of this function at
-Copt_level=1 is the same as it is at -Copt_level=3.
2020-08-16 21:31:48 +03:00
Jan Riemer
43dec0e171
rephrase: struct -> type
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-16 20:17:28 +02:00
Jan Riemer
a876b3d8aa
docs(marker/copy): provide example for &T being Copy
In the current documentation about the `Copy` marker trait, there is a section
with examples of structs that can implement `Copy`. Currently there is no example for
showing that shared references (`&T`) are also `Copy`.
It is worth to have a dedicated example for `&T` being `Copy`, because shared
references are an integral part of the language and it being `Copy` is not as
intuitive as other types that share this behaviour like `i32` or `bool`.

The example picks up on the previous non-`Copy` struct and shows that
structs can be `Copy`, even when they hold a shared reference to a non-`Copy` type.
2020-08-16 20:03:34 +02:00
Prabakaran Kumaresshan
0a96e089ba Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rs 2020-08-16 22:28:45 +05:30
David Wood
7dee5f824d
hir: introduce lang items for AST lowering
This commit adds new lang items which will be used in AST lowering once
`QPath::LangItem` is introduced.

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:23 +01:00
bors
7a4fb355c6 Auto merge of #75567 - poliorcetics:intra-links-std-net, r=jyn514
Move to intra doc links in std::net

Helps with #75080.

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

The links for `true` and `false` had to stay else `rustdoc` complained, it is intended ?
2020-08-16 13:15:52 +00:00
Alexis Bourget
5fc187cd97 Fix a link, improve method resolution 2020-08-16 14:41:12 +02:00
bors
de32266a17 Auto merge of #75565 - nixphix:docs/vxworks-ext, r=jyn514
Switch to intra-doc links in std/src/sys/vxworks/ext/{fs,process}.rs

Partial fix for #75080

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

r? @jyn514
2020-08-16 08:45:52 +00:00
bors
243c725c24 Auto merge of #75561 - kornelski:stringcol, r=Dylan-DPC
Doc: String isn't a collection

On forums one user was confused by this text, interpreting it as saying that `String` is a `Vec<char>` literally, rather than figuratively for the purpose of collect. I've reworded that paragraph.
2020-08-16 06:26:38 +00:00
bors
9d38dc22e5 Auto merge of #75553 - denisvasilik:intra-doc-links-convert, r=jyn514
Move to intra-doc links for /library/core/src/char/convert.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-16 04:31:05 +00:00
bors
86bccb684d Auto merge of #75541 - camelid:intra-doc-links-for-core-option, r=jyn514
Switch to intra-doc links in `core::option`

Part of #75080.

I didn't change some of the links since they link into `std` and you can't link from `core` to `std` (#74481).

Also, at least one other link can't be switched to an intra-doc link because it's not supported yet (#74489).
2020-08-16 02:39:21 +00:00
bors
3f3250500f Auto merge of #75246 - pickfire:patch-5, r=Amanieu
Add more examples to Path ends_with

We faced a footgun when using ends_with to check extension,
showing an example could prevent that.

2c155e50b2
2020-08-15 19:51:44 +00:00
Denis Vasilik
14b50ede7d Link to primitive instead of module 2020-08-15 19:27:34 +02:00
Alexis Bourget
15cad1c465 Move to intra doc links in std::net 2020-08-15 19:17:19 +02:00
Kornel Lesiński
d5cb5eb08b Doc: String isn't a collection 2020-08-15 17:55:10 +01:00
Camelid
8227b3b0b2
Remove unnecessary intra-doc link
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-15 09:52:35 -07:00
Prabakaran Kumaresshan
c5849ae3e0 inline linking 2020-08-15 22:11:09 +05:30
Camelid
b02c4049cb
Fix link
Intra-doc links don't work yet in this case: #74489
2020-08-15 09:31:14 -07:00
Prabakaran Kumaresshan
f615b6d338 remove empty lines 2020-08-15 21:53:02 +05:30
Prabakaran Kumaresshan
b54341a9d7 resolve comments 2020-08-15 20:53:41 +05:30
Prabakaran Kumaresshan
9463380b0c Switch to intra-doc links in std/src/sys/vxworks/ext/{fs,process}.rs 2020-08-15 19:39:17 +05:30
bors
80fb3f3139 Auto merge of #74576 - myfreeweb:freebsd-sanitizers, r=oli-obk
Add sanitizer support on FreeBSD

Restarting #47337. Everything is better now, no more weird llvm problems, well not everything:

Unfortunately, the sanitizers don't have proper support for versioned symbols (https://github.com/google/sanitizers/issues/628), so `libc`'s usage of `stat@FBSD_1.0` and so on explodes, e.g. in calling `std::fs::metadata`.

Building std (now easy thanks to cargo `-Zbuild-std`) and libc with `freebsd12/13` config via the `LIBC_CI=1` env variable is a good workaround…

```
LIBC_CI=1 RUSTFLAGS="-Z sanitizer=address" cargo +san-test -Zbuild-std run --target x86_64-unknown-freebsd --verbose
```

…*except* std won't build because there's no `st_lspare` in the ino64 version of the struct, so an std patch is required:

```diff
--- i/src/libstd/os/freebsd/fs.rs
+++ w/src/libstd/os/freebsd/fs.rs
@@ -66,8 +66,6 @@ pub trait MetadataExt {
     fn st_flags(&self) -> u32;
     #[stable(feature = "metadata_ext2", since = "1.8.0")]
     fn st_gen(&self) -> u32;
-    #[stable(feature = "metadata_ext2", since = "1.8.0")]
-    fn st_lspare(&self) -> u32;
 }

 #[stable(feature = "metadata_ext", since = "1.1.0")]
@@ -136,7 +134,4 @@ impl MetadataExt for Metadata {
     fn st_flags(&self) -> u32 {
         self.as_inner().as_inner().st_flags as u32
     }
-    fn st_lspare(&self) -> u32 {
-        self.as_inner().as_inner().st_lspare as u32
-    }
 }
```

I guess std could like.. detect that `libc` isn't built for the old ABI, and replace the implementation of `st_lspare` with a panic?
2020-08-15 11:38:24 +00:00
Ivan Tham
446fccf1b8
Use resolve.conf as example for Path ends_with 2020-08-15 17:25:07 +08:00
bors
f7aac25850 Auto merge of #75488 - ssomers:btree_revert_75257, r=Mark-Simulacrum
Revert the fundamental changes in #74762 and #75257

Before possibly going over to #75487. Also contains some added and fixed comments.

r? @Mark-Simulacrum
2020-08-15 05:43:00 +00:00
Tyler Mandry
29a946203a
Rollup merge of #75545 - eddyb:instant-sub-branchless, r=sfackler
std/sys/unix/time: make it easier for LLVM to optimize `Instant` subtraction.

This PR is the minimal change necessary to get LLVM to optimize `if self.t.tv_nsec >= other.t.tv_nsec` to branchless instructions (at least on x86_64), inspired by @m-ou-se's own attempts at optimizing `Instant` subtraction.

I stumbled over this by looking at the total number of instructions executed by `rustc -Z self-profile`, and found that after disabling ASLR, the largest source of non-determinism remaining was from this `if` taking one branch or the other, depending on the values involved.

The reason this code is even called so many times to make a difference, is that `measureme` (the `-Z self-profile` implementation) currently uses `Instant::elapsed` for its event timestamps (of which there can be millions).

I doubt it's critical to land this, although perhaps it could slightly improve some forms of benchmarking.
2020-08-14 20:07:16 -07:00
DPC
9ad17b9ca7 tidy up 2020-08-15 03:16:20 +02:00
Eduard-Mihai Burtescu
a7ad899f9d std/sys/unix/time: make it easier for LLVM to optimize Instant subtraction. 2020-08-15 04:13:25 +03:00
Denis Vasilik
ebcb99ef8f Use intra-doc links 2020-08-15 01:12:47 +02:00
Camelid
b1c05c5c2b Switch to intra-doc links in core::option 2020-08-14 16:11:43 -07:00
Tyler Mandry
939befd65e
Rollup merge of #75531 - ssomers:btree_tests_migration, r=Mark-Simulacrum
Migrate unit tests of btree collections to their native breeding ground

There's one BTreeSet test case that I couldn't easily convince to come along, maybe because it truly is an integration test. But leaving it in place would mean git wouldn't see the move so I also moved it to a new file.

r? @Mark-Simulacrum
2020-08-14 14:47:04 -07:00
Tyler Mandry
6d09e29f5e
Rollup merge of #75530 - nixphix:docs/os-raw, r=jyn514
Switch to intra-doc links in os/raw/*.md

Partial fix for #75080

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

r? @jyn514
2020-08-14 14:47:03 -07:00
Tyler Mandry
2564135115
Rollup merge of #75519 - ssomers:btree_splitpoint_cleanup, r=Mark-Simulacrum
BTreeMap: refactor splitpoint and move testing over to unit test

r? @Mark-Simulacrum
2020-08-14 14:47:01 -07:00
Tyler Mandry
83c04392c8
Rollup merge of #75515 - workingjubilee:patch-4, r=Mark-Simulacrum
Bump std's libc version to 0.2.74

It's been a while and this should really be using a recent version, that's all. 💖
2020-08-14 14:46:57 -07:00
Tyler Mandry
ad1bfd2f3e
Rollup merge of #75501 - poliorcetics:intra-links-std-ffi, r=jyn514
Move to intra doc links in std::ffi

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-14 14:46:52 -07:00
Tyler Mandry
b0261814f1
Rollup merge of #75432 - camelid:intra-doc-links-for-std-process, r=jyn514
Switch to intra-doc links in `std::process`

Part of #75080.
2020-08-14 14:46:49 -07:00
Tyler Mandry
ad8c5e1480
Rollup merge of #75214 - chansuke:fix-intra-doc-links, r=jyn514
Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`

This is partial fixes for https://github.com/rust-lang/rust/issues/75080.
2020-08-14 14:46:47 -07:00
Tyler Mandry
83e75acdec
Rollup merge of #75195 - ssomers:btree_split_up_into_kv_mut, r=Mark-Simulacrum
BTreeMap: purge innocent use of into_kv_mut

Replace the use of `into_kv_mut` into more precise calls. This makes more sense if you know that the single remaining use of `into_kv_mut` is in fact evil and can be trialled in court (#75200) and sent to a correction facility (#73971).

No real performance difference reported (but functions that might benefit a tiny constant bit like `BTreeMap::get_mut` aren't benchmarked):
```
benchcmp old new --threshold 5
 name                       old ns/iter  new ns/iter  diff ns/iter  diff %  speedup
 btree::map::clone_fat_100  63,073       59,256             -3,817  -6.05%   x 1.06
 btree::map::iter_100       3,514        3,235                -279  -7.94%   x 1.09
```
2020-08-14 14:46:45 -07:00
Tyler Mandry
5b61230303
Rollup merge of #74409 - LukasKalbertodt:improve-debug-impl-of-socketaddr-ipaddr, r=Amanieu
Change Debug impl of SocketAddr and IpAddr to match their Display output

This has already been done for `SocketAddrV4`, `SocketAddrV6`, `IpAddrV4` and `IpAddrV6`. I don't see a point to keep the rather bad to read derived impl, especially so when pretty printing:

    V4(
        127.0.0.1
    )

From the `Display`, one can easily and unambiguously see if it's V4 or V6. Two examples:

```
127.0.0.1:443
[2001:db8:85a3::8a2e:370:7334]:443
```

Luckily the docs explicitly state that `Debug` output is not stable and that it may be changed at any time.

Using `Display` as `Debug` is very convenient for configuration structs (e.g. for webservers) that often just have a `derive(Debug)` and are printed that way to the one starting the server.
2020-08-14 14:46:44 -07:00
Tyler Mandry
dae020d491
Rollup merge of #74192 - xkr47:patch-1, r=Mark-Simulacrum
Improve documentation on process::Child.std* fields

As a relative beginner, it took a while for me to figure out I could just steal the references to avoid partially moving the child and thus retain ability to call functions on it (and store it in structs etc).
2020-08-14 14:46:41 -07:00
Tyler Mandry
3111a8c1e2
Rollup merge of #74185 - pickfire:liballoc-iter-doc, r=jyn514
Remove liballoc unneeded explicit link
2020-08-14 14:46:40 -07:00
Tyler Mandry
fba3989052
Rollup merge of #74062 - poliorcetics:unsafe-in-unsafe-c_str, r=Mark-Simulacrum
deny(unsafe_op_in_unsafe_fn) in libstd/ffi/c_str.rs

Partial fix of #73904.

This encloses `unsafe` operations in `unsafe fn` in `libstd/ffi/c_str.rs`.
2020-08-14 14:46:33 -07:00
Alexis Bourget
0e610bb31e Document the unsafe keyword 2020-08-14 22:52:23 +02:00
Denis Vasilik
75c1e2dfbb Use intra-doc links 2020-08-14 20:50:38 +02:00
chansuke
61866bc60c Use intra-doc links in mem::manually_drop & mem::maybe_uninit 2020-08-15 02:33:39 +09:00
Alexis Bourget
e97fa1e3da libstd/ffi/c_str.rs: #![deny(unsafe_op_in_unsafe_fn)], enclose unsafe operations in unsafe blocks 2020-08-14 19:33:04 +02:00
Poliorcetics
ee4f893e27
Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-14 19:08:09 +02:00
Prabakaran Kumaresshan
84539eb7b5 remove primitive type links 2020-08-14 21:57:42 +05:30
Stein Somers
ff45df2acf Move btree unit test to their native, privileged location 2020-08-14 17:54:09 +02:00
Prabakaran Kumaresshan
232e3d04b3 Switch to intra-doc links in os/raw/*.md 2020-08-14 21:09:35 +05:30
Stein Somers
8d1c3c116b BTreeMap: refactor splitpoint and move testing over to unit test 2020-08-14 16:41:54 +02:00
bors
55b9adfafa Auto merge of #75157 - rodrimati1992:patch-1, r=oli-obk
Constified str::from_utf8_unchecked

This would be useful for const code to use an array to construct a string using guaranteed utf8 inputs, and then create a `&str` from it.
2020-08-14 14:08:05 +00:00
Stein Somers
421e0ff3d9 BTreeMap: refactor splitpoint and move testing over to unit test 2020-08-14 14:50:30 +02:00
Jonas Berlin
90e4c905d3 Improve documentation on process::Child.std* fields
As a relative beginner, it took a while for me to figure out I could just steal the references to avoid partially moving the child and thus retain ability to call functions on it (and store it in structs etc).
2020-08-14 08:25:45 -04:00
bors
7996182bc1 Auto merge of #74777 - ssomers:btree_cleanup_7, r=Mark-Simulacrum
Stop BTreeMap casts from reborrowing

Down in btree/node.rs, the interface and use of `cast_unchecked` look a bit shady. It's really just there for inverting `forget_type` which does not borrow. By borrowing we can't write the same `cast_unchecked` in the same way at the Handle level.

No change in undefined behaviour or performance.
2020-08-14 12:00:59 +00:00
Jubilee
28bca67708
Bump std's libc version to 0.2.74 2020-08-14 00:37:19 -07:00