Commit graph

2394 commits

Author SHA1 Message Date
ibraheemdev
14769ce96f enable slice_swap_unchecked feature in doc test 2021-10-11 16:14:30 -04:00
ibraheemdev
1afe14ceed add slice::swap_unchecked 2021-10-11 16:14:30 -04:00
Gary Guo
148f456cc6 Fix ICE 89775 2021-10-11 20:52:36 +01:00
Wilfred Hughes
e56d89ae62
Add missing words in Infallible docs
This sentence was previously incomplete.
2021-10-11 12:26:27 -07:00
David Tolnay
a1e03fc563
Add library tracking issue for poll_ready feature 2021-10-11 12:17:41 -07:00
John Kugelman
b0b09f0842
Update library/core/src/mem/maybe_uninit.rs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-10-11 14:46:08 -04:00
John Kugelman
06e625f7d5 Add #[must_use] to as_type conversions 2021-10-11 13:57:38 -04:00
bors
5b210643eb Auto merge of #83908 - Flying-Toast:master, r=davidtwco
Add enum_intrinsics_non_enums lint

There is a clippy lint to prevent calling [`mem::discriminant`](https://doc.rust-lang.org/std/mem/fn.discriminant.html) with a non-enum type. I think the lint is worthy of being included in rustc, given that `discriminant::<T>()` where `T` is a non-enum has an unspecified return value, and there are no valid use cases where you'd actually want this.

I've also made the lint check [variant_count](https://doc.rust-lang.org/core/mem/fn.variant_count.html) (#73662).

closes #83899
2021-10-11 17:12:14 +00:00
The8472
a398b6b9d4 inline next() on &mut Iterator impl 2021-10-11 17:50:03 +02:00
bors
1067e2ca5e Auto merge of #89767 - GuillaumeGomez:rollup-sczixhk, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #89655 (bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts)
 - #89726 (Add #[must_use] to alloc constructors)
 - #89729 (Add #[must_use] to core and std constructors)
 - #89743 (Fix RUSTC_LOG handling)
 - #89753 (Add #[must_use] to from_value conversions)
 - #89754 (Cleanup .item-table CSS)
 - #89761 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-11 14:16:15 +00:00
John Kugelman
3ac0ae21d5 Add #[must_use] to MaybeUninit::new 2021-10-11 10:03:55 -04:00
Guillaume Gomez
96ffc74fe3
Rollup merge of #89753 - jkugelman:must-use-from_value-conversions, r=joshtriplett
Add #[must_use] to from_value conversions

I added two methods to the list myself. Clippy did not flag them because they take `mut` args, but neither modifies their argument.

```rust
core::str           const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;
std::ffi::CString   unsafe fn from_raw(ptr: *mut c_char) -> CString;
```

I put a custom note on `from_raw`:

```rust
#[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `CString`"]
pub unsafe fn from_raw(ptr: *mut c_char) -> CString {
```

Parent issue: #89692

r? ``@joshtriplett``
2021-10-11 14:11:45 +02:00
Guillaume Gomez
77be7e441a
Rollup merge of #89729 - jkugelman:must-use-core-std-constructors, r=joshtriplett
Add #[must_use] to core and std constructors

Parent issue: #89692

r? ``@joshtriplett``
2021-10-11 14:11:43 +02:00
bors
6ae8912a3e Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov
Apply clippy suggestions for rustc and core
2021-10-11 11:14:47 +00:00
Flying-Toast
59b186d99a
Add enum_intrinsics_non_enums lint 2021-10-11 09:46:27 +02:00
bors
86d6d2b738 Auto merge of #89755 - jkugelman:must-use-conversions-that-move-self, r=joshtriplett
Add #[must_use] to conversions that move self

Everything here got the same message. Is the wording okay?

```rust
#[must_use = "`self` will be dropped if the result is not used"]
```

I want to draw attention to these methods in particular:

```rust
alloc::sync::Arc<MaybeUninit<T>>     unsafe fn assume_init(self) -> Arc<T>;
alloc::sync::Arc<[MaybeUninit<T>]>   unsafe fn assume_init(self) -> Arc<[T]>;
core::pin::Pin<&'a mut T>            const fn into_ref(self) -> Pin<&'a T>;
core::pin::Pin<&'a mut T>            const fn get_mut(self) -> &'a mut T;
core::pin::Pin<&'a mut T>            const unsafe fn get_unchecked_mut(self) -> &'a mut T;
core::pin::Pin<&'a mut T>            unsafe fn map_unchecked_mut(self, func: F) -> Pin<&'a mut U>;
core::pin::Pin<&'a mut Pin<P>>       fn as_deref_mut(self) -> Pin<&'a mut P::Target>;
```

Parent issue: #89692

r? `@joshtriplett`
2021-10-11 07:27:44 +00:00
John Kugelman
b115781bcd Add #[must_use] to conversions that move self 2021-10-10 19:50:52 -04:00
John Kugelman
cf2bcd10ed Add #[must_use] to from_value conversions 2021-10-10 19:00:33 -04:00
Matthias Krüger
c8b5a7b0c4
Rollup merge of #89720 - jkugelman:must-use-math-operations, r=joshtriplett
Add #[must_use] to math and bit manipulation methods

Also tidied up a few other nearby `#[must_use]`s.

Parent issue: #89692
2021-10-10 18:22:25 +02:00
Matthias Krüger
758a901a40
Rollup merge of #89719 - jkugelman:must-use-char-escape-methods, r=joshtriplett
Add #[must_use] to char escape methods

Parent issue: #89692
2021-10-10 18:22:24 +02:00
Matthias Krüger
0c04b1fc03
Rollup merge of #89718 - jkugelman:must-use-is_condition-tests, r=joshtriplett
Add #[must_use] to is_condition tests

There's nothing insightful to say about these so I didn't write any extra explanations.

Parent issue: #89692
2021-10-10 18:22:23 +02:00
Matthias Krüger
ce6097dfa4
Rollup merge of #89705 - nbdd0121:doc, r=GuillaumeGomez
Cfg hide no_global_oom_handling and no_fp_fmt_parse

These are unstable sysroot customisation cfg options that only projects building their own sysroot will use (e.g. Rust-for-linux). Most users shouldn't care. `no_global_oom_handling` can be especially annoying since it's applied on many commonly used alloc crate methods (e.g. `Box::new`, `Vec::push`).

r? ```@GuillaumeGomez```
2021-10-10 18:22:21 +02:00
Matthias Krüger
06cfd0af48
Rollup merge of #89438 - pierwill:prefix-free-hash, r=Amanieu
docs: `std:#️⃣:Hash` should ensure prefix-free data

Attempt to synthesize the discussion in #89429 into a suggestion regarding `Hash` implementations (not a hard requirement).

Closes #89429.
2021-10-10 18:22:20 +02:00
Matthias Krüger
4473b945bf
Rollup merge of #88713 - falk-hueffner:int-log10-documentation-fixes, r=scottmcm
Improve docs for int_log

* Clarify rounding.
* Avoid "wrapping" wording.
* Omit wrong claim on 0 only being returned in error cases.
* Typo fix for one_less_than_next_power_of_two.
2021-10-10 18:22:18 +02:00
Matthias Krüger
fd5bed73d0
Rollup merge of #88374 - joshlf:patch-2, r=JohnTitor
Fix documentation in Cell
2021-10-10 18:22:17 +02:00
Clemens Wasser
71dd0b928b Apply clippy suggestions 2021-10-10 15:38:19 +02:00
bors
0c87288f92 Auto merge of #89219 - nickkuk:str_split_once_get_unchecked, r=Mark-Simulacrum
Use get_unchecked in str::[r]split_once

This PR removes indices checking in `str::split_once` and `str::rsplit_once` methods.
2021-10-10 12:29:48 +00:00
John Kugelman
5b5c12be1c Add #[must_use] to core and std constructors 2021-10-10 02:44:26 -04:00
John Kugelman
bc9d13e658 Add #[must_use] to math and bit manipulation methods
Also tidied up a few other nearby `#[must_use]`s.
2021-10-09 22:43:32 -04:00
John Kugelman
fec9514727 Add #[must_use] to char escape methods 2021-10-09 21:35:09 -04:00
John Kugelman
475e9925a7 Add #[must_use] to is_condition tests
There's nothing insightful to say about these so I didn't write any
extra explanations.
2021-10-09 21:27:13 -04:00
pierwill
749194d847
Update library/core/src/hash/mod.rs
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-10-09 13:53:29 -05:00
Gary Guo
01825669b8 Cfg hide no_global_oom_handling and no_fp_fmt_parse 2021-10-09 17:07:33 +01:00
Guillaume Gomez
21a5101e21
Rollup merge of #89614 - cuviper:unicode-14, r=joshtriplett
Update to Unicode 14.0

The Unicode Standard [announced Version 14.0](https://home.unicode.org/announcing-the-unicode-standard-version-14-0/) on September 14, 2021, and this pull request updates the generated tables in `core` accordingly.

This did require a little prep-work in `unicode-table-generator`. First, #81358 had modified the generated file instead of the tool, so that change is now reflected in the tool as well. Next, I found that the "Alphabetic" property in version 14 was panicking when generating a bitset, "cannot pack 264 into 8 bits". We've been using the skiplist for that anyway, so I changed this to fail gracefully. Finally, I confirmed that the tool still created the exact same tables for 13 before moving to 14.
2021-10-09 17:08:40 +02:00
Guillaume Gomez
86bf3ce859
Rollup merge of #75644 - c410-f3r:array, r=yaahc
Add 'core::array::from_fn' and 'core::array::try_from_fn'

These auxiliary methods fill uninitialized arrays in a safe way and are particularly useful for elements that don't implement `Default`.

```rust
// Foo doesn't implement Default
struct Foo(usize);

let _array = core::array::from_fn::<_, _, 2>(|idx| Foo(idx));
```

Different from `FromIterator`, it is guaranteed that the array will be fully filled and no error regarding uninitialized state will be throw. In certain scenarios, however, the creation of an **element** can fail and that is why the `try_from_fn` function is also provided.

```rust
#[derive(Debug, PartialEq)]
enum SomeError {
    Foo,
}

let array = core::array::try_from_fn(|i| Ok::<_, SomeError>(i));
assert_eq!(array, Ok([0, 1, 2, 3, 4]));

let another_array = core::array::try_from_fn(|_| Err(SomeError::Foo));
assert_eq!(another_array, Err(SomeError::Foo));
 ```
2021-10-09 17:08:38 +02:00
Matthias Krüger
827b540424
Rollup merge of #89694 - jkugelman:must-use-string-transforms, r=joshtriplett
Add #[must_use] to string/char transformation methods

These methods could be misconstrued as modifying their arguments instead of returning new values.

Where possible I made the note recommend a method that does mutate in place.

Parent issue: #89692
2021-10-09 11:56:07 +02:00
Matthias Krüger
36db658796
Rollup merge of #88707 - sylvestre:split_example, r=yaahc
String.split_terminator: Add an example when using a slice of chars
2021-10-09 11:55:58 +02:00
John Kugelman
2ec7588aa1
Update library/core/src/num/mod.rs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-10-09 02:05:03 -04:00
John Kugelman
54d807cfc7 Add #[must_use] to string/char transformation methods
These methods could be misconstrued as modifying their arguments instead
of returning new values.

Where possible I made the note recommend a method that does mutate in
place.
2021-10-09 01:01:40 -04:00
Loïc BRANSTETT
31b2eb16e3 Cfg hide more conditions for core 2021-10-08 16:13:49 +02:00
Caio
85c4a52807 Also cfg flag auxiliar function 2021-10-08 06:40:24 -03:00
Jubilee
30e068f58b
Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank
Use correct edition for panic in [debug_]assert!().

See https://github.com/rust-lang/rust/issues/88638#issuecomment-915472783
2021-10-07 20:26:15 -07:00
Jubilee
2b6d7f75f7
Rollup merge of #88772 - orlp:result-map-or-else-docfix, r=yaahc
Fixed confusing wording on Result::map_or_else.

Fixes https://github.com/rust-lang/rust/issues/88195.
2021-10-07 20:26:11 -07:00
bors
2ee06e7372 Auto merge of #89638 - rust-lang:revert-88548-intersperse, r=Mark-Simulacrum
Revert "Stabilize `Iterator::intersperse()`"

Reverts rust-lang/rust#88548

First step in resolving https://github.com/rust-lang/rust/issues/88967
2021-10-07 23:50:54 +00:00
Ibraheem Ahmed
5f7e7d2e93 revert stabilization of core::task::ready! 2021-10-07 18:44:48 -04:00
Ibraheem Ahmed
a57c18b5e1 add Poll::ready 2021-10-07 15:47:28 -04:00
Jane Lusby
8965b5884a
Revert "Stabilize Iterator::intersperse()" 2021-10-07 10:39:36 -07:00
Guillaume Gomez
e32328bdc5
Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514
Make cfg imply doc(cfg)

This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):

 * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc.
 * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation.
 * I updated the version for the feature.

There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624)

> I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different.

How/why should they differ?

EDIT: this part has been solved, the current code was fine, just needed a little simplification.

cc `@Nemo157`
r? `@jyn514`

Original PR description:

This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like:

```rust
#[cfg(unix)]
#[doc(cfg(all()))]
pub struct Unix;
```

By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-07 16:24:53 +02:00
Mara Bos
afe5335b97 Use correct edition for panic in [debug_]assert!() etc. 2021-10-07 14:27:08 +02:00
Josh Stone
459a7e340c Regenerate tables for Unicode 14.0.0 2021-10-06 17:49:33 -07:00
Manish Goregaokar
1e3b5d6725
Rollup merge of #88523 - kpreid:category, r=yaahc
Expand documentation for `FpCategory`.

I intend these changes to be helpful to readers who are not yet familiar with the quirks of floating-point numbers. Additionally, I felt it was misleading to describe `Nan` as being the result of division by zero, since most divisions by zero (except for 0/0) produce `Infinite` floats, so I moved that remark to the `Infinite` variant with adjustment.

The first sentence of the `Nan` documentation is copied from `f32`; I followed the example of the `f64` documentation by referring to `f32` for general concepts, rather than duplicating the text.

----

I considered making similar changes to the documentation of the `is_*` methods of floats, but decided that that was a much larger and trickier problem; here, each of the variants' descriptions can be expected to be read in context of being mutually exclusive with the others.
2021-10-06 12:33:14 -07:00
Manish Goregaokar
3209582a87
Rollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm
Add functions to add unsigned and signed integers

This PR adds methods to unsigned integers to add signed integers with good overflow semantics under `#![feature(mixed_integer_ops)]`.

The added API is:

```rust
// `uX` is `u8`, `u16`, `u32`, `u64`,`u128`, `usize`
impl uX {
    pub const fn checked_add_signed(self, iX) -> Option<Self>;
    pub const fn overflowing_add_signed(self, iX) -> (Self, bool);
    pub const fn saturating_add_signed(self, iX) -> Self;
    pub const fn wrapping_add_signed(self, iX) -> Self;
}

impl iX {
    pub const fn checked_add_unsigned(self, uX) -> Option<Self>;
    pub const fn overflowing_add_unsigned(self, uX) -> (Self, bool);
    pub const fn saturating_add_unsigned(self, uX) -> Self;
    pub const fn wrapping_add_unsigned(self, uX) -> Self;

    pub const fn checked_sub_unsigned(self, uX) -> Option<Self>;
    pub const fn overflowing_sub_unsigned(self, uX) -> (Self, bool);
    pub const fn saturating_sub_unsigned(self, uX) -> Self;
    pub const fn wrapping_sub_unsigned(self, uX) -> Self;
}
```

Maybe it would be interesting to also have `add_signed` that panics in debug and wraps in release ?
2021-10-06 12:33:13 -07:00
Guillaume Gomez
8fac41a530 Clean up code a bit:
* Remove "bool_to_options" feature
 * Update version for compiler feature
 * rustfmt
2021-10-06 20:23:57 +02:00
Orson Peters
c3dfda0e3d Rebase Result::map_or_else doc wording on top of #89400. 2021-10-06 09:03:18 +02:00
Manish Goregaokar
4e8c853c9e
Rollup merge of #89502 - FabianWolff:issue-89493, r=joshtriplett
Fix Lower/UpperExp formatting for integers and precision zero

Fixes the integer part of #89493 (I daren't touch the floating-point formatting code). The issue is that the "subtracted" precision essentially behaves like extra trailing zeros, but this is not currently reflected in the code properly.
2021-10-05 12:52:46 -07:00
Wim Looman
0031ce3a91 Suppress some cfg from being shown in the stdlib docs 2021-10-05 18:15:29 +02:00
Trevor Spiteri
4ec0377d6a for signed overflowing remainder, delay comparing lhs with MIN
Since the wrapped remainder is going to be 0 for all cases when the rhs is -1,
there is no need to divide in this case. Comparing the lhs with MIN is only done
for the overflow bool. In particular, this results in better code generation for
wrapping remainder, which discards the overflow bool completely.
2021-10-05 15:15:24 +02:00
nickkuk
a35aaa2108 Use get_unchecked in str::[r]split_once 2021-10-05 14:42:08 +05:00
Jubilee
05b4cd6789
Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis
Correctly handle supertraits for min_specialization

Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.

r? ````@nikomatsakis````
2021-10-04 21:12:35 -07:00
Jubilee
234fa90878
Rollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se
Added abs_diff for integer types.

Closes https://github.com/rust-lang/rust/issues/62111.
2021-10-04 21:12:34 -07:00
Jubilee
9866b090f4
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04 13:58:17 -07:00
Jubilee
5352e17df3
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
Practice diagnostic message convention

Detected by #89455.

r? ```@estebank```
2021-10-04 13:58:15 -07:00
Jubilee
9e387cf27e
Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay
Improve wording of `map_or_else` docs

Changes doc text to refer to the "default" parameter as the "default"
function.

Previously, the doc text referred to the "f" parameter as the "default" function; and the "default" parameter as the "fallback" function.
2021-10-04 13:58:09 -07:00
Jubilee
ca8a10845f
Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett
implement advance_(back_)_by on more iterators

Add more efficient, non-default implementations for `feature(iter_advance_by)` (#77404) on more iterators and adapters.

This PR only contains implementations where skipping over items doesn't elide any observable side-effects such as user-provided closures or `clone()` functions. I'll put those in a separate PR.
2021-10-04 13:58:07 -07:00
Benoît du Garreau
47edde1086 Optimize saturating_add_signed 2021-10-04 18:52:17 +02:00
bors
175b8db73b Auto merge of #88834 - the8472:char-count, r=joshtriplett
optimize str::from_utf8() validation when slice contains multibyte chars and str.chars().count() in all cases

The change shows small but consistent improvements across several x86 target feature levels. I also tried to optimize counting with `slice.as_chunks` but that yielded more inconsistent results, bigger improvements for some optimization levels, lesser ones in others.

```
old, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,924 ns/iter (+/- 26)
test str::str_char_count_lorem                                  ... bench:         879 ns/iter (+/- 12)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,878 ns/iter (+/- 21)
test str::str_char_count_lorem                                  ... bench:         851 ns/iter (+/- 11)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,477 ns/iter (+/- 46)
test str::str_char_count_lorem                                  ... bench:         675 ns/iter (+/- 15)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,323 ns/iter (+/- 39)
test str::str_char_count_lorem                                  ... bench:         593 ns/iter (+/- 18)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         748 ns/iter (+/- 7)
test str::str_char_count_lorem                                  ... bench:         348 ns/iter (+/- 2)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         650 ns/iter (+/- 4)
test str::str_char_count_lorem                                  ... bench:         301 ns/iter (+/- 1)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)
```

and for the multibyte-char string validation:

```
old, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       4,606 ns/iter (+/- 64)

new, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       3,837 ns/iter (+/- 60)
```
2021-10-04 12:49:57 +00:00
Jacob Pratt
bce8621983
Stabilize const_panic 2021-10-04 02:33:33 -04:00
Manish Goregaokar
70d82e0a6e
Rollup merge of #88353 - jhpratt:stabilize-array-as-ref, r=joshtriplett
Partially stabilize `array_methods`

This stabilizes `<[T; N]>::as_slice` and `<[T; N]>::as_mut_slice`, which is forms part of the `array_methods` feature: #76118.

This also makes `<[T; N]>::as_slice` const due to its trivial nature.
2021-10-03 23:13:19 -07:00
Manish Goregaokar
e500f1c1e9
Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtriplett
Mark unsafe methods NonZero*::unchecked_(add|mul) as const.

Now that https://github.com/rust-lang/rfcs/pull/3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of #84186.
2021-10-03 23:13:17 -07:00
Manish Goregaokar
287af0403a
Rollup merge of #86828 - lambinoo:67441-const-fn-copied-take-replace, r=joshtriplett
const fn for option copied, take & replace

Tracking issue: [#67441](https://github.com/rust-lang/rust/issues/67441)

Adding const fn for the copied, take and replace method of Option. Also adding necessary unit test.

It's my first contribution so I am pretty sure I don't know what I'm doing but there's a first for everything!
2021-10-03 23:13:16 -07:00
Jacob Pratt
11140ff1a0
Stabilize unreachable_unchecked as const fn 2021-10-04 01:04:17 -04:00
Ryan Lopopolo
e41bb97c25
Add #[repr(i8)] to Ordering
Followup to #89491 to allow `Ordering` to auto-derive `AsRepr` once
the proposal to add `AsRepr` (#81642) lands.
2021-10-03 20:59:54 -07:00
Josh Triplett
199b33f0d7
Use a test value that doesn't depend on the handling of even/odd rounding 2021-10-03 20:15:12 -07:00
Fabian Wolff
e3996ffcb6 Fix Lower/UpperExp formatting for integers and precision zero 2021-10-03 23:05:03 +02:00
Benoît du Garreau
4846fd92c0 Revert suggested use of unwrap_or 2021-10-03 22:56:34 +02:00
Alphyr
70e55a8938
Apply suggestions
Co-authored-by: kennytm <kennytm@gmail.com>
2021-10-03 22:44:07 +02:00
Orson Peters
6dd6e7c002 Added tracking issue numbers for int_abs_diff. 2021-10-03 17:44:07 +02:00
Caio
91ad91efb6 Skip platforms without unwinding support 2021-10-03 12:25:23 -03:00
bors
5051904d66 Auto merge of #87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnay
Make `<[T]>::split_at_unchecked` and `<[T]>::split_at_mut_unchecked` public

The methods were originally added in https://github.com/rust-lang/rust/pull/75936 (30dc32b10e), but for some reason as private. Nevertheless, the methods have documentation and even a [tracking issue](https://github.com/rust-lang/rust/issues/76014).

It's very weird to have a tracking issue for private methods and these methods may be useful outside of the standard library. As such, this PR makes the methods public.
2021-10-03 13:41:52 +00:00
bors
4479cb82e5 Auto merge of #89459 - tspiteri:idiv-overflow-bitand, r=kennytm
Use bitand when checking for signed integer division overflow

For `self == Self::MIN && rhs == -1`, LLVM does not realize that this is the same check made by `self / rhs`, so the code generated may have some unnecessary duplication. For `(self == Self::MIN) & (rhs == -1)`, LLVM realizes it is the same check.
2021-10-03 10:34:57 +00:00
Hirochika Matsumoto
3818981ca1 Practice diagnostic message convention 2021-10-03 16:16:28 +09:00
Cameron Steffen
eec856bfbc Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
Trevor Spiteri
1139ee32aa Use bitand when checking for signed integer division overflow
For `self == Self::MIN && rhs == -1`, LLVM does not realize that this is the
same check made by `self / rhs`, so the code generated may have some unnecessary
duplication. For `(self == Self::MIN) & (rhs == -1)`, LLVM realizes it is the
same check.
2021-10-02 12:16:08 +02:00
Albin Hedman
81bb5a54c3
Revert "Auto merge of #86853 - usbalbin:const_try, r=oli-obk"
This reverts commit c6007fdc70, reversing
changes made to 69c1c6a173.
2021-10-02 00:07:48 +02:00
pierwill
2a5dcd5890 fix: edit description of "prefix-free" 2021-10-01 13:18:06 -05:00
pierwill
f531b8122e docs: std:#️⃣:Hash should ensure prefix-free data
Closes #89429
2021-10-01 12:41:22 -05:00
Benoît du Garreau
9faf621355 Add methods to add/sub uX to/from iX 2021-10-01 19:09:52 +02:00
Benoît du Garreau
b5dd5227ee Fix doc test 2021-10-01 19:08:14 +02:00
Alphyr
ab9f8a0b59 Apply suggestion for overflowing_add_signed
Co-authored-by: kennytm <kennytm@gmail.com>
2021-10-01 19:08:13 +02:00
Benoît du Garreau
fe11483afa Add functions to add unsigned and signed integers 2021-10-01 19:08:13 +02:00
bors
ed937594d3 Auto merge of #89403 - camsteffen:fmt-unsafe-private, r=Mark-Simulacrum
Add private arg to fmt::UnsafeArg

As discussed [here](https://github.com/rust-lang/rust/pull/89139#discussion_r719467357)

r? `@Mark-Simulacrum`
2021-10-01 12:08:35 +00:00
Manish Goregaokar
7b40d4240e
Rollup merge of #89303 - guswynn:std_suspend, r=dtolnay
Add `#[must_not_suspend]` to some types in std

I am not sure what else should have it? `Ref`?
2021-09-30 18:05:23 -07:00
Matthew Jasper
051d5b0118 Fix standard library for min_specialization changes 2021-09-30 21:42:41 +01:00
The8472
ffd7ade203 fix issues pointed out in review 2021-09-30 21:23:30 +02:00
the8472
6654a0bbdc from review: code style
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2021-09-30 21:23:30 +02:00
The8472
2c6e67105e implement advance_(back_)_by on more iterators 2021-09-30 21:23:28 +02:00
Cameron Steffen
f5e4f78eb7 Add private arg to fmt::UnsafeArg 2021-09-30 12:32:05 -05:00
Tyler Hart
35b0015b09
Improve wording of map_or_else docs
Changes doc text to refer to the "default" parameter as the "default"
function.
2021-09-30 11:12:09 -04:00
Frank Steffahn
355c7e9415 Remove an unnecessary use of unwrap_unchecked
also add a new SAFETY comment and simplify/remove a closure
2021-09-30 10:09:03 -03:00
Frank Steffahn
325025e74b Improve previous commit 2021-09-30 13:53:24 +02:00