Commit graph

773 commits

Author SHA1 Message Date
Pietro Albini
0f1ffa85d1
Rollup merge of #75967 - aticu:blackbox_typo, r=Dylan-DPC
Fix typo in `std::hint::black_box` docs
2020-08-28 10:24:04 +02:00
Pietro Albini
e027b57e40
Rollup merge of #75955 - camelid:intra-doc-links-for-future-and-dec2flt, r=jyn514
Use intra-doc links in `core::future::future` and `core::num::dec2flt`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc
2020-08-28 10:24:02 +02:00
Pietro Albini
cbe3aef559
Rollup merge of #75946 - pickfire:patch-8, r=jyn514
Error use explicit intra-doc link and fix text

Follow up of https://github.com/rust-lang/rust/pull/75629

r? @jyn514
2020-08-28 10:24:00 +02:00
Pietro Albini
be1b304ea4
Rollup merge of #75943 - elichai:2020-align_offset-docs, r=RalfJung
Fix potential UB in align_offset doc examples

Currently it takes a pointer only to the first element in the array, this changes the code to take a pointer to the whole array.
miri can't catch this right now because it later calls `x.len()` which re-tags the pointer for the whole array.

https://github.com/rust-lang/miri/issues/1526#issuecomment-680897144
2020-08-28 10:23:59 +02:00
Pietro Albini
521b2054b6
Rollup merge of #75927 - camelid:intra-doc-links-for-core-macros, r=jyn514
Use intra-doc links in `core::macros`

Part of #75080.

Also cleaned up some things.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-28 10:23:55 +02:00
Thomas Vigouroux
392478c29e Update compiler-builtins
Fixes #57820 and #46651
2020-08-28 09:02:39 +02:00
Amjad Alsharafi
6aae4a2fe6 Used intra-doc links for ptr#safety occurrences 2020-08-28 11:52:04 +08:00
Amjad Alsharafi
a04e12002a Used intra-doc links for NonNull::dangling() occurrences 2020-08-28 11:52:04 +08:00
Amjad Alsharafi
8e33137159 Fixes intra-doc same scope links 2020-08-28 11:52:03 +08:00
Amjad Alsharafi
91e4aaa736 Use intra-doc links for core/src/slice.mod.rs
- most are using primitive types links, which cannot be used with intra
  links at the moment
- also `std` cannot be referenced in any link
2020-08-28 11:52:03 +08:00
Nathan West
c91e764d51 Once again, x.py tidy 2020-08-27 22:55:58 -04:00
Nathan West
d2d8bcb50e Typo fixes 2020-08-27 22:49:16 -04:00
Camelid
39cd184606
Remove unnecessary intra-doc link
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-27 19:42:23 -07:00
Nathan West
017ed5a579 Improvements to LineWriter::write_all
`LineWriter::write_all` now only emits a single write when writing a
newline when there's already buffered data.
2020-08-27 22:32:28 -04:00
bors
41aaa90c67 Auto merge of #70212 - Amanieu:catch_foreign, r=Mark-Simulacrum
Abort when foreign exceptions are caught by catch_unwind

Prior to this PR, foreign exceptions were not caught by catch_unwind, and instead passed through invisibly. This represented a painful soundness hole in some libraries ([take_mut](https://github.com/Sgeo/take_mut/blob/master/src/lib.rs#L37)), which relied on `catch_unwind` to handle all possible exit paths from a closure.

With this PR, foreign exceptions are now caught by `catch_unwind` and will trigger an abort since catching foreign exceptions is currently UB according to the latest proposals by the FFI unwind project group.

cc @rust-lang/wg-ffi-unwind
2020-08-28 01:20:17 +00:00
Amanieu d'Antras
239f833ed1 Abort when catch_unwind catches a foreign exception 2020-08-27 21:08:30 +01:00
Camelid
f0722c06a7 Switch to intra-doc links in core::hash 2020-08-27 12:09:50 -07:00
Rich Kadel
dd96996c70 Add InstrProfilingPlatformFuchsia.c to profiler_builtins
All other Platform files included in `llvm-project/compiler-rt` were
present, except Fuchsia.

Now that there is a functional end-to-end version of
`-Zinstrument-coverage`, I need to start building and testing
coverage-enabled Rust programs on Fuchsia, and this file is required.
2020-08-27 11:52:36 -07:00
Camelid
707298d52c Use intra-doc links in core::num::dec2flt 2020-08-27 11:40:29 -07:00
Camelid
c933d697d8 Use intra-doc links in core::future::future 2020-08-27 11:40:28 -07:00
Ryan Levick
970e7793bf Add __fastfail for Windows on arm/aarch64 2020-08-27 19:11:48 +02:00
bors
3d0c847d33 Auto merge of #74941 - dylanmckay:replace-broken-avr-unknown-unknown-target, r=oli-obk
[AVR] Replace broken 'avr-unknown-unknown' target with 'avr-unknown-gnu-atmega328' target

The `avr-unknown-unknown` target has never worked correctly, always trying to invoke
the host linker and failing. It aimed to be a mirror of AVR-GCC's
default handling of the `avr-unknown-unknown' triple (assume bare
minimum chip features, silently skip linking runtime libraries, etc).
This behaviour is broken-by-default as it will cause a miscompiled executable
when flashed.

This patch improves the AVR builtin target specifications to instead
expose only a 'avr-unknown-gnu-atmega328' target. This target system is
`gnu`, as it uses the AVR-GCC frontend along with avr-binutils. The
target triple ABI is 'atmega328'.

In the future, it should be possible to replace the dependency on
AVR-GCC and binutils by using the in-progress AVR LLD and compiler-rt support.
Perhaps at that point it would make sense to add an
'avr-unknown-unknown-atmega328' target as a better default when
implemented.

There is no current intention to add in-tree AVR target specifications for other
AVR microcontrollers - this one can serve as a reference implementation
for other devices via `rustc --print target-spec-json
avr-unknown-gnu-atmega328p`.

There should be no users of the existing 'avr-unknown-unknown' Rust
target as a custom target specification JSON has always been
recommended, and the avr-unknown-unknown target could never pass the
linking step anyway.
2020-08-27 15:48:56 +00:00
Ivan Tham
3a814f3f57
Reduce duplicate doc link in error
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-27 23:30:15 +08:00
bors
118860a7e7 Auto merge of #75947 - pietroalbini:bootstrap-update, r=Mark-Simulacrum
Bump version to 1.48 and update cfg(bootstrap)s

r? @Mark-Simulacrum
2020-08-27 09:24:51 +00:00
Pietro Albini
1b6590c9f4
forgot to remove a cfg(not(bootstrap)) 2020-08-27 10:58:34 +02:00
aticu
39f5ebcd74 Fix typo in std::hint::black_box docs 2020-08-27 01:16:18 +02:00
Dylan DPC
11e9769a97
Rollup merge of #75875 - pickfire:patch-4, r=jyn514
Shorten liballoc vec resize intra-doc link

r? @jyn514
2020-08-27 01:14:17 +02:00
Dylan DPC
a838f2fc79
Rollup merge of #75818 - ollie27:doc_systemtime_windows, r=retep998
Update docs for SystemTime Windows implementation

Windows now uses `GetSystemTimePreciseAsFileTime` (since #69858) on versions of Windows that support it.
2020-08-27 01:14:11 +02:00
Dylan DPC
a79f9af290
Rollup merge of #75780 - matklad:unconfuseunpindocs, r=KodrAus
Unconfuse Unpin docs a bit

* Don't say that Unpin is used to prevent moves, because it is used
  to *allow* moves
* Be more precise about kindedness of things, it is
  `Pin<Pointer<Data>>`, rather than just `Pin<Pointer>`.
2020-08-27 01:14:06 +02:00
Dylan DPC
730449d22a
Rollup merge of #75758 - bpangWR:master, r=Mark-Simulacrum
Fixes for VxWorks

r? @alexcrichton
2020-08-27 01:14:04 +02:00
Dylan DPC
2eec2ecbde
Rollup merge of #74730 - androm3da:fix_libstd_hexlinux_01, r=dtolnay
Hexagon libstd: update type defs
2020-08-27 01:14:02 +02:00
Camelid
294c1160bb
Improve docs for the const keyword 2020-08-26 14:51:21 -07:00
bors
48717b6f3c Auto merge of #75912 - scottmcm:manuallydrop-vs-forget, r=Mark-Simulacrum
Suggest `mem::forget` if `mem::ManuallyDrop::new` isn't used

I think this communicates the intent more idiomatically, and is shorter anyway.

Inspired because [it came up on URLO](https://users.rust-lang.org/t/validity-of-memory-area-after-std-forget/47730/7?u=scottmcm), and it turns out that std had done it too in one spot:
![image](https://user-images.githubusercontent.com/18526288/91203819-e19f2980-e6f2-11ea-9112-835f3b22ce05.png)
2020-08-26 18:40:51 +00:00
Surya Midatala
7569cf98f9 Merge conflict fix: disambiguate f32 -> prim@f32 and u32 -> prim@u32 2020-08-26 21:55:42 +05:30
Joshua Nelson
25c034c52e Use allow(unused_imports) instead of cfg(doc) for imports used only for intra-doc links 2020-08-26 21:43:46 +05:30
Joshua Nelson
9b89d8a7a2 Fix link to f32
Co-authored-by: Oliver Middleton <olliemail27@gmail.com>
2020-08-26 21:43:46 +05:30
Surya Midatala
621cbaafff Use crate::mod to disambiguate links 2020-08-26 21:43:46 +05:30
Surya Midatala
f10ab91391 Add suggestions from code review 2020-08-26 21:43:46 +05:30
Surya Midatala
b3437f36e0 Add missed links in primitive_docs.rs 2020-08-26 21:43:46 +05:30
Surya Midatala
a712fbd50b Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs, primitive_docs.rs & poison.rs 2020-08-26 21:43:46 +05:30
Ivan Tham
9ea4593572
Use [xxx()] rather than the [xxx] function
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-26 23:21:44 +08:00
Ivan Tham
16d8d4b899
Error use explicit intra-doc link and fix text 2020-08-26 22:41:56 +08:00
Elichai Turkel
0cca5978a4
Fix potential UB in align_offset docs 2020-08-26 17:02:24 +03:00
bors
ffd59bf9c6 Auto merge of #75687 - TimDiekmann:realloc-align, r=Amanieu
Allow reallocation to different alignment in `AllocRef`

The allocator-wg [has decided](https://github.com/rust-lang/wg-allocators/issues/5#issuecomment-672591112) to support reallocating to a different alignment in `AllocRef`. For more details please see the linked issue.

r? @Amanieu

closes https://github.com/rust-lang/wg-allocators/issues/5
2020-08-26 10:44:28 +00:00
Pietro Albini
3e16d4af7f
apply bootstrap cfgs 2020-08-26 10:17:31 +02:00
Camelid
511ee052a0 Use intra-doc links in core::macros
Also cleaned up some things and added a few more links.
2020-08-25 18:45:20 -07:00
Alexis Bourget
28798132aa Move to intra doc links for core::ptr::non_null 2020-08-25 22:46:12 +02:00
Pang, Baoshan
079baafdf1 For VxWorks:
fix building errors
use wr-c++ as linker
2020-08-25 12:09:39 -07:00
Scott McMurray
f3024073f9 Suggest mem::forget if mem::ManuallyDrop::new isn't used
I think this communicates the intent better, and is shorter anyway.
2020-08-25 09:40:53 -07:00
bors
5890563859 Auto merge of #75838 - mati865:profiler-atomics, r=Amanieu
Profiler: reenable atomics after #65214
2020-08-25 11:53:07 +00:00
bors
3d6a3ed158 Auto merge of #75364 - rylev:libpanic-abort-failfast, r=alexcrichton
Call into fastfail on abort in libpanic_abort on Windows x86(_64)

This partially resolves #73215 though this is only for x86 targets. This code is directly lifted from [libstd](13290e83a6/library/std/src/sys/windows/mod.rs (L315)). `__fastfail` is the preferred way to abort a process on Windows as it will hook into debugger toolchains.

Other platforms expose a `_rust_abort` symbol which wraps `std::sys::abort_internal`. This would also work on Windows, but is a slightly largely change as we'd need to make sure that the symbol is properly exposed to the linker. I'm inlining the call to the `__fastfail`, but the indirection through `rust_abort` might be a cleaner approach.

 A different instruction must be used on ARM architectures. I'd like to verify this works first before tackling ARM.
2020-08-25 07:36:52 +00:00
bors
c30341ddec Auto merge of #75132 - scottmcm:stabilize-range-is-empty, r=dtolnay
Stabilize Range[Inclusive]::is_empty

I would like to propose these two simple methods for stabilization:
- Knowing that a range is exhausted isn't otherwise trivial
- Clippy would like to suggest them, but had to do extra work to disable that path <https://github.com/rust-lang/rust-clippy/issues/3807> because they're unstable
- These work on `PartialOrd`, consistently with the stable `contains` method, and are thus more general than iterator-based approaches that need `Step`
- They've been unchanged for some time, and have picked up uses in the compiler
- Stabilizing them doesn't block any future iterator-based `is_empty` plans, as these inherent ones are preferred in name resolution

https://doc.rust-lang.org/nightly/std/ops/struct.Range.html#method.is_empty
https://doc.rust-lang.org/nightly/std/ops/struct.RangeInclusive.html#method.is_empty

Closes #48111
2020-08-25 05:24:30 +00:00
Scott McMurray
c20ad72323 Stabilize Range[Inclusive]::is_empty
I would like to propose these two simple methods for stabilization:
- Knowing that a range is exhaused isn't otherwise trivial
- Clippy would like to suggest them, but had to do extra work to disable that path <https://github.com/rust-lang/rust-clippy/issues/3807> because they're unstable
- These work on `PartialOrd`, consistently with now-stable `contains`, and are thus more general than iterator-based approaches that need `Step`
- They've been unchanged for some time, and have picked up uses in the compiler
- Stabilizing them doesn't block any future iterator-based is_empty plans, as the inherent ones are preferred in name resolution
2020-08-24 13:20:25 -07:00
bors
f44c6e4e28 Auto merge of #75110 - lzutao:ip-endianness, r=Mark-Simulacrum
Minor changes to Ipv4Addr

Minor changes to Ipv4Addr

* Impl IntoInner rather than AsInner for Ipv4Addr
* Add some comments
* Add test to show endiannes of Ipv4Addr display
2020-08-24 20:05:32 +00:00
dylni
d9e877fb98 Add more information to safety comment 2020-08-24 10:53:25 -04:00
Ivan Tham
adc492573e
Shorten liballoc vec resize intra-doc link 2020-08-24 20:52:41 +08:00
Ivan Tham
bc7ea6f52e
Shorten liballoc doc intra link while readable 2020-08-24 20:02:02 +08:00
Aleksey Kladov
daa6620c95 Unconfuse Unpin docs a bit
* Don't say that Unpin is used to prevent moves, because it is used
  to *allow* moves
* Be more precise about kindedness of things, it is
  `Pin<Pointer<Data>>`, rather than just `Pin<Pointer>`.
2020-08-24 13:56:57 +02:00
bors
aa7010df90 Auto merge of #75815 - jyn514:ambiguous-primitives, r=guillaumegomez
Report an ambiguity if both modules and primitives are in scope for intra-doc links

Closes https://github.com/rust-lang/rust/issues/75381

- Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace
- Refactor `report_ambiguity` into a closure

Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case.

I also need to update libstd to use `prim@char` instead of `type@char`. If possible I would also like to refactor `ambiguity_error` to use `Disambiguator` instead of its own hand-rolled match - that ran into issues with `prim@` (I updated one and not the other) and it would be better for them to be in sync.
2020-08-24 10:29:29 +00:00
bors
9d74562432 Auto merge of #75505 - Dylan-DPC:feature/arc_new, r=KodrAus
Add Arc::new_cyclic

Rework of #72443

References #75861

cc @Diggsey @RalfJung

r? @KodrAus
2020-08-24 08:26:59 +00:00
Dylan McKay
a0905ceff9 [AVR] Rename the last few remaining references from 'avr-unknown-unknown' to 'avr-unknown-gnu-atmega328' 2020-08-24 18:45:24 +12:00
bors
d795eb4b10 Auto merge of #75855 - jyn514:no-cfg-doc, r=ollie27
Use allow(unused_imports) instead of cfg(doc) for imports used only for intra-doc links

This prevents links from breaking when items are re-exported in a
different crate and the original isn't being documented.

Spotted in https://github.com/rust-lang/rust/pull/75832#discussion_r475275837 (thanks ollie!)

r? @ollie27
2020-08-24 06:05:00 +00:00
bors
c4b6d9411f Auto merge of #75865 - JohnTitor:rollup-yxia6d2, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #75819 (Use intra-doc-links in `core::{char, macros, fmt}`)
 - #75821 (Switch to intra-doc links in `std::macros`)
 - #75825 (Fix typo in documentation of i32 wrapping_abs())
 - #75826 (Corrected Misleading documentation for derived Ord/PartialOrd implementation )
 - #75831 (doc: Prefer https link for wikipedia URLs)
 - #75844 (publish-toolstate: show more context on HTTP error)
 - #75847 (Switch to intra-doc links in `std::collections`)
 - #75851 (Switch to intra-doc links in `core::array`)
 - #75856 (more tool clippy fixes)
 - #75859 (doc: Fix typo in std::process::Child documentation)

Failed merges:

r? @ghost
2020-08-24 04:10:54 +00:00
Joshua Nelson
5aac94a1f6 Don't import atomics unless supported by the platform 2020-08-23 23:11:47 -04:00
Yuki Okushi
47a03d9815
Rollup merge of #75859 - jrheard:patch-2, r=jonas-schievink
doc: Fix typo in std::process::Child documentation

Nearly done reading stdlib docs, found another small typo, here's a PR!

r? @steveklabnik
2020-08-24 11:48:55 +09:00
Yuki Okushi
648ad7c57e
Rollup merge of #75851 - camelid:patch-2, r=jyn514
Switch to intra-doc links in `core::array`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:52 +09:00
Yuki Okushi
282d258cd1
Rollup merge of #75847 - camelid:patch-1, r=dtolnay
Switch to intra-doc links in `std::collections`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:50 +09:00
Yuki Okushi
25a677ccef
Rollup merge of #75831 - lzutao:https, r=Dylan-DPC
doc: Prefer https link for wikipedia URLs

A tiny changes.
2020-08-24 11:48:47 +09:00
Yuki Okushi
427e969c43
Rollup merge of #75826 - ayushmishra2005:misleading_documentation_for_derived_Ord_PartialOrd, r=KodrAus
Corrected Misleading documentation for derived Ord/PartialOrd implementation

Corrected Misleading documentation for derived Ord/PartialOrd implementation

Fixes #75620
2020-08-24 11:48:46 +09:00
Yuki Okushi
b8e456f2db
Rollup merge of #75825 - jrheard:patch-1, r=steveklabnik
Fix typo in documentation of i32 wrapping_abs()

Hi!

I was reading through the std library docs and noticed that this section flowed a bit oddly; comparing it against https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_div and https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_neg , I noticed that those two pieces of documentation used a semicolon here.

This is my first time submitting a PR to this repo. Am I doing this right? Are tiny typo-fix PRs like this worth submitting, or are they not a good use of time?

Thank you!
2020-08-24 11:48:44 +09:00
Yuki Okushi
640b36f97a
Rollup merge of #75821 - camelid:intra-doc-links-for-std-macros, r=jyn514
Switch to intra-doc links in `std::macros`

Part of #75080.

---

* Switch to intra-doc links in `std::macros`
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`

---

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:42 +09:00
Yuki Okushi
50bdcc2f2e
Rollup merge of #75819 - LeSeulArtichaut:core-intra-docs-2, r=jyn514
Use intra-doc-links in `core::{char, macros, fmt}`

Helps with #75080.
r? @jyn514
2020-08-24 11:48:41 +09:00
Joshua Nelson
6f4681bacc Convert str -> prim@str in std 2020-08-23 22:40:20 -04:00
Joshua Nelson
373432e47f Convert from str -> prim@str for alloc 2020-08-23 22:40:20 -04:00
Joshua Nelson
556fd86524 Disambiguate char -> prim@char for core
This also changes human intuition -> intuition. 'human intuition' sounds
vaguely menacing.
2020-08-23 22:40:20 -04:00
bors
a962b692a6 Auto merge of #75817 - LeSeulArtichaut:proc_macro-docs, r=jyn514
Use intra-doc link in `proc_macro`

Yep. One link.

Helps with #75080.
r? @jyn514
2020-08-24 02:18:09 +00:00
Dylan DPC
c26a8d5772
add issue number 2020-08-24 02:34:52 +02:00
JR Heard
bc47f70f88
doc: Fix typo in std::process::Child documentation 2020-08-23 16:38:23 -07:00
Joshua Nelson
602dd145a3 Use allow(unused_imports) instead of cfg(doc)
This prevents links from breaking when items are re-exported in a
different crate and the original isn't being documented.
2020-08-23 18:45:57 -04:00
LeSeulArtichaut
d36e3e23a8 Use intra-doc-links in core::{char, macros, fmt} 2020-08-24 00:13:23 +02:00
Camelid
04e8237c6d
Switch to intra-doc links in core::array 2020-08-23 14:42:21 -07:00
Camelid
e9928d8926
Switch to intra-doc links in std::collections 2020-08-23 13:51:01 -07:00
bors
0ec94594dd Auto merge of #72449 - ecstatic-morse:const-float-bitcast, r=RalfJung
Const floating point bitcasts and classification

Makes the `f32` and `f64` methods described in #72447 and #72505 unstably const.

r? @RalfJung
2020-08-23 19:14:55 +00:00
bors
d02a209eb9 Auto merge of #75028 - MrModder:master, r=steveklabnik
Document that slice refers to any pointer type to a sequence

I was recently confused about the way slices are represented in memory. The necessary information was not available in the std-docs directly, but was a mix of different material from the reference and book.

This PR should clear up the definition of slices a bit more in the documentation. Especially the fact that the term slice refers to the pointer/reference type, e.g. `&[T]`, and not `[T]`.
It also documents that slice pointers are twice the size of pointers to `Sized` types, as this concept may be unfamiliar to users coming from other languages that do not have the concept of "fat pointers" (especially C/C++).

I've documented why this was important to me and my findings in [this blog post](https://codecrash.me/understanding-rust-slices).

r? @lcnr
2020-08-23 16:59:10 +00:00
bors
9d606d939a Auto merge of #74238 - RalfJung:offset_from, r=oli-obk
stabilize ptr_offset_from

This stabilizes ptr::offset_from, and closes https://github.com/rust-lang/rust/issues/41079. It also removes the deprecated `wrapping_offset_from`. This function was deprecated 19 days ago and was never stable; given an FCP of 10 days and some waiting time until FCP starts, that leaves at least a month between deprecation and removal which I think is fine for a nightly-only API.

Regarding the open questions in https://github.com/rust-lang/rust/issues/41079:
* Should offset_from abort instead of panic on ZSTs? -- As far as I know, there is no precedent for such aborts. We could, however, declare this UB. Given that the size is always known statically and the check thus rather cheap, UB seems excessive.
* Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return usize (like how isize-taking offset is more conveniently done with usize-taking add these days)? -- No reason to block stabilization on that, we can always add such methods later.

Also nominating the lang team because this exposes an intrinsic.

The stabilized method is best described [by its doc-comment](56d4b2d69a/src/libcore/ptr/const_ptr.rs (L227)). The documentation forgot to mention the requirement that both pointers must "have the same provenance", aka "be derived from pointers to the same allocation", which I am adding in this PR. This is a precondition that [Miri already implements](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a3b9d0a07a01321f5202cd99e9613480) and that, should LLVM ever obtain a `psub` operation to subtract pointers, will likely be required for that operation (following the semantics in [this paper](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf)).
2020-08-23 14:50:15 +00:00
Ralf Jung
4129e0757a bump stable version
Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-08-23 16:12:39 +02:00
Ralf Jung
eb27828bf1 remove an unused feature flag 2020-08-23 16:12:39 +02:00
Leon Matthes
cf76256b83 Revert changed paragraph about slice definition.
This reverts part of commit e6c83dd57b.
As requested by @steveklabnik .
2020-08-23 16:02:22 +02:00
Mateusz Mikuła
1a9def139e Profiler: reenable atomics after #65214 2020-08-23 15:55:18 +02:00
bors
b88434ee0f Auto merge of #75816 - LeSeulArtichaut:core-intra-docs, r=jyn514
Use intra-doc-links in `core::{raw, ffi, pin}`

Helps with #75080.
r? @jyn514
2020-08-23 12:40:01 +00:00
Ayush Kumar Mishra
18f47d81da Misleading documentation for derived Ord/PartialOrd implementation for enums #75620 2020-08-23 15:56:01 +05:30
Lzu Tao
2c995d29f7 Prefer https link for wikipedia URLs 2020-08-23 10:02:42 +00:00
JR Heard
69d3334adf
Fix typo in documentation of i32 wrapping_abs() 2020-08-22 22:21:03 -07:00
Camelid
637659be6a Add missing links 2020-08-22 20:23:50 -07:00
Camelid
becf5ec4ea Add missing intra-doc link 2020-08-22 17:41:40 -07:00
Camelid
5d32786b4f Switch to intra-doc links in std::macros
Also:
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`
2020-08-22 15:44:00 -07:00
Oliver Middleton
57e7e2875b Update docs for SystemTime Windows implementation
Windows now uses `GetSystemTimePreciseAsFileTime` on versions of Windows that support it.
2020-08-22 22:00:33 +01:00
LeSeulArtichaut
c3e3b7f119 Use intra-doc link in proc_macro 2020-08-22 22:29:43 +02:00
LeSeulArtichaut
c8a372ecff Use intra-doc-links in core::{raw, ffi, pin} 2020-08-22 22:25:27 +02:00
Dylan MacKenzie
23e08e223b Add #![feature(const_float_classify)] for f64::classify and friends 2020-08-22 12:28:31 -07:00
Dylan MacKenzie
3cd450ec5d Add #![feature(const_float_bits_conv)] for f64::to_bits and friends 2020-08-22 12:28:31 -07:00
bors
663d2f5cd3 Auto merge of #75171 - amosonn:new_zeroed_slice, r=Amanieu
New zeroed slice

Add to #63291 the methods

```rust
impl<T> Box<[T]> { pub fn new_zeroed_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_zeroed_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_zeroed_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }
```

as suggested in https://github.com/rust-lang/rust/issues/63291#issuecomment-605511675 .

Also optimize `{Rc, Arc}::new_zeroed` to use `alloc_zeroed`, otherwise they are no more efficient than using `new_uninit` and zeroing the memory manually (which was the original implementation).
2020-08-22 18:46:42 +00:00
bors
527a685e40 Auto merge of #75783 - denisvasilik:intra-doc-links-core-alloc, r=jyn514
Move to intra-doc links for library/core/src/alloc/{layout, global, mod}.rs

Helps with #75080. The files already contained intra-doc links, so there are only minor changes.

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

Known issues:

* [`handle_alloc_error`]: Link from `core` to `alloc` could not be resolved.
* [`slice`]: slice is a primitive type, but could not be resolved; had to use [`crate::slice`] instead.
2020-08-22 13:21:24 +00:00
Ralf Jung
9a12d9a243 fix dead links to wrapping_offset_from 2020-08-22 15:07:34 +02:00
Ralf Jung
4f92f0d31b remove feature gate from tests 2020-08-22 15:07:32 +02:00
Ralf Jung
0e4f335e63 stabilize ptr_offset_from 2020-08-22 14:37:10 +02:00
Ralf Jung
7ad4369ba6 remove deprecated wrapping_offset_from 2020-08-22 14:37:08 +02:00
Ralf Jung
1241f1927e offset_from: also document same-provenance requirement 2020-08-22 14:37:06 +02:00
Denis Vasilik
2500b6df14 Link to primitive instead of module 2020-08-22 12:16:03 +02:00
bors
c5a8b7b901 Auto merge of #75790 - LeSeulArtichaut:std-intra-doc, r=jyn514
Use intra-doc-links in `std::sync::*`

Helps with #75080.
r? @jyn514
2020-08-22 08:54:29 +00:00
bors
ebc03f7c80 Auto merge of #75772 - tmiasko:io-maybe-no, r=dtolnay
Remove unused `Maybe` wrapper around raw standard streams

* Remove result type from raw standard streams constructors
* Make raw standard stream constructors const
* Remove wrapper type handling absent raw standard streams

cargo checked with:

```shell
env CC=true ./x.py check library/std/ \
  --target i686-unknown-linux-gnu \
  --target wasm32-unknown-emscripten \
  --target wasm32-wasi \
  --target x86_64-fortanix-unknown-sgx \
  --target x86_64-pc-windows-gnu \
  --target x86_64-unknown-cloudabi \
  --target x86_64-unknown-hermit \
  --target x86_64-unknown-linux-gnu \
  --target x86_64-uwp-windows-gnu \
  --target x86_64-wrs-vxworks
```

Note: Last target doesn't compile currently.
2020-08-22 04:39:15 +00:00
Dylan DPC
13dfa9c874
Rollup merge of #75787 - LeSeulArtichaut:core-intra-doc, r=jyn514
Use intra-doc-links in `core::ops::*`

Helps with #75080.
r? @jyn514
2020-08-22 02:14:57 +02:00
Dylan DPC
2ea63794a4
Rollup merge of #75782 - GuillaumeGomez:more-links, r=jyn514
Convert core/src/str/pattern.rs to Intra-doc links

Part of #75080.
2020-08-22 02:14:56 +02:00
Dylan DPC
ec629800ec
Rollup merge of #75725 - LeSeulArtichaut:alloc-intra-doc, r=jyn514
Use intra-doc-links in `alloc`

I didn't have time to test this, so I will let the CI do it for me.

r? @jyn514 cc #75080
2020-08-22 02:14:45 +02:00
Dylan DPC
8af33add1a
Rollup merge of #75705 - denisvasilik:intra-doc-links-intrinsics, r=jyn514
Move to intra-doc links for /library/core/src/intrinsics.rs

Helps with #75080.

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

Known issues:

* The following f32 and f64 primitive methods cannot be resolved:

    f32/f64::powi
    f32/f64::sqrt
    f32/f64::sin
    f32/f64::cos
    f32/f64::powf
    f32/f64::exp
    f32/f64::exp2
    f32/f64::ln
    f32/f64::log2
    f32/f64::log10
    f32/f64::mul_add
    f32/f64::abs
    f32/f64::copysign
    f32/f64::floor
    f32/f64::ceil
    f32/f64::trunc
    f32/f64::round

* Links from core to std:

    [`std::pointer::*`]
    [`std::process::abort`]
    [`from_raw_parts`]
    [`Vec::append`]

* Links with anchors?

	I provided a separate commit that replaced links with anchors by intra-doc links.
	Here the anchor location information gets lost, so its questionable whether to
	actually replace those links.
2020-08-22 02:14:36 +02:00
LeSeulArtichaut
f3a832f4b4 Use intra-doc-links in std::sync::* 2020-08-22 01:28:26 +02:00
Guillaume Gomez
385a1b2476 Add more links 2020-08-22 00:10:58 +02:00
LeSeulArtichaut
9424ac79b2 Remove links that get imported from the prelude 2020-08-21 23:27:23 +02:00
LeSeulArtichaut
8e009bc4f0 Use intra-doc-links in core::ops::* 2020-08-21 23:19:10 +02:00
amosonn
5aba816672
Update rc.rs 2020-08-21 22:25:09 +02:00
Denis Vasilik
9785fd0882 Use intra-doc links 2020-08-21 21:41:43 +02:00
Denis Vasilik
a45d90ec23 Use intra-doc links 2020-08-21 21:35:52 +02:00
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
dylni
d04e6b8de5 Replace ad hoc implementations with slice::check_range 2020-08-16 21:47:12 -04: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