Commit graph

504 commits

Author SHA1 Message Date
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
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
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
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
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