Commit Graph

9223 Commits

Author SHA1 Message Date
Michael Howell
7381d7d8b2
Rollup merge of #102326 - yancyribbens:splin-mut-doc-change, r=thomcc
rustdoc: Update doc comment for splitn_mut to include mutable in the …

The doc comment for [splitn](https://github.com/rust-lang/rust/blob/master/library/core/src/slice/mod.rs#L2051:L2056) is the exact same as the comment for [splitn_mut](https://github.com/rust-lang/rust/blob/master/library/core/src/slice/mod.rs#L2079:L2084).  The doc comment for `splitn_mut` should instead say it's working on a mutable subslice.
2022-09-26 15:40:55 -07:00
Michael Howell
66bab6b781
Rollup merge of #102322 - sigaloid:master, r=GuillaumeGomez
Document that Display automatically implements ToString

Closes #92941

r? rust-lang/docs
2022-09-26 15:40:54 -07:00
Michael Howell
2668a6839a
Rollup merge of #102283 - GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc
Improve code example for Option::unwrap_or_default

Fixes #100054.
Follow-up of #102259.

r? ``@thomcc``
2022-09-26 15:40:52 -07:00
yancy
40f404468a rustdoc: Update doc comment for splitn_mut to include mutable in the description 2022-09-26 20:20:13 +02:00
Matthew Esposito
4fad063cba Document that Display entails ToString 2022-09-26 13:03:59 -04:00
Guillaume Gomez
475aeab79e Improve code example for Option::unwrap_or_default 2022-09-26 12:37:41 +02:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
Pietro Albini
d0305b3d00
replace stabilization placeholders 2022-09-26 10:13:44 +02:00
bors
72f4923979 Auto merge of #102297 - fee1-dead-contrib:rollup-2np0cre, r=fee1-dead
Rollup of 5 pull requests

Successful merges:

 - #102143 (Recover from struct nested in struct)
 - #102178 (bootstrap: the backtrace feature is stable, no need to allow it any more)
 - #102197 (Stabilize const `BTree{Map,Set}::new`)
 - #102267 (Don't set RUSTC in the bootstrap build script)
 - #102270 (Remove benches from `rustc_middle`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-26 05:27:43 +00:00
fee1-dead
804c2c1ed9
Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-26 13:09:42 +08:00
fee1-dead
beb224084d
Rollup merge of #102263 - GuillaumeGomez:iterator-rposition-example, r=thomcc
Clarify Iterator::rposition code example

Fixes #101095.

r? `@thomcc`
2022-09-26 09:27:37 +08:00
fee1-dead
c50303ca1f
Rollup merge of #102259 - gimbles:patch-1, r=joshtriplett
Type-annotate and simplify documentation of Option::unwrap_or_default

Part of #100054
2022-09-25 22:06:41 +08:00
fee1-dead
b00b918f28
Rollup merge of #102245 - ink-feather-org:const_cmp_by, r=fee1-dead
Constify cmp_min_max_by.

Constifies `core::cmp::{min, max}_by[_key]` behind the `const_cmp` #92391 feature gate, using `const_closure`.
2022-09-25 22:06:40 +08:00
fee1-dead
69aa41b000
Rollup merge of #102200 - ink-feather-org:const_default_impls, r=fee1-dead
Constify Default impl's for Arrays and Tuples.

Allows to create arrays and tuples in const Context using the ~const Default implementation of the inner type.
2022-09-25 22:06:40 +08:00
fee1-dead
da884d25da
Rollup merge of #101800 - chriss0612:feat/const_split_at_mut, r=fee1-dead
Constify slice.split_at_mut(_unchecked)

Tracking Issue: [Tracking Issue for const_slice_split_at_mut](https://github.com/rust-lang/rust/issues/101804)

Feature gate: `#![feature(const_slice_split_at_mut)]`

Still requires const_mut_refs to be actually used, but this feature removes the need to manually re implement these functions in a user crate.
2022-09-25 22:06:38 +08:00
fee1-dead
033f93fbb9
Rollup merge of #98111 - eggyal:issue-97982, r=GuillaumeGomez
Clarify `[T]::select_nth_unstable*` return values

In cases where the nth element is not unique within the slice, it is not
correct to say that the values in the returned triplet include ones for
"all elements" less/greater than that at the given index: indeed one (or
more) such values would then also contain elements equal to that at
the given index.

The text proposed here clarifies exactly what is returned, but in so
doing it is also documenting an implementation detail that previously
wasn't detailed: namely that the returned slices are slices into the
reordered slice.  I don't think this can be contentious, because the
lifetimes of those returned slices are bound to that of the original
(now reordered) slice—so there really isn't any other reasonable
implementation that could have this behaviour; but nevertheless it's
probably best if `@rust-lang/libs-api` give it a nod?

Fixes #97982
r? `@m-ou-se`

`@rustbot` label +A-docs +C-bug +T-libs-api -T-libs
2022-09-25 22:06:36 +08:00
Guillaume Gomez
a20672c919 Clarify Iterator::rposition code example 2022-09-25 14:09:41 +02:00
Gimgim
4411d5fcc7
Update option.rs 2022-09-25 15:48:08 +05:30
bors
8e9c93df46 Auto merge of #99609 - workingjubilee:lossy-unix-strerror, r=thomcc
Recover error strings on Unix from_lossy_utf8

Some language settings can result in unreliable UTF-8 being produced.
This can result in failing to emit the error string, panicking instead.
from_lossy_utf8 allows us to assume these strings usually will be fine.

This fixes rust-lang#99535.
2022-09-25 06:53:14 +00:00
bors
e20fabb0d0 Auto merge of #98457 - japaric:gh98378, r=m-ou-se
make Condvar, Mutex, RwLock const constructors work with the `unsupported` impl

applying this patch locally to the `rust-src` component fixes #98378

however, the solution seems wrong to me because PR #97791 didn't add any `rustc_const_stable` attribute to underlying implementations like `std::sys::unix::futex`, so I must be missing something about how const-stability is checked ... maybe the `restricted_std` feature (gate?) has an effect?

fixes #98378
fixes #98293 (probably)
2022-09-25 04:12:30 +00:00
bors
e58621a4a3 Auto merge of #102169 - scottmcm:constify-some-conditions, r=thomcc
Make ZST checks in core/alloc more readable

There's a bunch of these checks because of special handing for ZSTs in various unsafe implementations of stuff.

This lets them be `T::IS_ZST` instead of `mem::size_of::<T>() == 0` every time, making them both more readable and more terse.

*Not* proposed for stabilization.  Would be `pub(crate)` except `alloc` wants to use it too.

(And while it doesn't matter now, if we ever get something like #85836 making it a const can help codegen be simpler.)
2022-09-25 01:20:11 +00:00
onestacked
2e7a201d2e Constify cmp_min_max_by 2022-09-24 22:12:00 +02:00
Scott McMurray
ed16dbf65e Add some more documentation 2022-09-24 12:12:41 -07:00
bors
6580010551 Auto merge of #102234 - matthiaskrgr:rollup-5cb20l1, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #100823 (Refactor some `std` code that works with pointer offstes)
 - #102088 (Fix wrongly refactored Lift impl)
 - #102109 (resolve: Set effective visibilities for imports more precisely)
 - #102186 (Add const_closure, Constify Try trait)
 - #102203 (rustdoc: remove no-op CSS `#source-sidebar { z-index }`)
 - #102204 (Make `ManuallyDrop` satisfy `~const Destruct`)
 - #102210 (diagnostics: avoid syntactically invalid suggestion in if conditionals)
 - #102226 (bootstrap/miri: switch to non-deprecated env var for setting the sysroot folder)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-24 14:37:01 +00:00
Matthias Krüger
455a20b7ba
Rollup merge of #102186 - ink-feather-org:const_try_trait, r=fee1-dead
Add const_closure, Constify Try trait

Adds a struct for creating const `FnMut` closures (for now just copy pasted form my [const_closure](https://crates.io/crates/const_closure) crate).
I'm not sure if this way is how it should be done.
The `ConstFnClosure` and `ConstFnOnceClosure` structs can probably also be entirely removed.

This is then used to constify the try trait.

Not sure if i should add const_closure in its own pr and maybe make it public behind a perma-unstable feature gate.

cc ```@fee1-dead```  ```@rust-lang/wg-const-eval```
2022-09-24 14:29:54 +02:00
Matthias Krüger
1b1596c118
Rollup merge of #100823 - WaffleLapkin:less_offsets, r=scottmcm
Refactor some `std` code that works with pointer offstes

This PR replaces `pointer::offset` in standard library with `pointer::add` and `pointer::sub`, [re]moving some casts and using `.addr()` while we are at it.

This is a more complicated refactor than all other sibling PRs, so take a closer look when reviewing, please 😃  (though I've checked this multiple times and it looks fine).

r? ````@scottmcm````

_split off from #100746, continuation of #100822_
2022-09-24 14:29:52 +02:00
bors
cdb76db493 Auto merge of #102167 - thomcc:exclusive-inline, r=scottmcm
Add `#[inline]` to trivial functions on `core::sync::Exclusive`

When optimizing for size things like these sometimes don't inlined even though they're generic. This is bad because they're no-ops.

Only dodgy one is poll I guess since it forwards to the inner poll, but it's not like we're doing `#[inline(always)]` here.
2022-09-24 12:17:53 +00:00
bors
199fe1d169 Auto merge of #102223 - matthiaskrgr:rollup-wb1qdhk, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #101780 (Add a platform support document for Android)
 - #102044 (Remove `RtlGenRandom` (take two))
 - #102081 (Adding ignore fuchsia tests for execvp (pre_exec))
 - #102082 (Adding ignore fuchsia non-applicable commands)
 - #102146 (rustdoc: CSS prevent sidebar width change jank)
 - #102152 (Calculate `ProjectionTy::trait_def_id` for return-position `impl Trait` in trait correctly)
 - #102175 (Also require other subtrees to always build successfully)
 - #102176 (Add `llvm-dis` to the set of tools in `ci-llvm`)
 - #102188 (Update doc after renaming `fn is_zero`)
 - #102199 (Improve rustdoc GUI tests)
 - #102218 (Document some missing command-line arguments)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-24 06:55:32 +00:00
Matthias Krüger
be902e8905
Rollup merge of #102188 - flba-eb:doc_missed_at_rename, r=jyn514
Update doc after renaming `fn is_zero`

`fn is_zero` has been renamed to `fn count_is_zero` in 1b1bf24636.
This patch updates the documentation accordingly.
2022-09-24 07:38:57 +02:00
Matthias Krüger
3baf5f8d9a
Rollup merge of #102044 - ChrisDenton:BCrypt-system-rand, r=thomcc
Remove `RtlGenRandom` (take two)

First try to use the system preferred RNG but if that fails (e.g. due to a broken system configuration) then fallback to manually opening an algorithm handle.
2022-09-24 07:38:53 +02:00
Scott McMurray
f0dc35927b Put back one of the uses for intra-doc mentions 2022-09-23 21:47:23 -07:00
bors
06968954f7 Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm
Use internal iteration in `Iterator` comparison methods

Updates the `Iterator` methods `cmp_by`, `partial_cmp_by`, and `eq_by` to use internal iteration on `self`. I've also extracted their shared logic into a private helper function `iter_compare`, which will either short-circuit once the comparison result is known or return the comparison of the lengths of the iterators.

This change also indirectly benefits calls to `cmp`, `partial_cmp`, `eq`, `lt`, `le`, `gt`, and `ge`.

Unsurprising benchmark results: iterators that benefit from internal iteration (like `Chain`) see a speedup, while other iterators are unaffected.
```
 name                           before ns/iter  after ns/iter  diff ns/iter   diff %  speedup
 iter::bench_chain_partial_cmp  208,301         54,978             -153,323  -73.61%   x 3.79
 iter::bench_partial_cmp        55,527          55,702                  175    0.32%   x 1.00
 iter::bench_lt                 55,502          55,322                 -180   -0.32%   x 1.00
```
2022-09-24 04:04:46 +00:00
Nilstrieb
aa35ab81ea Stabilize const BTree{Map,Set}::new
Since `len` and `is_empty` are not const stable yet, this also
creates a new feature for them since they previously used the same
`const_btree_new` feature.
2022-09-23 20:55:37 +02:00
onestacked
84666afb36 Constify Residual behind const_try 2022-09-23 20:17:31 +02:00
onestacked
d78bc41785 Remove unused ConstFn(Once)Closure structs. 2022-09-23 19:55:51 +02:00
onestacked
6267c60f6a Added some spacing in const closure 2022-09-23 18:20:57 +02:00
onestacked
449326aaad Added const Default impls for Arrays and Tuples. 2022-09-23 17:53:59 +02:00
Matthias Krüger
dfe045ad71
Rollup merge of #102177 - inquisitivecrystal:std-doc-typo, r=Dylan-DPC
Fix a typo in `std`'s root docs

Remarkably, this typo has been present for *seven years.* I was so surprised that I reread the text five times and then asked people on the rust Zulip to double-check. :)
2022-09-23 15:40:23 +02:00
Matthias Krüger
6b001f3d68
Rollup merge of #102115 - Alfriadox:master, r=thomcc
Add examples to `bool::then` and `bool::then_some`

Added examples to `bool::then` and `bool::then_some` to show the distinction between the eager evaluation of `bool::then_some` and the lazy evaluation of `bool::then`.
2022-09-23 15:40:20 +02:00
Matthias Krüger
986fc4b5d2
Rollup merge of #102094 - GuillaumeGomez:bool-from-str-missing-docs, r=scottmcm
Add missing documentation for `bool::from_str`

Fixes #101870.
2022-09-23 15:40:20 +02:00
onestacked
53049f7dcd Fixed Doc-Tests 2022-09-23 15:39:13 +02:00
Florian Bartels
8eeeac69db Update doc after renaming fn is_zero
`fn is_zero` has been renamed to `fn count_is_zero` in
1b1bf24636.
This patch updates the documentation accordingly.
2022-09-23 14:16:35 +02:00
onestacked
8e0ea60a04 Constifed Try trait 2022-09-23 13:43:34 +02:00
onestacked
0b2f717dfa Added const_closure 2022-09-23 13:42:31 +02:00
inquisitivecrystal
a0eb46788a Fix a typo in std's root docs 2022-09-23 01:45:43 -07:00
Scott McMurray
cbbcd9f52c rustfmt 2022-09-22 23:13:12 -07:00
Scott McMurray
44b4ce1d61 Make ZST checks in core/alloc more readable
There's a bunch of these checks because of special handing for ZSTs in various unsafe implementations of stuff.

This lets them be `T::IS_ZST` instead of `mem::size_of::<T>() == 0` every time, making them both more readable and more terse.

*Not* proposed for stabilization at this time.  Would be `pub(crate)` except `alloc` wants to use it too.

(And while it doesn't matter now, if we ever get something like 85836 making it a const can help codegen be simpler.)
2022-09-22 23:12:29 -07:00
Thom Chiovoloni
29efe8c789
Add #[inline] to trivial functions on core::sync::Exclusive 2022-09-22 22:15:27 -07:00
Matthias Krüger
23370637ef
Rollup merge of #102144 - chriss0612:const_convert_control_flow, r=scottmcm
Extend const_convert with const {FormResidual, Try} for ControlFlow.

Very small change so I just used the existing `const_convert` feature flag.  #88674
Newly const API:
```
impl<B, C> const ops::Try for ControlFlow<B, C>;
impl<B, C> const ops::FromResidual for ControlFlow<B, C>;
```

`@usbalbin` I hope it is ok that I added to your feature.
2022-09-22 21:34:55 +02:00
onestacked
5a5138df59 Constify {FormResidual, Try} for ControlFlow 2022-09-22 18:21:34 +02:00