Commit Graph

4862 Commits

Author SHA1 Message Date
Matthias Krüger
487fe2e5ad
Rollup merge of #115512 - Fulgen301:startupinfow, r=ChrisDenton
Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of

Fixes #115511.
2023-09-03 21:38:43 +02:00
Matthias Krüger
33e2e71502
Rollup merge of #115489 - saethlin:is-interrupted, r=thomcc
Use std::io::Error::is_interrupted everywhere

In https://github.com/rust-lang/rust/pull/115228 I introduced this helper and started using it, this PR uses it to replace all applicable uses of `std::io::Error::kind`. The justification is the same; for whatever reason LLVM totally flops optimizing `Error::kind` so it's nice to use it less.

FYI ``@mkroening`` I swear the hermit changes look good, but I was so sure about the previous PR.
2023-09-03 21:38:43 +02:00
Fulgen301
a8b0e44e86
Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of 2023-09-03 17:04:42 +02:00
Ben Kimock
642251b71f Use std::io::Error::is_interrupted everywhere 2023-09-03 09:21:10 -04:00
Matthias Krüger
43e15613d1
Rollup merge of #115443 - epage:os_str, r=cuviper
feat(std): Stabilize 'os_str_bytes' feature

Closes #111544
2023-09-02 07:48:22 +02:00
Matthias Krüger
b44bf0d117
Rollup merge of #115427 - solid-rs:patch/kmc-solid/is-interrupted, r=cuviper
kmc-solid: Fix `is_interrupted`

Follow-up to #115228. Fixes a build error in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

```
error[E0603]: function `is_interrupted` is private
  --> library\std\src\sys\solid\mod.rs:77:12
   |
77 |     error::is_interrupted(code)
   |            ^^^^^^^^^^^^^^ private function
   |
note: the function `is_interrupted` is defined here
  --> library\std\src\sys\solid\error.rs:35:1
   |
35 | fn is_interrupted(er: abi::ER) -> bool {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2023-09-02 07:48:22 +02:00
Ed Page
30292bb68e fix(std): Rename os_str_bytes to encoded_bytes 2023-09-01 19:33:16 -05:00
Ed Page
9aee1de612 feat(std): Stabilize 'os_str_bytes' feature
Closes #111544
2023-09-01 11:13:45 -05:00
bors
dc348dbd90 Auto merge of #114448 - SteveLauC:std_fs_read_doc, r=Mark-Simulacrum
docs: improve std::fs::read doc

#### What does this PR do

1. Rephrase a confusing sentence in the document of `std::fs::read()`

-----

Closes #114432

cc `@Dexus0` `@saethlin`
2023-09-01 05:25:44 +00:00
Tomoaki Kawada
eb627ea339 kmc-solid: Refactor is_interrupted to avoid integer overflow 2023-09-01 11:55:48 +09:00
Steve Lau
0e270b1a97 docs: improve std::fs::read doc 2023-09-01 10:54:37 +08:00
Tomoaki Kawada
dc37959ce8 kmc-solid: Directly delegate to net::is_interrupted in std::sys::solid::is_interrupted 2023-09-01 11:53:15 +09:00
bors
a517049d8c Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc
fix(sys/hermit): add is_interrupted

https://github.com/rust-lang/rust/pull/115228 broke compilation for Hermit by not adding a Hermit implementation of is_interrupted.
2023-08-29 04:11:13 +00:00
bors
fef2f5907f Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper
fix(sys/hermit): remove obsolete network initialization

This function does not exist as of hermit-sys 0.4.1 ([`e38f246`]). Once std does not call this function, we can remove it entirely.

CC: `@stlankes`

[`e38f246`]: e38f246e04 (diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10)
2023-08-29 00:37:48 +00:00
Matthias Krüger
2eff0deca3
Rollup merge of #115310 - RalfJung:panic-and-format, r=scottmcm
Document panic behavior across editions, and improve xrefs

This revives (parts of) https://github.com/rust-lang/rust/pull/96518.
r? `@scottmcm`
Cc `@ijackson`
2023-08-28 19:53:56 +02:00
bors
9847c6406d Auto merge of #114848 - michaelvanstraten:spawn_with_attributes, r=ChrisDenton
Add ability to spawn Windows process with Proc Thread Attributes | Take 2

This is the second attempt to merge pull request #88193 into the standard library.

This PR implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait.

`@TyPR124` and my main motivation behind adding this feature is to enable the support of pseudo terminals in the std library, but there are many more applications. A good starting point to get into this topic is to head over to the [`Win32 API documentation`](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute).
2023-08-28 10:55:05 +00:00
Martin Kröning
eee27331ba
fix(sys/hermit): add is_interrupted
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-08-28 12:42:12 +02:00
Martin Kröning
5853c2bdd3
fix(sys/hermit): remove obsolete network initialization
This function does not exist as of hermit-sys 0.4.1 [1].
Once std does not call this function, we can remove it entirely.

[1]: e38f246e04 (diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10)

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-08-28 12:37:42 +02:00
Ian Jackson
55159e80ad print macros: add xrefs to format syntax documentation 2023-08-28 11:51:41 +02:00
Matthias Krüger
32053f7602
Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=Amanieu
avoid triple-backtrace due to panic-during-cleanup

Supersedes https://github.com/rust-lang/rust/pull/115020
Cc https://github.com/rust-lang/rust/issues/114954
r? ``@Amanieu``
2023-08-28 08:13:59 +02:00
Matthias Krüger
eb569400e5
Rollup merge of #114512 - devnexen:fix_tests_fbsd, r=thomcc
std/tests: disable ancillary tests on freebsd since the feature itsel…

…f is.
2023-08-28 08:13:57 +02:00
Matthias Krüger
fb98f7adc3
Rollup merge of #109660 - ijackson:leap, r=thomcc
Document that SystemTime does not count leap seconds

Fixes #77994

This may not be entirely uncontroversial.  I know that `@Ekleog` is going to disagree.  However, in support of this docs change:

 This documents the current behaviour.  The alternative would be to plan to *change* the behaviour.

There are many programs which need to get a POSIX time (a `time_t`).  Right now, `duration_since(UNIX_EPOCH)` is the only facility in std that does that.  So, that is what programs use.  Changing the behaviour would  break[1] all of those programs.  We would need to define a new API that can be used to get a POSIX time, and get everyone to use it.  This seems highly unpalatable.

And, even if we wanted to do that, time with leap seconds is a lot less easy to work with.  We would need to arrange to have a leap seconds table available to `std` somehow, and make sure that it was kept up to date.  Currently we don't offer to do that for timezone data, which has similar needs.  There are other complications.  So it seems it would be awkwarrd to *implement* a facility that provides time including leap seconds, and the resulting value would be hard for applications to work with.

Therefore, I think it's clear that we don't want to plan to ever change `SystemTime`.  We should plan to keep it the way it is.  Providing TAI (for example) should be left to external crates, or additional APIs we may add in the future.

For more discussion see #77994 and in particular `@fanf2's` https://github.com/rust-lang/rust/issues/77994#issuecomment-1409448174

[1]  Of course, by "break" we really only mean *future* breakage in the case where there is, in fact, ever another leap second.  There may well not be: they are in the process of being abolished (although this is of course being contested).  But if we decide that `SystemTime::now().duraton_since(UNIX_EPOCH)` counts leap seconds, it would start to return `Durations`s that are 27s different to the current answers.   That's clearly unacceptable.  And we can hardly change `UNIX_EPOCH` by 27s.
2023-08-28 08:13:56 +02:00
bors
1baf77aad0 Auto merge of #115254 - cuviper:aligned_alloc-size, r=thomcc
wasi: round up the size for `aligned_alloc`

C11 `aligned_alloc` requires that the size be a multiple of the
alignment. This is enforced in the wasi-libc emmalloc implementation,
which always returns NULL if the size is not a multiple.
(The default `MALLOC_IMPL=dlmalloc` does not currently check this.)
2023-08-28 00:02:42 +00:00
Ralf Jung
1087e90a2e avoid triple-backtrace due to panic-during-cleanup 2023-08-27 20:02:46 +02:00
Matthias Krüger
922b827b8c
Rollup merge of #115007 - kpreid:alloc, r=Mark-Simulacrum
Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`.

The primary goal of this change is to remove the false claim that `handle_alloc_error` always aborts; instead, code should be prepared for `handle_alloc_error` to possibly unwind, and be sound under that condition.

I saw other opportunities for improvement, so I have added all the following information:

* `handle_alloc_error` may panic instead of aborting. (Fixes #114898)
* What happens if a hook returns rather than diverging.
* A hook may panic. (This was already demonstrated in an example, but not stated in prose.)
* A hook must be sound to call — it cannot assume that it is only called by the runtime, since its function pointer can be retrieved by safe code.

I've checked these statements against the source code of `alloc` and `std`, but there may be nuances I haven't caught, so a careful review is welcome.
2023-08-27 09:45:18 +02:00
Josh Stone
1c6d867d78 wasi: round up the size for aligned_alloc
C11 `aligned_alloc` requires that the size be a multiple of the
alignment. This is enforced in the wasi-libc emmalloc implementation,
which always returns NULL if the size is not a multiple.
(The default `MALLOC_IMPL=dlmalloc` does not currently check this.)
2023-08-26 11:50:16 -07:00
bors
9334ec9354 Auto merge of #115228 - saethlin:is-interrupted, r=thomcc
Add a new helper to avoid calling io::Error::kind

On `cfg(unix)`, `Error::kind` emits an enormous jump table that LLVM seems unable to optimize out. I don't really understand why, but see for yourself: https://godbolt.org/z/17hY496KG

This change lets us check for `ErrorKind::Interrupted` without going through a big match. I've checked the codegen locally, and it has the desired effect on the codegen for `BufReader::read_exact`.
2023-08-26 02:19:08 +00:00
Ben Kimock
1abaf40ec8 Add a new helper to avoid calling io::Error::kind 2023-08-25 21:26:06 -04:00
Michael van Straten
edefa8b105 Added option to set ProcThreadAttributes for Windows processes
This implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait. Setting these attributes provides extended configuration options for Windows processes.

Co-authored-by: Tyler Ruckinger <t.ruckinger@gmail.com>
2023-08-25 16:30:34 +02:00
Matthias Krüger
b88849d77c
Rollup merge of #114754 - workingjubilee:gamma-ray-logger, r=thomcc
Name what ln_gamma does

The previous description omitted some important details.
2023-08-25 09:00:12 +02:00
Weihang Lo
351445ad44
Rollup merge of #115124 - solid-rs:patch/kmc-solid/import-poison-error-in-os, r=cuviper
kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os`

Follow-up to #114968. Fixes a missing import in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

```
 error[E0433]: failed to resolve: use of undeclared type `PoisonError`
 C:\Users\xxxxx\.rustup\toolchains\nightly-2023-08-23-x86_64-pc-windows-gnu\lib\rustlib\src\rust\library\std\src\sys\solid\os.rs(85,36)
   |
85 |     ENV_LOCK.read().unwrap_or_else(PoisonError::into_inner)
   |                                    ^^^^^^^^^^^ use of undeclared type `PoisonError`
   |
```
2023-08-24 22:53:58 +01:00
bors
8a6b67f988 Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur
Update bootstrap compiler to 1.73.0 beta
2023-08-24 11:10:52 +00:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
Guillaume Gomez
128ff0897b
Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-Simulacrum
Fix a pthread_t handle leak #114610

https://github.com/rust-lang/rust/issues/114610

Ran the tests as described in https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md?plain=1#L125
2023-08-23 17:46:33 +02:00
Dylan DPC
21411c4db5
Rollup merge of #115053 - waywardmonkeys:augment-type-keyword-docs, r=cuviper
docs: Add example, reference link for `type` keyword.

Fixes #114281.
2023-08-23 05:35:16 +00:00
Tomoaki Kawada
65217a72b0 kmc-solid: Import std::sync::PoisonError in std::sys::solid::os 2023-08-23 11:44:18 +09:00
Mark Rousskov
c8522adb97 Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
Michael Howell
88bd304a10 docs: add alias log1p to ln_1p
This is what the function is called in several other languages:

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p
* https://numpy.org/doc/stable/reference/generated/numpy.log1p.html
* https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/log1p-log1pf-log1pl2?view=msvc-170

It also confused people at URLO: https://users.rust-lang.org/t/64-bit-trigonometry/98599/27
2023-08-21 10:45:47 -07:00
Bruce Mitchener
53245709f6 docs: Add example, reference link for type keyword.
Fixes #114281.
2023-08-21 20:00:43 +07:00
ShE3py
f8a2f31ae4
Add data race test to std::env::{get, set} 2023-08-20 21:50:45 +02:00
Matthias Krüger
7b66abe5a2
Rollup merge of #114968 - ShE3py:unix-getsetenv-ub, r=thomcc
Fix UB in `std::sys::os::getenv()`

Fixes #114949.

Reduced the loops to 1k iterations (100k was taking way too long), Miri no longer shows any UB.

`@rustbot` label +A-process +C-bug +I-unsound +O-unix
2023-08-20 08:34:03 +02:00
bors
9c699a40cc Auto merge of #113167 - ChAoSUnItY:redundant_explicit_link, r=GuillaumeGomez
rustdoc: Add lint `redundant_explicit_links`

Closes #87799.
- Lint warns by default
- Reworks link parser to cache original link's display text

r? `@jyn514`
2023-08-20 01:04:22 +00:00
Matthias Krüger
d761a5fe11
Rollup merge of #114983 - crlf0710:formatmsg, r=ChrisDenton
Usage zero as language id for `FormatMessageW()`

This switches the language selection from using system language (note that this might be different than application language, typically stored as thread ui language) to use `FormatMessageW` default search strategy, which is `neutral` first, then `thread ui lang`, then `user language`, then `system language`, then `English`. (See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagew)

This allows the Rust program to take more control of `std::io::Error`'s message field, by setting up thread ui language themselves before hand (which many programs already do).
2023-08-20 00:28:32 +02:00
Matthias Krüger
cbcdf7580b
Rollup merge of #114973 - shepmaster:std-provide-value, r=Amanieu
Expose core::error::request_value in std

I think this was simply forgotten in #113464.

/cc ``@waynr``

r? ``@Amanieu``
2023-08-20 00:28:32 +02:00
Matthias Krüger
0cc4b55a12
Rollup merge of #114605 - Easyoakland:hash-collection-doc, r=thomcc
Increase clarity about Hash - Eq consistency in HashMap and HashSet docs

As discussed [here](https://users.rust-lang.org/t/what-hapens-if-hash-and-partialeq-dont-match-when-using-hashmap/98052/13) the description of logic errors in `HashMap` and `HashSet` does not explicitly apply to
```text
k1 == k2 -> hash(k1) == hash(k2)
```
but this is likely what is intended.

This PR is a small doc change to correct this.

r? rust-lang/libs
2023-08-20 00:28:31 +02:00
Kevin Reid
3dde25edc4 Correct and expand documentation of handle_alloc_error and set_alloc_error_hook.
Add the following facts:

* `handle_alloc_error` may panic instead of aborting.
* What happens if a hook returns rather than diverging.
* A hook may panic. (This was already demonstrated in an example,
  but not stated in prose.)
* A hook must be sound to call — it cannot assume that it is only
  called by the runtime, since its function pointer can be retrieved by
  safe code.
2023-08-19 13:27:03 -07:00
Charles Lew
4504cc513f Usage zero as language id for FormatMessageW() 2023-08-19 14:32:15 +08:00
Matthias Krüger
8e0a8cdecb
Rollup merge of #114977 - kpreid:modulo, r=thomcc
Add `modulo` and `mod` as doc aliases for `rem_euclid`.

When I was learning Rust I looked for “a modulo function” and couldn’t find one, so thought I had to write my own; it wasn't at all obvious that a function with “rem” in the name was the function I wanted. Hopefully this will save the next learner from that.

However, it does have the disadvantage that the top results in rustdoc for “mod” are now these aliases instead of the Rust keyword, which probably isn't ideal.
2023-08-19 03:27:01 +02:00
Matthias Krüger
8d52b4d2f3
Rollup merge of #114971 - kpreid:trig, r=joshtriplett
Add doc aliases for trigonometry and other f32,f64 methods.

These are common alternate names, usually a less-abbreviated form, for the operation; e.g. `arctan` instead of `atan`. Prompted by <https://users.rust-lang.org/t/64-bit-trigonometry/98599>
2023-08-19 03:27:00 +02:00
Kevin Reid
2c21635382 Add modulo and mod as doc aliases for rem_euclid.
When I was learning Rust I looked for “a modulo function” and couldn’t
find one, so thought I had to write my own; it wasn't at all obvious
that a function with “rem” in the name was the function I wanted.
Hopefully this will save the next learner from that.

However, it does have the disadvantage that the top results in rustdoc
for “mod” are now these aliases instead of the Rust keyword, which
probably isn't ideal.
2023-08-18 12:28:27 -07:00