Commit Graph

3807 Commits

Author SHA1 Message Date
Anirudh
4c42e3831f Update docs so that deprecated method points to relevant method 2022-09-26 19:28:51 +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
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
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
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
inquisitivecrystal
a0eb46788a Fix a typo in std's root docs 2022-09-23 01:45:43 -07:00
Dylan DPC
c99a603b87
Rollup merge of #102036 - Patiga:remove-io-errorkind-other-use-in-std, r=Mark-Simulacrum
Remove use of `io::ErrorKind::Other` in std

The documentation states that this `ErrorKind` is not used by the standard library. Instead, `io::ErrorKind::Uncategorized` should be used.

The two instances are in the unstable API [linux_pidfd](https://github.com/rust-lang/rust/issues/82971).
2022-09-22 18:25:52 +05:30
Dylan DPC
77d063b954
Rollup merge of #102058 - mqudsi:path_extension_docs, r=thomcc
Clarify Path::extension() semantics in docs abstract

State up-front and center what shape the returned extension will have, without making the user read through the description and examples.

This is a doc-only change. There are no changes to the API contract and the clarification is in line with what was already stated/promised in the existing doc text - just clarified, summarized, and served bright and early.

Rationale: Various frameworks and libraries for different platforms have their different conventions as to whether an "extension" is ".ext" or just "ext" and anyone that's had to deal with this ambiguity in the past is always double- or triple-checking to make sure the function call returns an extension that matches the expected semantics. Offer the answer to this important question right off the bat instead of making them dig to find it.

```@rustbot``` label +A-docs
2022-09-21 19:01:09 +05:30
bors
7743aa836e Auto merge of #100581 - joboet:sync_rwlock_everywhere, r=thomcc
std: use `sync::RwLock` for internal statics

Since `sync::RwLock` is now `const`-constructible, it can be used for internal statics, removing the need for `sys_common::StaticRwLock`. This adds some extra allocations on platforms which need to box their locks (currently SGX and some UNIX), but these will become unnecessary with the lock improvements tracked in #93740.
2022-09-20 22:00:08 +00:00
Chris Denton
8ca6a272bd
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-20 18:39:31 +01:00
Mahmoud Al-Qudsi
c291d2adec Clarify Path::extension() semantics in docs abstract
State up-front and center what shape the returned extension will have, without
making the user read through the description and examples.

Rationale: Various frameworks and libraries for different platforms have their
different conventions as to whether an "extension" is ".ext" or just "ext" and
anyone that's had to deal with this ambiguity in the past is always double- or
triple-checking to make sure the function call returns an extension that matches
the expected semantics. Offer the answer to this important question right off
the bat instead of making them dig to find it.
2022-09-20 11:12:03 -05:00
Patiga
04c108711e Remove use of io::ErrorKind::Other in std
The documentation states that this `ErrorKind` is not used by the
standard library. Instead, `io::ErrorKind::Uncategorized` should be
used.
2022-09-20 02:56:23 +02:00
joboet
be09a4a8b2
std: use sync::RwLock for internal statics 2022-09-19 23:27:26 +02:00
Matthias Krüger
ea076a4f9f
Rollup merge of #101798 - y86-dev:const_waker, r=lcnr
Make `from_waker`, `waker` and `from_raw` unstably `const`

Make
- `Context::from_waker`
- `Context::waker`
- `Waker::from_raw`

`const`.

Also added a small test.
2022-09-19 17:55:19 +02:00
Matthias Krüger
92d8bf918c
Rollup merge of #101861 - wesleywiser:update_stdarch, r=Amanieu
Update stdarch

This pulls in the following changes:

- [Use simd_bitmask intrinsic in a couple of places](9f0928782b)
- [Remove simd_shuffle<n> usage in favor of simd_shuffle](3fd17e4607)
- [Remove late specifiers in __cpuid_count](f1db941633)
  - Helps with #101346
- [Use mov and xchg instead of movl(q) and xchgl(q)](3049a31937)
- [Bump cfg-if dependency to 1.0](f305cc83e7)
- [Fix documentation of __m256bh and __m512bh structs](699c093a42)

r? ``@Amanieu``
2022-09-17 19:27:07 +02:00
Matthias Krüger
00d88bdb2c
Rollup merge of #101672 - idigdoug:array_try_into, r=Mark-Simulacrum
array docs - advertise how to get array from slice

On my first Rust project, I spent more time than I care to admit figuring out how to efficiently get an array from a slice. Update the array documentation to explain this a bit more clearly.

(As a side note, it's a bit unfortunate that get-array-from-slice is only available via trait since that means it can't be used from const functions yet.)
2022-09-17 19:27:05 +02:00
est31
173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
Wesley Wiser
9286c3c3f5 Update stdarch
stdarch updated their version of `cfg-if` so we need to update the one
used by libstd as well.
2022-09-15 13:05:28 -04:00
Matthias Krüger
93ae223951
Rollup merge of #101559 - andrewpollack:add-backtrace-off-fuchsia, r=tmandry
Adding "backtrace off" option for fuchsia targets

Used for improving compiler test suite results on Fuchsia targets
2022-09-15 08:00:12 +02:00
Andrew Pollack
88baf8f6f5 Adding backtrace off option for fuchsia targets 2022-09-14 23:54:40 +00:00
y86-dev
9a78faba71 Made from_waker, waker, from_raw const 2022-09-14 14:53:16 +02:00
Markus Reiter
14230a7f8e
Simplify clippy fix. 2022-09-12 19:46:51 +02:00
Markus Reiter
d01498a902
Add rustc_diagnostic_item for IP addresses. 2022-09-12 19:04:17 +02:00
Markus Reiter
f7e8ba28a4
Flatten net module again. 2022-09-12 19:04:17 +02:00
Markus Reiter
a1e4a339ed
Move net::parser into net::addr module. 2022-09-12 19:04:17 +02:00
Markus Reiter
65003fd4e3
Add tests for SockAddr Display. 2022-09-12 19:04:16 +02:00
Markus Reiter
96b44f6f65
Use DisplayBuffer for socket addresses. 2022-09-12 19:04:16 +02:00
Dylan DPC
93177758fc
Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726
Remove manual <[u8]>::escape_ascii

`@rustbot` label: +C-cleanup
2022-09-12 15:21:30 +05:30
bors
98e1f041b6 Auto merge of #101442 - joboet:null_check_tcs, r=thomcc
Check if TCS is a null pointer on SGX

The `EENTER` instruction only checks if the TCS is aligned, not if it zero. Saying the address returned is a `NonNull<u8>` (for which `Tcs` is a type alias) is unsound. As well-behaved runners will not put the TCS at address zero, so the definition of `Tcs` is correct. However, `std` should check the address before casting it to a `NonNull`.

ping `@jethrogb` `@raoulstrackx`
`@rustbot` label I-unsound
2022-09-11 22:19:24 +00:00
joboet
2fa58080cb
std: check if TCS is a null pointer 2022-09-11 12:15:32 +02:00
bors
56b625be68 Auto merge of #101482 - joboet:netbsd_parker, r=sanxiyn
Optimize thread parking on NetBSD

As the futex syscall is not present in the latest stable release, NetBSD cannot use the efficient thread parker and locks Linux uses. Currently, it therefore relies on a pthread-based parker, consisting of a mutex and semaphore which protect a state variable. NetBSD however has more efficient syscalls available: [`_lwp_park`](https://man.netbsd.org/_lwp_park.2) and [`_lwp_unpark`](https://man.netbsd.org/_lwp_unpark.2). These already provide the exact semantics of `thread::park` and `Thread::unpark`, but work with thread ids. In `std`, this ID is here stored in an atomic state variable, which is also used to optimize cases were the parking token is already available at the time `thread::park` is called.

r? `@m-ou-se`
2022-09-11 04:07:17 +00:00
Doug Cook (WINDOWS)
705a7667c5 array docs - advertise how to get array from slice
On my first Rust project, I spent more time than I care to admit
figuring out how to efficiently get an array from a slice. Update the
array documentation to explain this a bit more clearly.

(As a side note, it's a bit unfortunate that get-array-from-slice is
only available via trait since that means it can't be used from const
functions yet.)
2022-09-10 19:37:07 -07:00
bors
abd4d2ef0d Auto merge of #101643 - ChrisDenton:alloc-link-kernel32, r=thomcc
Explicitly link kernel32.lib from alloc
2022-09-11 01:44:09 +00:00
joboet
81b11ed698
std: optimize thread parking on NetBSD 2022-09-10 20:03:15 +02:00
Dylan DPC
33d54c4f73
Rollup merge of #101606 - akhi3030:patch-1, r=Dylan-DPC
doc: fix minor typo
2022-09-10 18:56:07 +05:30
Chris Denton
931e851144
Explicitly link kernel32.lib from alloc 2022-09-10 11:57:36 +01:00
bors
395e56f398 Auto merge of #101617 - Dylan-DPC:rollup-iiy4ipc, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #101366 (Restore old behaviour on broken UNC paths)
 - #101492 (Suggest adding array lengths to references to arrays if possible)
 - #101529 (Fix the example code and doctest for Formatter::sign_plus)
 - #101573 (update `ParamKindOrd`)
 - #101612 (Fix code generation of `Rvalue::Repeat` with 128 bit values)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-09 23:06:40 +00:00
Dylan DPC
d9609c7c26
Rollup merge of #101366 - ChrisDenton:unc-forward-slash, r=m-ou-se
Restore old behaviour on broken UNC paths

This fixes #101358 by restoring the behaviour from previous stable Rust versions. I'm not convinced this is ultimately right but I think it's less wrong and maybe this should be backported to beta?

r? libs
2022-09-09 22:02:16 +05:30
joboet
262193e044
std: use futex-based locks and thread parker on Hermit 2022-09-09 11:56:50 +02:00
Akhilesh Singhania
1933b74dbd
doc: fix minor typo 2022-09-09 11:30:40 +02:00
Michael Goulet
2c4dc4f494
Rollup merge of #101423 - mkroening:hermit-warnings, r=sanxiyn
Fix hermit warnings

This fixes two `unused_imprt` and one `dead_code` warning for hermit.
2022-09-08 14:41:08 -07:00
Dylan DPC
7064344ba4
Rollup merge of #101422 - mkroening:hermit-file-time, r=joshtriplett
Hermit: Add File::set_time stub

This is not supported on hermit yet. This change is required for compiling std.
2022-09-08 11:55:07 +05:30
bors
c2804e6ec2 Auto merge of #101544 - matthiaskrgr:rollup-4urx917, r=matthiaskrgr
Rollup of 14 pull requests

Successful merges:

 - #101343 (Add -api-level to pm command)
 - #101416 (stdio: Document no support for writing to non-blocking stdio/stderr)
 - #101435 (Remove unnecessary `EMIT_MIR_FOR_EACH_BITWIDTH`)
 - #101493 (Pass ImplTraitContext as &mut to avoid the need of ImplTraitContext::reborrow)
 - #101502 (Do not suggest a semicolon for a macro without `!`)
 - #101503 (Add debug calls)
 - #101506 (rustdoc: remove unused CSS `#main-content > .since`)
 - #101507 (rustdoc: remove unused CSS `#main-content > table td`)
 - #101521 (Rustdoc-Json: More accurate struct type.)
 - #101525 (Fix typo in pass_manager.rs)
 - #101534 (rustdoc: remove unused mobile CSS `.rustdoc { flex-direction }`)
 - #101535 (Fix error printing mistake in tidy)
 - #101536 (Add documentation for Attr::is_doc_comment)
 - #101538 (rustdoc: remove unused CSS `.content .methods > div`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-07 21:17:30 +00:00
bors
9682b5d3a3 Auto merge of #101476 - ChrisDenton:BCryptRandom-fix, r=thomcc
Open a BCrypt algorithm handle

Fixes #101474, supplants #101456.

Replaces use of a pseduo handle with manually opening a algorithm handle.

Most interesting thing here is the atomics.

r? `@thomcc`
2022-09-07 18:54:03 +00:00
Usama Arif
dfbc1f712d stdio: Document no support for writing to non-blocking stdio/stderr
Printing to stdio/stderr that have been opened with non-blocking
(O_NONBLOCK in linux) can result in an error, which is not handled
by std::io module causing a panic.

Signed-off-by: Usama Arif <usama.arif@bytedance.com>
2022-09-07 14:22:57 +01:00
Chris Denton
832c7af0ea
Don't break windows/rand for miri 2022-09-07 14:00:15 +01:00
Chris Denton
b2e4f9dcb3
Open a BCrypt algorithm handle 2022-09-06 19:29:58 +01:00
Chris Denton
774e71228c
Fix compile errors for uwp-windows-msvc targets 2022-09-06 14:57:42 +01:00