Commit graph

789 commits

Author SHA1 Message Date
Mara Bos
126d88bd12
Rollup merge of #79114 - andjo403:nonzero_leading_trailing_zeros, r=m-ou-se
add trailing_zeros and leading_zeros to non zero types

as a way towards being able to use the optimized intrinsics ctlz_nonzero and cttz_nonzero from stable.

have not crated any tracking issue if this is not a solution that is wanted
2020-11-18 15:46:31 +01:00
Andreas Jonson
9bbc4c16d3 add trailing_zeros and leading_zeros to non zero types 2020-11-17 19:54:29 +01:00
Mara Bos
c0a9bf9336
Rollup merge of #78769 - est31:remove_lifetimes, r=KodrAus
Remove unneeded lifetimes in array/mod.rs
2020-11-16 17:26:29 +01:00
Mara Bos
5bbf75da78
Rollup merge of #77691 - exrook:rename-layouterr, r=KodrAus
Rename/Deprecate LayoutErr in favor of LayoutError

Implements rust-lang/wg-allocators#73.

This patch renames LayoutErr to LayoutError, and uses a type alias to support users using the old name.

The new name will be instantly stable in release 1.49 (current nightly), the type alias will become deprecated in release 1.51 (so that when the current nightly is 1.51, 1.49 will be stable).

This is the only error type in `std` that ends in `Err` rather than `Error`, if this PR lands all stdlib error types will end in `Error` 🥰
2020-11-16 17:26:17 +01:00
Mara Bos
de0aa6169f
Rollup merge of #76339 - CDirkx:structural-match-range, r=Mark-Simulacrum
Test structural matching for all range types

As of #70166 all range types (`core::ops::Range` etc.) can be structurally matched upon, and by extension used in const generics. In reference to the fact that this is a publicly observable property of these types, and thus falls under the Rust stability guarantees of the standard library, a regression test was added in #70283.

This regression test was implemented by me by testing for the ability to use the range types within const generics, but that is not the actual property the std guarantees now (const generics is still unstable). This PR addresses that situation by adding extra tests for the range types that directly test whether they can be structurally matched upon.

Note: also adds the otherwise unrelated test `test_range_to_inclusive` for completeness with the other range unit tests
2020-11-16 17:26:13 +01:00
pubfnbar
c03dfa6671 Implement Index[Mut] for arrays
Adds implementations of `Index` and `IndexMut` for arrays that simply forward to the slice indexing implementation.
2020-11-16 09:05:15 -05:00
Jonas Schievink
62f0a78056
Rollup merge of #78216 - workingjubilee:duration-zero, r=m-ou-se
Duration::zero() -> Duration::ZERO

In review for #72790, whether or not a constant or a function should be favored for `#![feature(duration_zero)]` was seen as an open question. In https://github.com/rust-lang/rust/issues/73544#issuecomment-691701670 an invitation was opened to either stabilize the methods or propose a switch to the constant value, supplemented with reasoning. Followup comments suggested community preference leans towards the const ZERO, which would be reason enough.

ZERO also "makes sense" beside existing associated consts for Duration. It is ever so slightly awkward to have a series of constants specifying 1 of various units but leave 0 as a method, especially when they are side-by-side in code. It seems unintuitive for the one non-dynamic value (that isn't from Default) to be not-a-const, which could hurt discoverability of the associated constants overall. Elsewhere in `std`, methods for obtaining a constant value were even deprecated, as seen with [std::u32::min_value](https://doc.rust-lang.org/std/primitive.u32.html#method.min_value).

Most importantly, ZERO costs less to use. A match supports a const pattern, but const fn can only be used if evaluated through a const context such as an inline `const { const_fn() }` or a `const NAME: T = const_fn()` declaration elsewhere. Likewise, while https://github.com/rust-lang/rust/issues/73544#issuecomment-691949373 notes `Duration::zero()` can optimize to a constant value, "can" is not "will". Only const contexts have a strong promise of such. Even without that in mind, the comment in question still leans in favor of the constant for simplicity. As it costs less for a developer to use, may cost less to optimize, and seems to have more of a community consensus for it, the associated const seems best.

r? ```@LukasKalbertodt```
2020-11-11 20:58:52 +01:00
Jonas Schievink
42fae6bb65
Rollup merge of #78910 - tmiasko:intrinsics-link, r=jyn514
Fix links to stabilized versions of some intrinsics
2020-11-10 14:45:34 +01:00
cyqsimon
bf982a52f6 Bad grammar 2020-11-09 23:52:33 +08:00
cyqsimon
2633e93aa0 Clarified description of write! macro 2020-11-09 23:00:31 +08:00
Dylan DPC
d69ee57f97
Rollup merge of #77640 - ethanboxx:int_error_matching_attempt_2, r=KodrAus
Refactor IntErrorKind to avoid "underflow" terminology

This PR is a continuation of #76455

# Changes

- `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in #76455
- Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178
- Carry the problem `char` with the `InvalidDigit` variant.
- Necessary changes were made to the compiler as it depends on `int_error_matching`.
- Redid tests to match on specific errors.

r? ```@KodrAus```
2020-11-09 01:13:25 +01:00
Tomasz Miąsko
f1739575ef Fix links to stabilized versions of some intrinsics 2020-11-09 00:00:00 +00:00
Mara Bos
96975e515a
Rollup merge of #78852 - camelid:intra-doc-bonanza, r=jyn514
Convert a bunch of intra-doc links

An intra-doc link bonanza!

This was accomplished using a bunch of trial-and-error with sed.
2020-11-08 13:36:28 +01:00
Mara Bos
3541280753
Rollup merge of #78788 - jhpratt:isize-impl-fix, r=m-ou-se
Correct unsigned equivalent of isize to be usize

See [#74913 (comment)](https://github.com/rust-lang/rust/issues/74913#issuecomment-722334456) for why this matters. Apparently it hasn't been used anywhere else, though CI will tell for sure.
2020-11-08 13:36:18 +01:00
Mara Bos
2967e58be3
Rollup merge of #78728 - a1phyr:const_cell_into_inner, r=dtolnay
Constantify `UnsafeCell::into_inner` and related

Tracking issue: #78729

This PR constantifies:
- `UnsafeCell::into_inner`
- `Cell::into_inner`
- `RefCell::into_inner`
- `Atomic*::into_inner`

r? `````@dtolnay`````
2020-11-08 13:36:14 +01:00
Mara Bos
bdeace9f4e
Rollup merge of #76227 - CDirkx:const-poll, r=KodrAus
Stabilize `Poll::is_ready` and `is_pending` as const

Insta-stabilize the methods `is_ready` and `is_pending` of `std::task::Poll` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198).

Possible because of the recent stabilization of const control flow.

Part of #76225.
2020-11-08 13:35:58 +01:00
Mara Bos
1f034f77bc
Rollup merge of #76097 - pickfire:stabilize-spin-loop, r=KodrAus
Stabilize hint::spin_loop

Partially fix #55002, deprecate in another release

r? ``````@KodrAus``````
2020-11-08 13:35:54 +01:00
Camelid
8258cf285f Convert a bunch of intra-doc links 2020-11-07 12:50:57 -08:00
Christiaan Dirkx
6728240f36 Test structural matching for all range types
Adds structural match tests for all range types.

Note: also adds the otherwise unrelated test `test_range_to_inclusive` for completeness
2020-11-07 01:31:44 +01:00
Yuki Okushi
8f70cad032
Rollup merge of #78730 - kornelski:not-inverse, r=Dylan-DPC
Expand explanation of reverse_bits

Original documentation only rephrased the function name
2020-11-07 01:02:20 +09:00
Ivan Tham
e8b5be5dff Stabilize hint::spin_loop
Partially fix #55002, deprecate in another release

Co-authored-by: Ashley Mannix <kodraus@hey.com>

Update stable version for stabilize_spin_loop

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Use better example for spinlock

As suggested by KodrAus

Remove renamed_spin_loop already available in master

Fix spin loop example
2020-11-06 23:41:55 +08:00
bors
f92b931045 Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27
Add non_autolinks lint

Part of #77501.

r? `@jyn514`
2020-11-06 04:17:41 +00:00
Jacob Pratt
8078474b0a
Correct unsigned equivalent of isize to be usize 2020-11-05 16:52:32 -05:00
Guillaume Gomez
99200f760b Fix even more URLs 2020-11-05 20:11:29 +01:00
est31
5058cad41e Remove unneeded lifetimes in array/mod.rs 2020-11-05 11:49:27 +01:00
Mara Bos
f383e4f1d9
Rollup merge of #78757 - camelid:crate-link-text, r=jyn514
Improve and clean up some intra-doc links
2020-11-05 10:30:02 +01:00
Mara Bos
86e6afafe1
Rollup merge of #78738 - sasurau4:test/move-range-test-to-library-core, r=jyn514
Move range in ui test to ops test in library/core

Helps with #76268

r? ````@matklad````
2020-11-05 10:29:56 +01:00
Mara Bos
29fad213b2
Rollup merge of #78735 - danielhenrymantilla:simplify-unsafecell-getmut, r=RalfJung
Simplify the implementation of `get_mut` (no unsafe)

Quick PR to reduce one use of `unsafe` pointed out in the previous PR

r? ````@RalfJung````
2020-11-05 10:29:54 +01:00
Mara Bos
43e1b58bcc
Rollup merge of #78716 - est31:array_traits, r=Dylan-DPC
Array trait impl comment/doc fixes

Two small doc/comment fixes regarding trait implementations on arrays.
2020-11-05 10:29:46 +01:00
Guillaume Gomez
9d114506c6 Rename lint to non_autolinks 2020-11-05 10:22:08 +01:00
Guillaume Gomez
60caf51b0d Rename automatic_links to url_improvements 2020-11-05 10:22:08 +01:00
Guillaume Gomez
55b4d21e25 Fix automatic_links warnings 2020-11-05 10:22:08 +01:00
chansuke
f9b139f9c4 Add mod nan for test 2020-11-05 12:57:18 +09:00
Camelid
3084a55d54 Don't use crate in link text
`crate::` -> `core::`

It looks weird to have `crate::` in the link text and we use the actual
crate name everywhere else.

If anyone is curious, I used this Vim command to update all the links:

    %s/\(\s\)\[`crate::\(.*\)`\]/\1[`core::\2`](crate::\2)/g
2020-11-04 18:44:40 -08:00
chansuke
97d5a1be3f Fix format 2020-11-05 08:40:04 +09:00
chansuke
5855fb7b79 Move f64::NAN ui tests into library 2020-11-05 08:32:07 +09:00
Daiki Ihara
232b9ba129 Move range in ui test to ops test in library/core 2020-11-05 00:00:44 +09:00
Daniel Henry-Mantilla
69e5729c58 Simplify the implementation of get_mut (no unsafe) 2020-11-04 14:54:22 +01:00
est31
93fa023111 Fix outdated comment next to array_impl_default
The comment has become outdated as the array_impl macro
has been removed.
2020-11-04 12:21:22 +01:00
Kornel
340c94ad76 Expand explanation of reverse_bits 2020-11-04 11:21:07 +00:00
Benoît du Garreau
795bbfe056 Add tracking issue 2020-11-04 11:58:41 +01:00
Benoît du Garreau
9a12d727df Constantify UnsafeCell::into_inner and related
Also includes:
- Cell::into_inner
- RefCell::into_inner
- Atomic*::into_inner
2020-11-04 11:41:57 +01:00
Yuki Okushi
9d4cdbbfcd
Rollup merge of #78664 - pickfire:patch-4, r=jonas-schievink
Fix intrinsic size_of stable link

I noticed that it is pointing to the same link when I was reading
https://github.com/rust-lang/rust-clippy/issues/2997
2020-11-03 15:27:18 +09:00
Vadim Petrochenkov
19dbb02a89 Expand NtExpr tokens only in key-value attributes 2020-11-03 00:53:43 +03:00
Ivan Tham
c83c635751
Fix intrinsic size_of stable link
I noticed that it is pointing to the same link when I was reading
https://github.com/rust-lang/rust-clippy/issues/2997
2020-11-02 16:03:23 +08:00
Yuki Okushi
50d7716efb
Rollup merge of #78637 - mystor:atomic_ptr_bool, r=m-ou-se
Add fetch_update methods to AtomicBool and AtomicPtr

These methods were stabilized for the integer atomics in #71843, but the methods were not added for the non-integer atomics `AtomicBool` and `AtomicPtr`.
2020-11-02 14:14:41 +09:00
Yuki Okushi
fb7948e7c1
Rollup merge of #78627 - est31:total_cmp_no_superset, r=m-ou-se
Point out that total_cmp is no strict superset of partial comparison

Partial comparison and total_cmp are not equal. This helps
preventing the mistake of creating float wrappers that
base their Ord impl on total_cmp and their PartialOrd impl on
the PartialOrd impl of the float type. PartialOrd and Ord
[are required to agree with each other](https://doc.rust-lang.org/std/cmp/trait.Ord.html#how-can-i-implement-ord).
2020-11-02 14:14:38 +09:00
Yuki Okushi
7baf48ffc0
Rollup merge of #78620 - gabhijit:bitops_doc_fix, r=m-ou-se
Trivial fixes to bitwise operator documentation

Added fixes to documentation of `BitAnd`, `BitOr`, `BitXor` and
`BitAndAssign`, where the documentation for implementation on
`Vector<bool>` was using logical operators in place of the bitwise
operators.

r? @steveklabnik
Closes #78619
2020-11-02 14:14:36 +09:00
Yuki Okushi
0fdb371d5a
Rollup merge of #78606 - autarch:patch-1, r=m-ou-se
Clarify handling of final line ending in str::lines()

I found the description as it stands a bit confusing. I've added a bit more explanation to make it clear that a trailing line ending does not produce a final empty line.
2020-11-02 14:14:33 +09:00
Nika Layzell
00f32e6631 Add fetch_update methods to AtomicBool and AtomicPtr
These methods were stabilized for the integer atomics in #71843, but the methods
were not added for the non-integer atomics `AtomicBool` and `AtomicPtr`.
2020-11-01 13:57:45 -05:00