Commit Graph

5085 Commits

Author SHA1 Message Date
Ralf Jung
53a29e0e60 also print clearing the environment entirely 2023-08-24 08:08:46 +02:00
Ralf Jung
3a28887623 fix a typo in env_clear docs 2023-08-24 08:08:46 +02:00
Ralf Jung
396cbe6639 make unsetting env vars print as executable command 2023-08-24 08:08:46 +02:00
Ralf Jung
f2b139f23d Command: also print removed env vars 2023-08-24 08:08:46 +02: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
Ian Jackson
f6255287f7 std: unix process_unsupported: Provide a wait status emulation (tidy)
Move tests into a module as demanded by tidy.
2023-08-22 20:22:09 +01:00
Ian Jackson
281b0501f6 fixup! std: unix process: Test exit statuses / wait statuses 2023-08-22 19:43:00 +01:00
Ian Jackson
2727f82526 std: unix process_unsupported: Provide a wait status emulation (fmt)
Worsify formatting as required by rustfmt.
2023-08-22 19:02:06 +01:00
Ian Jackson
9738a07f98 fixup! std: unix process_unsupported: Provide a wait status emulation 2023-08-22 19:01:46 +01:00
Ian Jackson
06567ad7fa std: unix process: Test exit statuses / wait statuses
This is a pretty basic test but should spot any other platforms which
are `#[cfg(unix)]` but not Unix and where the wait status
representation is wrong.  (And any actual Unix platforms where it's
not as expected, but I don't think they exist.)
2023-08-22 17:46:59 +01:00
Ian Jackson
013d2d2123 std: unix process_unsupported: Provide a wait status emulation
Fixes #114593

Needs FCP due to behavioural changes.
2023-08-22 17:45:24 +01:00
Patiga
adb22b92dd Improve UdpSocket documentation
I tried working with `UdpSocket` and ran into `EINVAL` errors with no
clear indication of what causes the error. Also, it was uncharacteristically
hard to figure this module out, compared to other Rust `std` modules.

1. `send` and `send_to` return a `usize`
This one is just clarity. Usually, returned `usize`s indicate that the
buffer might have only been sent partially. This is not the case with
UDP. Since that `usize` must always be `buffer.len()`, I have documented
that.

2. `bind` limits `connect` and `send_to`
When you bind to a limited address space like localhost, you can only
`connect` to addresses in that same address space. Error kind:
`AddrNotAvailable`.

3. `connect`ing to localhost locks you to localhost
On Linux, if you first `connect` to localhost, subsequent `connect`s to
non-localhost addresses fail. Error kind: `InvalidInput`.

Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2023-08-22 18:19:49 +02:00
Sean Cross
6c32a64962 std: enable feature(slice_ptr_len) on xous
Xous passes slice pointers around in order to manipulate memory.
This is feature-gated behind `slice_ptr_len`. Xous is currently
the only target to use this feature, so gate it behind an OS flag.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:39 +08:00
Sean Cross
6413844a22 std: xous: add support for locks
Add support for Condvar, Mutex, and RWLock. These are all backed by the
ticktimer server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
46a4ec3a71 std: xous: add thread_local_key
Add an implementation of thread local storage. This uses a container
that is pointed to by the otherwise-unsed `$tp` register. This container
is allocated on-demand, so threads that use no TLS will not allocate
this extra memory.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
d36e516478 std: xous: add thread support
Add initial support for threads on Xous. This includes thread creation
and joining.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
efa470d0ae std: xous: add support for time
Add support for determining the current time. This connects to the
ticktimer server in order to get the system uptime.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
4af7d2cf8d std: xous: add output support for stdio
Add support for stdout. This enables basic console printing via
`println!()`. Output is written to the log server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
10dad67f89 std: xous: add services support
Xous has a concept of `services` that provide various features.
Processes may connect to these services by name or by address. Most
services require a name server in order to connect.

Add a file with the most common services, and provide a way to connect
to a service by querying the name server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
823cba9cc8 std: xous: add alloc support
Basic alloc support on Xous is supported by the `dlmalloc` crate. This
necessitates bumping the dlmalloc version to 0.2.4.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
112d101f88 std: process: skip tests on xous
Xous does not yet support spawning processes.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
0b800577d1 std: fs: skip fs tests on xous
The xous filesystem support is not yet ready for merging.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
778e8038a2 std: net: skip tests on xous
Network functionality is not yet ready for merging.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
9afc1e958b std: xous: the basics of os
Add the basics to get the operating system running, including how to
exit the operating system.

Since Xous has no libc, there is no default entrypoint. Add a `_start`
entrypoint to the system-specific os module.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
7892cfb60e std: xous: add os-specific ffi calls
Xous has no C FFI. Instead, all FFI is done via syscalls that are
specified in Rust. Add these FFI calls to libstd, as well as some of the
currently-supported syscalls.

This enables Rust programs to interact with the Xous operating system
while avoiding adding an extra dependency to libstd.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Mark Rousskov
c8522adb97 Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
Ralf Jung
6d65379e7a clarify what you cannot do 2023-08-22 09:00:07 +02:00
Ralf Jung
2cb9d3def2
typos and wording
Co-authored-by: Dan Gohman <dev@sunfishcode.online>
2023-08-22 08:57:38 +02:00
Sean Cross
61cfb1734a libstd: add xous to libstd
Add the `xous` target to libstd. Currently this defers everything to the
`unsupported` target.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 08:20:04 +08: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
bors
d06ca0ffaf Auto merge of #114591 - joboet:thread_parking_ordering_fix, r=thomcc
Synchronize with all calls to `unpark` in id-based thread parker

[The documentation for `thread::park`](https://doc.rust-lang.org/nightly/std/thread/fn.park.html#memory-ordering) guarantees that "park synchronizes-with all prior unpark operations". In the id-based thread parking implementation, this is not implemented correctly, as the state variable is reset with a simple store, so there will not be a *synchronizes-with* edge if an `unpark` happens just before the reset. This PR corrects this, replacing the load-check-reset sequence with a single `compare_exchange`.
2023-08-18 19:03:38 +00:00
Jake Goulding
74942daf71 Expose core::error::request_value in std
I think this was simply forgotten in #113464.
2023-08-18 13:06:53 -04:00
Kevin Reid
c353dbd57f 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-18 08:08:35 -07:00
ShE3py
83c713bff0
Fix UB in std::sys::os::getenv() 2023-08-18 16:04:53 +02:00
Jorge Aparicio
f58b2548dc QNX: pass a truncated thread name to the OS
The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX`
2023-08-18 14:47:12 +02:00
Ben Schulz
a38ea96825 Remove Drop impl of mpsc Receiver and (Sync)Sender 2023-08-18 14:46:20 +02:00
Kyle Lin
4896fc0f59 resolve conflicts 2023-08-18 15:31:13 +08:00
Kyle Lin
c4afb8a868 resolve conflicts 2023-08-18 15:22:58 +08:00
Kyle Lin
f0b2cca185 lint links 2023-08-18 15:19:23 +08:00
Josh Stone
4f14451d7c
Rollup merge of #114897 - joshtriplett:partial-revert-ok-0, r=m-ou-se
Partially revert #107200

`Ok(0)` is indeed something the caller may interpret as an error, but
that's the *correct* thing to return if the writer can't accept any more
bytes.
2023-08-17 15:40:08 -07:00
Matthias Krüger
f4cd7a537b
Rollup merge of #114749 - gurry:issue-114722, r=thomcc
Update `mpsc::Sender` doc to reflect that it implements `Sync`

Fixes #114722
2023-08-17 08:39:21 +02:00
Josh Triplett
5210f482d7 Partially revert #107200
`Ok(0)` is indeed something the caller may interpret as an error, but
that's the *correct* thing to return if the writer can't accept any more
bytes.
2023-08-16 09:00:16 -07:00
Georgii Rylov
9b00e5f06f address comments 2023-08-16 11:21:06 +01:00
Georgii Rylov
42a708083a Fix a pthread_t handle leak #114610 2023-08-16 11:21:05 +01:00
Matthias Krüger
6f27032118
Rollup merge of #114861 - RalfJung:no-effect, r=wesleywiser
fix typo: affect -> effect

I just realized I made a silly typo when writing that comment...
2023-08-16 08:43:52 +02:00
bors
656ee47db3 Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc
Stabilize thread local cell methods.

Closes #92122.
2023-08-16 02:37:29 +00:00
Matthias Krüger
430e2e6772
Rollup merge of #114619 - g0djan:godjan/fix_#114608, r=m-ou-se
Fix pthread_attr_union layout on Wasi

Fixes https://github.com/rust-lang/rust/issues/114608

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-15 20:34:23 +02:00
Matthias Krüger
0587893f6d
Rollup merge of #114588 - ijackson:exit-status-default-2, r=m-ou-se
Improve docs for impl Default for ExitStatus

This addresses a review comment in #106425 (which is on the way to being merged I think).

Some of the other followup work is more complicated so I'm going to do individual MRs.

~~Note this branch is on top of #106425~~
2023-08-15 20:34:23 +02:00
Ralf Jung
e1e6c002d8 fix typo: affect -> effect 2023-08-15 19:30:09 +02:00
Ian Jackson
a741a5ad16 Document Default for ExitStatus
This lets us put a version on the impl, too.
2023-08-15 15:17:42 +01:00
Guillaume Gomez
f527d56c08
Rollup merge of #114800 - RalfJung:transparent, r=cuviper
std: add some missing repr(transparent)

For some types we don't want to stably guarantee this, so hide the `repr` from rustdoc. This nice approach was suggested by `@thomcc.`
2023-08-15 14:29:46 +02:00
bors
180dffba14 Auto merge of #113658 - Dirreke:csky-unknown-linux-gunabiv2, r=bjorn3
add a csky-unknown-linux-gnuabiv2 target

This is the rustc side changes to support csky based Linux target(`csky-unknown-linux-gnuabiv2`).

Tier 3 policy:

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I pledge to do my best maintaining it.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

This `csky`  section is the arch name and the `unknown-linux` section is the same as other linux target, and `gnuabiv2` is from the  cross-compile toolchain of  `gcc`

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I think the explanation in platform support doc is enough to make this aspect clear.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

It's using open source tools only.

> The target must not introduce license incompatibilities.

No new license

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Understood.

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

There are no new dependencies/features required.

> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

As previously said it's using open source tools only.

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

There are no such terms present/

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

I'm not the reviewer here.

> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

I'm not the reviewer here.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

It supports for std

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

I have added the documentation, and I think it's clear.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Understood.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Understood.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

I believe I didn't break any other target.

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I think there are no such problems in this PR.
2023-08-14 21:53:27 +00:00
Ralf Jung
fe1a034f16 actually this doesn't even affect doctests. nice. 2023-08-14 22:55:29 +02:00
dirreke
74817b7053 Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
Dirreke
d16409fe22 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
Ralf Jung
e9eca7cda4 reference-counting analogy 2023-08-14 16:53:08 +02:00
Ralf Jung
85e6e82f93 reword the paragraph on file description ownership 2023-08-14 13:55:16 +02:00
Ralf Jung
03c28d5626 don't link to RFCs, they are not up-to-date docs 2023-08-14 13:28:51 +02:00
Ralf Jung
f887f5a9c6 std: add some missing repr(transparent) 2023-08-14 10:40:59 +02:00
Ralf Jung
4da0811513 mention /proc/self/fd with /proc/self/mem 2023-08-14 09:16:08 +02:00
Ralf Jung
55f18beddd wording; and explain some of the possible consequences of violating io-safety 2023-08-14 08:59:37 +02:00
Ralf Jung
334a54cd83 typos 2023-08-14 08:50:32 +02:00
Ralf Jung
b2b225e1d1 sync the various FromRawFd trait docs, and remove 'valid' 2023-08-14 08:49:40 +02:00
wayne warren
a646b39965 core/any: remove Provider trait
* remove `impl Provider for Error`
* rename `Demand` to `Request`
* update docstrings to focus on the conceptual API provided by `Request`
* move `core::any::{request_ref, request_value}` functions into `core::error`
* move `core::any::tag`, `core::any::Request`, an `core::any::TaggedOption` into `core::error`
* replace `provide_any` feature name w/ `error_generic_member_access`
* move `core::error::request_{ref,value} tests into core::tests::error module
* update unit and doc tests
2023-08-13 13:07:53 -06:00
Ralf Jung
a473e95786 add more explicit I/O safety documentation 2023-08-13 15:07:57 +02:00
Matthias Krüger
8a997b159c
Rollup merge of #114132 - tamird:better-env-debug-impls, r=Amanieu
Better Debug for Vars and VarsOs

Display actual vars instead of two dots.

The same was done for Args and ArgsOs in 275f9a04af.
2023-08-12 12:06:35 +02:00
Jubilee Young
90dc2f839b Name what ln_gamma does
The previous description omitted some important details.
2023-08-12 02:13:41 -07:00
Jacob Pratt
62ca5aa8e4
Remove unnecessary feature gates 2023-08-12 00:21:04 -04:00
Gurinder Singh
0af9dfc0a3 Update Sender documentation for Sync 2023-08-12 09:20:56 +05:30
bors
08691f0c92 Auto merge of #113432 - klensy:ms-cut-backtrace, r=ChrisDenton
reduce deps for windows-msvc targets for backtrace

(eventually) mirrors https://github.com/rust-lang/backtrace-rs/pull/543

Some dependencies of backtrace don't used on windows-msvc targets, so exclude them:

    miniz_oxide (+ adler)
    addr2line (+ gimli)
    object (+ memchr)

This saves about 30kb of std.dll + 17.5mb of rlibs
2023-08-11 12:07:04 +00:00
Michael Goulet
5da7f36485
Rollup merge of #114359 - ttsugriy:barrier-simpl, r=cuviper
[library/std] Replace condv while loop with `cvar.wait_while`.

`wait_while` takes care of spurious wake-ups in centralized place, reducing chances for mistakes and potential future optimizations (who knows, maybe in future there will be no spurious wake-ups? :)
2023-08-10 21:17:37 -07:00
Michael Goulet
0c241e6bdb
Rollup merge of #114194 - thomcc:flushinline, r=cuviper
Inline trivial (noop) flush calls

At work I noticed that `writer.flush()?` didn't get optimized away in cases where the flush is obviously a no-op, which I had expected (well, desired).

I went through and added `#[inline]` to a bunch of cases that were obviously noops, or delegated to ones that were obviously noops. I omitted platforms I don't have access to (some tier3). I didn't do this very scientifically, in cases where it was non-obvious I left `#[inline]` off.
2023-08-10 21:17:36 -07:00
Mara Bos
dc3cbc1e56 Stabilize thread local cell methods. 2023-08-10 17:33:40 +02:00
bors
19a647d6d8 Auto merge of #114646 - matthiaskrgr:rollup-xf7qnmn, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113939 (open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG)
 - #114548 (Migrate a trait selection error to use diagnostic translation)
 - #114606 (fix: not insert missing lifetime for `ConstParamTy`)
 - #114634 (Mention riscv64-linux-android support in Android documentation)
 - #114638 (Remove old RPITIT tests (revisions were removed))
 - #114641 (Rename copying `ascii::Char` methods from `as_` to `to_`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-09 05:50:12 +00:00
Matthias Krüger
3feab00093
Rollup merge of #113939 - the8472:pidfd-from-child, r=Mark-Simulacrum
open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG

This avoids using `clone3` when a pidfd is requested while still getting it in a 100% race-free manner by passing it up from the child process.
This should solve most concerns in #82971
2023-08-09 06:32:24 +02:00
bors
8838c73e86 Auto merge of #99747 - ankane:float_gamma, r=workingjubilee
Add gamma function to f32 and f64

Adds the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) to `f32` and `f64` (`tgamma` and `tgammaf` from C).

Refs:
- https://github.com/rust-lang/rfcs/issues/864
- https://github.com/rust-lang/rust/issues/18271
2023-08-09 03:14:31 +00:00
The 8472
8d349c1598 open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG
This is a 100% race-free way to obtain a child's pidfd while
avoiding `clone3`.
2023-08-08 22:05:32 +02:00
Matthias Krüger
b3550891e8
Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnay
Make ExitStatus implement Default

And, necessarily, make it inhabited even on platforms without processes.

I noticed while preparing https://github.com/rust-lang/rfcs/pull/3362 that there was no way for anyone to construct an `ExitStatus`.

This would be insta-stable so needs an FCP.
2023-08-08 21:44:41 +02:00
Georgii Rylov
971427e5f1 Fix #114608 2023-08-08 11:07:48 +01:00
Easyoakland
98e434a01e Increase clarity about Hash - Eq consistency in HashMap and HashSet docs 2023-08-07 20:31:49 -06:00
Andrew Kane
a75e2284fb Bump compiler_builtins to 0.1.100 2023-08-07 16:38:09 -07:00
joboet
fd9fcc580a
std: synchronize with all calls to unpark in id-based thread parker 2023-08-07 19:13:34 +02:00
Tamir Duberstein
35c0c03a3c
Better Debug for Vars and VarsOs
Display actual vars instead of two dots.

The same was done for Args and ArgsOs in 275f9a04af.
2023-08-07 12:18:27 -04:00
Ian Jackson
b8f6d48eb6
impl Default for ExitCode
As suggested here
  https://github.com/rust-lang/rust/pull/106425#issuecomment-1382952598
2023-08-07 16:08:19 +01:00
Ian Jackson
c4bc16c5d6 Adjust the duration_since(UNIX_EPOCH) docs
* Make the description primary, not the definition in terms of time_t
 * Remove the list of Internet protocols

As per
  https://github.com/rust-lang/rust/pull/109660#pullrequestreview-1414613118
2023-08-07 15:45:47 +01:00
Ian Jackson
1f1d49a2b7 impl Default for ExitStatus 2023-08-07 15:24:55 +01:00
Ian Jackson
36295fad12 std::process: impl From<io::Stdout> (etc.) for Stdio
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07 15:18:58 +01:00
Ian Jackson
1bab95bf7f std::process (windows): Implement From<io::Stdout> etc. for imp::Stdio
This involves a new variant `imp;::Stdio::InheritSpecific`.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07 15:18:58 +01:00
Ian Jackson
deda7d3301 std::process (windows): refactor Stdio::to_handle slightly
We're going to want to reuse this bit of code.
2023-08-07 15:18:58 +01:00
Ian Jackson
fb7f1a8127 std::process (unix): Implement From<io::Stdout> etc. for imp::Stdio
This involves adding a new variant `imp::Stdio::StaticFd`.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07 15:18:58 +01:00
The 8472
20c25d6c31 use offset_of! to calculate dirent64 field offsets 2023-08-05 15:53:09 +02:00
David CARLIER
c3116c5045 std/tests: disable ancillary tests on freebsd since the feature itself is. 2023-08-05 12:19:15 +01:00
Matthias Krüger
539fecb882
Rollup merge of #114373 - xstaticxgpx:dev, r=the8472
unix/kernel_copy.rs: copy_file_range_candidate allows empty output files

This is for https://github.com/rust-lang/rust/issues/114341

The `meta.len() > 0` condition here is intended for inputs only, ie. when input is in the `/proc` filesystem as documented.

That inaccurately included empty output files which are then shunted to the sendfile() routine leading to higher than nescessary IO util in some cases, specifically with CoW filesystems like btrfs.

Simply, determine what is input or output given the passed boolean.
2023-08-04 07:25:46 +02:00
xstaticxgpx
2232fe8da3 unix/kernel_copy.rs: copy_file_range_candidate allows empty output files
This is for https://github.com/rust-lang/rust/issues/114341

The `meta.len() > 0` condition here is intended for inputs only,
ie. when input is in the `/proc` filesystem as documented.

That inaccurately included empty output files which are then shunted to
the sendfile() routine leading to higher than nescessary IO util in some
cases, specifically with CoW filesystems like btrfs.

Further, `NoneObtained` is not relevant in this context, so remove it.

Simply, determine what is input or output given the passed enum Unit.
2023-08-03 19:27:45 -04:00
Chai T. Rex
6acb415e7c Convert Into<ExitStatus> for ExitStatusError to From<ExitStatusError> for ExitStatus in std::process 2023-08-03 13:25:52 -04:00
Nilstrieb
5830ca216d Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
Taras Tsugrii
a090e97f68 [library/std] Replace condv while loop with cvar.wait_while.
`wait_while` takes care of spurious wake-ups in centralized place,
reducing chances for mistakes and potential future optimizations
(who knows, maybe in future there will be no spurious wake-ups? :)
2023-08-01 22:10:40 -07:00
bors
aa8462b6df Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser
WASI threads, implementation of wasm32-wasi-preview1-threads target

This PR adds a target proposed in https://github.com/rust-lang/compiler-team/issues/574 by `@abrown` and implementation of `std:🧵:spawn` for the target `wasm32-wasi-preview1-threads`

### Tier 3 Target Policy
As tier 3 targets, the new targets are required to adhere to [the tier 3 target policy](https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-3-target-policy) requirements. This section quotes each requirement in entirety and describes how they are met.
> - A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

See [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
> - Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

The target is using the same name for $ARCH=wasm32 and $OS=wasi as existing Rust targets. The suffix `preview1` introduced to accurately set expectations because eventually this target will be deprecated and follows [MCP 607](https://github.com/rust-lang/compiler-team/issues/607). The suffix `threads` indicates that it’s an extension that enables threads to the existing target and it follows [MCP 574](https://github.com/rust-lang/compiler-team/issues/574) which describes the rationale behind introducing a separate target.

> - Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
> - The target must not introduce license incompatibilities.
> - Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
> - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
> - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
> - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

This PR does not introduce any new dependency.
The new target doesn’t support building host tools.
> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

The full standard library is available for this target as it’s an extension to an existing target that has already supported it.
> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Only manual test running is supported at the moment with some tweaks in the test runner codebase. For build and running tests see [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
> - This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.
> - Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
> - Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.
> - Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
> - In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I acknowledge these requirements and intend to ensure they are met.
2023-08-02 01:01:48 +00:00
bors
4896daa398 Auto merge of #114331 - matthiaskrgr:rollup-rnrmwcx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #100455 (Implement RefUnwindSafe for Backtrace)
 - #113428 (coverage: Replace `ExpressionOperandId` with enum `Operand`)
 - #114283 (Use parking lot's rwlock even without parallel-rustc)
 - #114288 (Improve diagnostic for wrong borrow on binary operations)
 - #114296 (interpret: fix alignment handling for Repeat expressions)
 - #114306 ([rustc_data_structures][perf] Simplify base_n::push_str.)
 - #114320 (Cover statements for stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-01 16:09:13 +00:00
Matthias Krüger
c97af34de1
Rollup merge of #100455 - xfix:backtrace-ref-unwind-safe, r=dtolnay
Implement RefUnwindSafe for Backtrace

Backtrace doesn't have visible mutable state.

See also https://internals.rust-lang.org/t/should-backtrace-be-refunwindsafe/17169?u=xfix
2023-08-01 17:39:09 +02:00
bors
828bdc2c26 Auto merge of #112849 - m-ou-se:panic-message-format, r=thomcc
Change default panic handler message format.

This changes the default panic hook's message format from:

```
thread '{thread}' panicked at '{message}', {location}
```

to

```
thread '{thread}' panicked at {location}:
{message}
```

This puts the message on its own line without surrounding quotes, making it easiser to read. For example:

Before:
```
thread 'main' panicked at 'env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`', src/main.rs:4:6
```
After:
```
thread 'main' panicked at src/main.rs:4:6:
env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`
```

---

See this PR by `@nyurik,` which does that for only multi-line messages (specifically because of `assert_eq`): https://github.com/rust-lang/rust/pull/111071

This is the change that does that for *all* panic messages.
2023-08-01 14:15:09 +00:00
Raoul Strackx
9baab45e2f Aborting when before_wait function panics 2023-08-01 10:23:32 +02:00
bors
706a4d9a4e Auto merge of #114308 - matthiaskrgr:rollup-m64bkm7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109318 (Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock`)
 - #113701 (Re-export core::ffi::FromBytesUntilNulError in std::ffi)
 - #113804 (Resolve correct archive version name in `opt-dist`)
 - #114165 (Add missing rvalues to smir)
 - #114182 (clean up after 113312)
 - #114193 (Update lexer emoji diagnostics to Unicode 15.0)
 - #114200 (Detect trait upcasting through struct tail unsizing in new solver select)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-31 23:30:28 +00:00
Matthias Krüger
efd68db768
Rollup merge of #113701 - aswild:std-ffi-frombytesuntilnul, r=dtolnay
Re-export core::ffi::FromBytesUntilNulError in std::ffi

Like the other CStr and CString error types, make a re-export for std::ffi::FromBytesUntilNulError.

This seems to have slipped through the cracks in the cstr_from_bytes_until_nul implementation and core_c_str migration.

Tracking Issue: #95027
2023-07-31 22:51:13 +02:00
Matthias Krüger
bcfa49f162
Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnay
Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock`

`Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-07-31 22:51:12 +02:00
Matthias Krüger
d0ae0b31a8
Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-Simulacrum
Update Android system definitions and add riscv-linux-android as tier 3 target

This PR includes the following:
* Corrected Android system definitions for some types
* Support for the riscv64-linux-android target

The authoritative types for the system definitions can be found here: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/stat.h

Fixes rust-lang/compiler-team#640
2023-07-31 22:49:46 +02:00
Andrew Kane
fcecaff16e Add gamma and ln_gamma functions to f32 and f64 2023-07-31 07:41:50 -07:00
Jethro Beekman
905f49a728 Clean up SGX user memory copies 2023-07-31 13:21:11 +02:00
Raoul Strackx
9a5443fe21 waitqueue clarifications for SGX platform 2023-07-31 12:59:42 +02:00
Konrad Borowski
0f06b07552 Implement UnwindSafe and RefUnwindSafe for Backtrace
Backtrace doesn't have visible mutable state.
2023-07-31 10:38:24 +02:00
Jubilee
495e6577c8
Rollup merge of #114268 - SUPERCILEX:empty, r=workingjubilee
Fix empty_write since rust version attribute

Fixup of https://github.com/rust-lang/rust/pull/98154 for the rust version.

r? ``@workingjubilee``
2023-07-30 17:50:49 -07:00
Jubilee
0ad8d6adc5
Rollup merge of #109075 - joboet:lazylock_backtrace, r=workingjubilee
Use `LazyLock` to lazily resolve backtraces

By using TAIT to name the initializing closure, `LazyLock` can be used to replace the current `LazilyResolvedCapture`.
2023-07-30 17:50:47 -07:00
bors
d4145eeef4 Auto merge of #112843 - chenyukang:yukang-more-on-backtrace, r=workingjubilee
Print omitted frames count for short backtrace mode

Fixes #111730
2023-07-30 22:31:52 +00:00
Alex Saveau
0b4a80f417
Fix empty_write since rust version attribute 2023-07-30 22:53:32 +01:00
Matthias Krüger
27e3a740ae
Rollup merge of #98154 - vidhanio:master, r=workingjubilee
merge functionality of `io::Sink` into `io::Empty`

Many times, there is a need for a simple dummy `io::Read`er + `io::Write`r, but currently the only options are `io::Empty` and `io::Sink` respectively. Having both of their functionality together requires writing your own boilerplate for something that makes sense to have in the standard library. This PR adds the functionality of `io::Sink` to `io::Empty`, making `io::Empty` be able to perform the tasks of both of the previous structs. (This idea was first mentioned in #24235)

Note: I also updated some doc comments in `io::utils` in this pull request to fix inconsistencies between `io::Sink` and `io::Empty`.

API Change Proposal: https://github.com/rust-lang/libs-team/issues/49
2023-07-30 20:36:33 +02:00
David Carlier
4b73cf3446 rand use getrandom for freebsd (available since 12.x) 2023-07-30 10:32:35 +01:00
yukang
d67d9890ae Fix the example in document for WaitTimeoutResult::timed_out 2023-07-30 16:39:33 +08:00
Georgii Rylov
5697f1620d Add wasm32-wasi-threads target + WASI threads 2023-07-29 16:37:50 +01:00
yukang
90db98d074 print omitted frames count for short backtrace mode 2023-07-29 20:36:05 +08:00
Mara Bos
0e729404da Change default panic handler message format. 2023-07-29 11:42:50 +02:00
Matthias Krüger
68dc159241
Rollup merge of #114172 - fortanix:raoul/fix_process-spawning_test, r=workingjubilee
Fix issue_15149 test for the SGX target

PR https://github.com/rust-lang/rust/pull/112390 moved tests to std. Unfortunately, this caused the `issue_15149` test to be enabled for the SGX target. This is incorrect as the SGX target does not support the `env::current_exe()` call.
2023-07-29 06:13:07 +02:00
Matthias Krüger
5df97c6bb9
Rollup merge of #114171 - fortanix:raoul/fix_switch-stdout_test, r=workingjubilee
Fix switch-stdout test for none unix/windows platforms

PR #112390 moved tests to std. Unfortunately, there is a typo which causes issues on platforms other than unix and windows.
2023-07-29 06:13:06 +02:00
Thom Chiovoloni
558f49d7aa
inline trivial (noop) flush calls 2023-07-28 18:09:12 -07:00
Matthias Krüger
02f1e2ada7
Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwco
When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist

Fix #113881.
2023-07-28 19:51:15 +02:00
Raoul Strackx
8548689af2 Fix issue_15149 test for the SGX target 2023-07-28 14:48:06 +02:00
Raoul Strackx
9454916c84 Fix switch-stdout test for none unix/windows platforms 2023-07-28 13:54:07 +02:00
klensy
6203cda583 reduce deps for windows-msvc targets for backtrace 2023-07-28 14:26:39 +03:00
bors
e40e22be55 Auto merge of #112390 - MoskalykA:move-two-tests-from-library-to-tests, r=workingjubilee
Move two tests from `tests/ui/std` to `library/std/tests`

Hi, there,
This pull request comes from this issue (#99417), sorry I made some mistakes creating the pull request, it's my first one.
2023-07-28 05:00:22 +00:00
Esteban Küber
656213cc83 When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist
Fix #113881.
2023-07-27 14:06:27 +00:00
Matthias Krüger
26d791b351
Rollup merge of #101994 - devnexen:rand_fbsd_update, r=workingjubilee
rand: freebsd update, using getrandom.

supported since the 12th release, while 11.4 is EOL since 2021.
2023-07-26 20:49:11 +02:00
Chris Wailes
0081d64e4b Add definitions for riscv64_linux_android target 2023-07-26 11:46:48 -07:00
MoskalykA
48e7f3e313 Have a better file name than just the issue id 2023-07-26 15:07:57 +02:00
joboet
29e3f8b793
std: add auto traits to TAIT bound 2023-07-26 12:30:52 +02:00
bors
a6236fa460 Auto merge of #102757 - pcc:android-std-tests, r=workingjubilee
Make std tests pass on newer Android

Newer versions of Android forbid the creation of hardlinks as well as Unix domain sockets in the /data filesystem via SELinux rules, which causes several tests depending on this behavior to fail. So let's skip these tests on Android if we see an EACCES from one of these syscalls. To achieve this, introduce a macro with the horrible name of or_panic_or_skip_on_android_eacces (better suggestions welcome) which skips (returns from) the test if an EACCES return value is seen on Android.
2023-07-26 07:57:32 +00:00
bors
98db99f5f6 Auto merge of #113928 - nicholasbishop:bishop-update-cb-4, r=workingjubilee
Bump compiler_builtins to 0.1.98

Change list: https://github.com/rust-lang/compiler-builtins/compare/0.1.95...0.1.98
2023-07-26 02:50:58 +00:00
Matthias Krüger
91d1d7aa44
Rollup merge of #114043 - cathaysia:doc_lazy_lock, r=thomcc
docs(LazyLock): add example pass local LazyLock variable to struct
2023-07-25 19:21:37 +02:00
bors
ff8fe76c0e Auto merge of #112646 - vn971:document-thread-names-for-sgx-target, r=m-ou-se
Document thread names for SGX compilation target

`@raoulstrackx` `@Mkaynov` `@jethrogb`
2023-07-25 09:14:11 +00:00
DragonBillow
40dd5a337c
docs(LazyLock): add example pass local LazyLock variable to struct
Signed-off-by: DragonBillow <DragonBillow@outlook.com>
2023-07-25 12:21:30 +08:00
bors
d24c4da1d6 Auto merge of #113411 - unikraft:unikraft, r=wesleywiser
Add `x86_64-unikraft-linux-musl` target

This introduces `x86_64-unikraft-linux-musl` as the first Rust target for the [Unikraft] Unikernel Development Kit.

[Unikraft]: https://unikraft.org/

Unikraft imitates Linux and uses musl as libc.
It is extremely configurable, and does not even provide a `poll` implementation or a network stack, unless enabled by the end user who compiles the application.

Our approach for integrating the build process with `rustc` is to hide the build process as well as the actual final linking step behind a linker-shim (`kraftld`, see https://github.com/unikraft/kraftkit/issues/612).

## Tier 3 target policy

> - A tier 3 target must have a designated developer or developers (the "target
>   maintainers") on record to be CCed when issues arise regarding the target.
>   (The mechanism to track and CC such developers may evolve over time.)

I will be the target maintainer.

> - Targets must use naming consistent with any existing targets; for instance, a
>   target for the same CPU or OS as an existing Rust target should use the same
>   name for that CPU or OS. Targets should normally use the same names and
>   naming conventions as used elsewhere in the broader ecosystem beyond Rust
>   (such as in other toolchains), unless they have a very good reason to
>   diverge. Changing the name of a target can be highly disruptive, especially
>   once the target reaches a higher tier, so getting the name right is important
>   even for a tier 3 target.
>   - Target names should not introduce undue confusion or ambiguity unless
>     absolutely necessary to maintain ecosystem compatibility. For example, if
>     the name of the target makes people extremely likely to form incorrect
>     beliefs about what it targets, the name should be changed or augmented to
>     disambiguate it.
>   - If possible, use only letters, numbers, dashes and underscores for the name.
>     Periods (`.`) are known to cause issues in Cargo.

The target name `x86_64-unikraft-linux-musl` was derived from `x86_64-unknown-linux-musl`, setting Unikraft as vendor.
Unikraft exactly imitates Linux + musl.

> - Tier 3 targets may have unusual requirements to build or use, but must not
>   create legal issues or impose onerous legal terms for the Rust project or for
>   Rust developers or users.
>   - The target must not introduce license incompatibilities.
>   - Anything added to the Rust repository must be under the standard Rust
>     license (`MIT OR Apache-2.0`).
>   - The target must not cause the Rust tools or libraries built for any other
>     host (even when supporting cross-compilation to the target) to depend
>     on any new dependency less permissive than the Rust licensing policy. This
>     applies whether the dependency is a Rust crate that would require adding
>     new license exceptions (as specified by the `tidy` tool in the
>     rust-lang/rust repository), or whether the dependency is a native library
>     or binary. In other words, the introduction of the target must not cause a
>     user installing or running a version of Rust or the Rust tools to be
>     subject to any new license requirements.
>   - Compiling, linking, and emitting functional binaries, libraries, or other
>     code for the target (whether hosted on the target itself or cross-compiling
>     from another target) must not depend on proprietary (non-FOSS) libraries.
>     Host tools built for the target itself may depend on the ordinary runtime
>     libraries supplied by the platform and commonly used by other applications
>     built for the target, but those libraries must not be required for code
>     generation for the target; cross-compilation to the target must not require
>     such libraries at all. For instance, `rustc` built for the target may
>     depend on a common proprietary C runtime library or console output library,
>     but must not depend on a proprietary code generation library or code
>     optimization library. Rust's license permits such combinations, but the
>     Rust project has no interest in maintaining such combinations within the
>     scope of Rust itself, even at tier 3.
>   - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
>     legal/licensing terms include but are *not* limited to: non-disclosure
>     requirements, non-compete requirements, contributor license agreements
>     (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
>     requirements conditional on the employer or employment of any particular
>     Rust developers, revocable terms, any requirements that create liability
>     for the Rust project or its developers or users, or any requirements that
>     adversely affect the livelihood or prospects of the Rust project or its
>     developers or users.

No dependencies were added to Rust.
Requirements for linking are [Unikraft] and [KraftKit] (both BSD-3-Clause), but none of these are added to Rust.

[KraftKit]: https://github.com/unikraft/kraftkit

> - Neither this policy nor any decisions made regarding targets shall create any
>   binding agreement or estoppel by any party. If any member of an approving
>   Rust team serves as one of the maintainers of a target, or has any legal or
>   employment requirement (explicit or implicit) that might affect their
>   decisions regarding a target, they must recuse themselves from any approval
>   decisions regarding the target's tier status, though they may otherwise
>   participate in discussions.
>   - This requirement does not prevent part or all of this policy from being
>     cited in an explicit contract or work agreement (e.g. to implement or
>     maintain support for a target). This requirement exists to ensure that a
>     developer or team responsible for reviewing and approving a target does not
>     face any legal threats or obligations that would prevent them from freely
>     exercising their judgment in such approval, even if such judgment involves
>     subjective matters or goes beyond the letter of these requirements.

Understood.
I am not a member of a Rust team.

> - Tier 3 targets should attempt to implement as much of the standard libraries
>   as possible and appropriate (`core` for most targets, `alloc` for targets
>   that can support dynamic memory allocation, `std` for targets with an
>   operating system or equivalent layer of system-provided functionality), but
>   may leave some code unimplemented (either unavailable or stubbed out as
>   appropriate), whether because the target makes it impossible to implement or
>   challenging to implement. The authors of pull requests are not obligated to
>   avoid calling any portions of the standard library on the basis of a tier 3
>   target not implementing those portions.

Understood.
`std` is supported.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target, using cross-compilation if possible. If the target
>   supports running binaries, or running tests (even if they do not pass), the
>   documentation must explain how to run such binaries or tests for the target,
>   using emulation if possible or dedicated hardware if necessary.

Building is described in the platform support doc.
It will be updated once proper `kraftld` support has landed.

> - Tier 3 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to maintain the target. In particular,
>   do not post comments (automated or manual) on a PR that derail or suggest a
>   block on the PR based on a tier 3 target. Do not send automated messages or
>   notifications (via any medium, including via ``@`)` to a PR author or others
>   involved with a PR regarding a tier 3 target, unless they have opted into
>   such messages.
>   - Backlinks such as those generated by the issue/PR tracker when linking to
>     an issue or PR are not considered a violation of this policy, within
>     reason. However, such messages (even on a separate repository) must not
>     generate notifications to anyone involved with a PR who has not requested
>     such notifications.

Understood.

> - Patches adding or updating tier 3 targets must not break any existing tier 2
>   or tier 1 target, and must not knowingly break another tier 3 target without
>   approval of either the compiler team or the maintainers of the other tier 3
>   target.
>   - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

I don't think this PR breaks anything.

r? compiler-team
2023-07-25 03:41:56 +00:00
James Dietz
db4a153440 remove additional [allow(unused_unsafe)] 2023-07-24 17:56:38 -04:00
James Dietz
fe0ef9a689 delete [allow(...)] from issue #74838 2023-07-24 16:32:32 -04:00
Martin Kröning
553804754a
unix::init: Don't use signal on Unikraft.
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:25:30 +02:00
Martin Kröning
7485e9c965
unix::init: Handle ENOSYS from poll on Unikraft.
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:25:30 +02:00
Matthias Krüger
746d507c72
Rollup merge of #113876 - darklyspaced:master, r=cuviper
fix docs & example for `std::os::unix::prelude::FileExt::write_at`

 Changelog:
 * used `File::create` instead of `File::read` to get a writeable file
 * explicity mentioned the bug with `pwrite64` in docs

Unfortunately, I don't think that there is really much we can do about this since the feature has already been stabilised.

We could potentially add a clippy lint warning people on Linux that using `write_at` with the `O_APPEND` flag does not exhibit the behaviour that they would have assumed.

fixes #113627
2023-07-22 11:48:54 +02:00
Matthias Krüger
0877d11e8d
Rollup merge of #113442 - epage:osstring, r=cuviper
Allow limited access to `OsString` bytes

This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.
2023-07-22 11:48:53 +02:00
Matthias Krüger
6003d6b60b
Rollup merge of #112490 - Alexendoo:c-char-cfg-all, r=cuviper
Remove `#[cfg(all())]` workarounds from `c_char`

Casts to type aliases are now ignored by Clippy https://github.com/rust-lang/rust-clippy/pull/8596

Closes https://github.com/rust-lang/rust-clippy/issues/8093
2023-07-22 11:48:52 +02:00
bors
e0922fba67 Auto merge of #113033 - JohnTitor:stabilize-unix-chown, r=cuviper
Stabilize chown functions (`unix_chown`)

Closes #88989
FCP is complete here: https://github.com/rust-lang/rust/issues/88989#issuecomment-1561125635
2023-07-22 07:27:01 +00:00
Nicholas Bishop
8d5d2fea96 Bump compiler_builtins to 0.1.98 2023-07-21 13:03:58 -04:00
bors
78f97c9b25 Auto merge of #113911 - matthiaskrgr:rollup-wk6cr7v, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #113380 (style-guide: clean up "must"/"should"/"may")
 - #113723 (Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics.)
 - #113780 (Support `--print KIND=PATH` command line syntax)
 - #113810 (Make {Rc,Arc}::allocator associated functions)
 - #113907 (Minor improvements to Windows TLS dtors)

Failed merges:

 - #113392 (style-guide: Some cleanups from the fmt-rfcs repo history)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-21 05:36:01 +00:00
bors
1a44b45987 Auto merge of #113106 - marcospb19:improve-path-with-extension-function, r=thomcc
std: remove an allocation in `Path::with_extension`

`Path::with_extension` used to reallocate (and copy) paths twice per call, now it does it once, by checking the size of the previous and new extensions it's possible to call `PathBuf::with_capacity` and pass the exact capacity required.

This also reduces the memory consumption of the path returned from `Path::with_extension` by using exact capacity instead of using amortized exponential growth.
2023-07-21 03:47:29 +00:00
Chris Denton
40e116489f
Minor improvements to Windows TLS dtors 2023-07-20 23:27:24 +01:00
bors
6b53175b5d Auto merge of #113861 - ibraheemdev:mpsc-tls-bug, r=Mark-Simulacrum
Avoid tls access while iterating through mpsc thread entries

Upstream fix: https://github.com/crossbeam-rs/crossbeam/pull/802. Possibly fixes https://github.com/rust-lang/rust/issues/113726.
2023-07-20 12:30:12 +00:00
darklyspaced
7d17a263d1
added a problematic example 2023-07-20 14:25:50 +08:00
Matthias Krüger
538dcdad31
Rollup merge of #113787 - sanchopanca:process-command-windows-docs, r=ChrisDenton
Update documentation for std::process::Command's new method

In the current documentation, it's not specified that when creating a Command, the .exe extension can be omitted for Windows executables. However, for other types of executable files like .bat or .cmd, the complete filename including the extension must be provided.

I encountered it by noticing that `Command::new("wt").spawn().unwrap()` succeeds on my machine while `Command::new("code").spawn().unwrap()` panics. Turns out VS Code's entrypoint is .cmd file.

`resolve_exe` method mentions this behaviour in [a comment](e7fda447e7/library/std/src/sys/windows/process.rs (L425)), but it makes sense to mention it at a more visible place.

I've added this clarification to the documentation, which should make it more accurate and helpful for Rust developers working on the Windows platform.
2023-07-20 07:08:42 +02:00
darklyspaced
e7dc177442
fix docs & example for FileExt::write_at 2023-07-20 11:27:13 +08:00
Ibraheem Ahmed
fb31a1ac21 avoid tls access while iterating through mpsc thread entries 2023-07-19 11:50:29 -04:00
Esteban Küber
8eb5843a59 On nightly, dump ICE backtraces to disk
Implement rust-lang/compiler-team#578.

When an ICE is encountered on nightly releases, the new rustc panic
handler will also write the contents of the backtrace to disk. If any
`delay_span_bug`s are encountered, their backtrace is also added to the
file. The platform and rustc version will also be collected.
2023-07-19 14:10:07 +00:00
chenx97
d3727148a0 support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00
chenx97
c6e03cd951 support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
Aleksandr Kovalev
5dea766dc9 Update documentation for std::process::Command's new method
In the current documentation, it's not specified that when creating
a Command, the .exe extension can be omitted for Windows executables.
However, for other types of executable files like .bat or .cmd,
the complete filename including the extension must be provided.

I encountered it by noticing that `Command::new("wt").spawn().unwrap()`
succeeds on my machine while `Command::new("code").spawn().unwrap()`
panics. Turns out VS Code's entrypoint is .cmd file.

`resolve_exe` method mentions this behaviour in a comment[1], but it
makes sense to mention it at more visible place.

I've added this clarification to the documentation, which should
make it more accurate and helpful for Rust developers
working on the Windows platform.

[1] e7fda447e7/library/std/src/sys/windows/process.rs (L425)
2023-07-18 11:32:04 +02:00
dvdsk
4cf66f0b09
adds crate attribute to examples so they compile 2023-07-16 23:35:38 +02:00
dvdsk
bd70b639fd
fix examples add tracking issue 2023-07-16 12:16:04 +02:00
dvdsk
77844f015f
fixes sleep_until examples 2023-07-16 11:58:00 +02:00
dvdsk
4854fc9646
Adds thread::sleep_until, tracking issue TODO
APC (API change proposal): https://github.com/rust-lang/libs-team/issues/237
2023-07-15 22:08:38 +02:00
João M. Bezerra
6ffca76e9b std: add tests for Path::with_extension 2023-07-14 13:19:45 -03:00
Allen Wild
fda3d2abaa Re-export core::ffi::FromBytesUntilNulError in std::ffi
Like the other CStr and CString error types, make a re-export for
std::ffi::FromBytesUntilNulError.

This seems to have slipped through the cracks in the
cstr_from_bytes_until_nul implementation and core_c_str migration.

Tracking Issue: #95027
2023-07-14 11:08:57 -04:00
Matthias Krüger
8d1dd7e67b
Rollup merge of #113618 - tshepang:patch-1, r=jyn514
update ancient note
2023-07-14 01:03:08 +02:00
Matthias Krüger
efc3c71c16
Rollup merge of #112525 - hermitcore:devel, r=m-ou-se
Adjustments for RustyHermit

The interface between `libstd` and the OS changed and some changes are not correctly merged for RustHermit. For instance, the crate `hermit_abi` isn't defined as public, although it provided the socket interface for the application.

In addition, the support of thread::available_parallelism is realized. It returns the number of available processors.
2023-07-14 01:03:07 +02:00
Mark Rousskov
0d93d787ba Replace version placeholder to 1.72 2023-07-12 21:24:05 -04:00
Tshepang Mbambo
df3f45dbc5
avoid ambiguous word
See https://github.com/rust-lang/rust/pull/113618#pullrequestreview-1526295432
2023-07-12 20:10:52 +02:00
Stefan Lankes
8666adeb61 use latest version of hermit-abi
0.3.0 and 0.3.1 have an issue and will be yanked. Consequently, std
should switch to 0.3.2.
2023-07-12 13:15:09 +02:00
Stefan Lankes
e1777f9690 fix usage of Timespec om the target hermit 2023-07-12 13:14:00 +02:00
Stefan Lankes
50c7344eaf define hermit_abi as public depedenceny
It's exported publicly, so it should not be linted.
2023-07-12 13:14:00 +02:00
Stefan Lankes
5842a3fe08 add support of available_parallelism for target hermit
On RustyHermit, the function `get_processor_count` returns the
number of activated processors.
2023-07-12 13:14:00 +02:00
Tshepang Mbambo
5710fca279
update ancient note 2023-07-12 12:23:40 +02:00
bors
48a814deab Auto merge of #103754 - SUPERCILEX:filled-mut, r=m-ou-se
Add back BorrowedBuf::filled_mut

This is useful if you want to do some processing on the bytes while still using the BorrowedBuf.

The API was removed in https://github.com/rust-lang/rust/pull/97015 with no explanation. The RFC also has it as part of its API, so this just seems like a mistake: [RFC](https://rust-lang.github.io/rfcs/2930-read-buf.html#:~:text=inline%5D%0A%20%20%20%20pub%20fn-,filled_mut,-(%26mut%20self))

ACP: https://github.com/rust-lang/libs-team/issues/139
2023-07-11 19:07:11 +00:00
Chris Wailes
dfcd3226ba Correct the Android stat struct definitions
See https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/stat.h
for reference.
2023-07-10 15:13:25 -07:00
bors
05b82e551e Auto merge of #94748 - tbu-:pr_file_arc, r=Amanieu
Add `Read`, `Write` and `Seek` impls for `Arc<File>` where appropriate

If `&T` implements these traits, `Arc<T>` has no reason not to do so
either. This is useful for operating system handles like `File` or
`TcpStream` which don't need a mutable reference to implement these
traits.

CC #53835.
CC #94744.
2023-07-10 13:26:42 +00:00
bors
743333f3dd Auto merge of #108796 - devsnek:personality-pal-exception, r=workingjubilee
move personality to sys

this moves `personality` to sys, removing another PAL exception
2023-07-10 05:19:37 +00:00
Gus Caplan
90e11a2a58 move personality to sys 2023-07-09 22:11:21 -07:00
bors
71f71a5397 Auto merge of #108485 - devsnek:float-pat-exception, r=workingjubilee
move pal cfgs in f32 and f64 to sys

I'd like to push forward on `sys` being a separate crate. To start with, most of these PAL exception cases are very simple little bits of code like this, so I thought I would try tidying them up.
2023-07-10 02:50:53 +00:00
Gus Caplan
45b516c844 move pal cfgs in f32 and f64 to sys 2023-07-09 17:32:26 -07:00
The 8472
6f8ba511fa additional io::copy specializations
- copying from `&[u8]` and `VecDeque<u8>`
- copying to `Vec<u8>`
2023-07-09 00:05:56 +02:00
Ed Page
ee604fccd9 Allow limited access to OsString bytes
This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString`
as suggested in feedback from `os_str_bytes` crate in #111544.
2023-07-07 09:46:48 -05:00
Michael Goulet
75febc6ed6
Rollup merge of #112008 - intruder-kat:master, r=Nilstrieb
Fix incorrect documented default bufsize in bufreader/writer
2023-07-06 20:11:38 -07:00
bors
85bf07972a Auto merge of #113269 - jyn514:update-compiler-builtins, r=Amanieu
Update compiler builtins

cc https://github.com/rust-lang/compiler-builtins/pull/532#discussion_r1249354225

in particular this pulls in https://github.com/rust-lang/compiler-builtins/pull/532 and https://github.com/rust-lang/compiler-builtins/pull/535.

Fixes https://github.com/rust-lang/rust/issues/93166. Fixes https://github.com/rust-lang/git2-rs/issues/706. Fixes https://github.com/rust-lang/rust/issues/109064. Fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/74.
2023-07-06 18:58:54 +00:00
fee1-dead
1830b80c2d
Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errors
Revert the lexing of `c"…"` string literals

Fixes \[after beta-backport\] #113235.
Further progress is tracked in #113333.

This PR *manually* reverts parts of #108801 (since a git-revert would've been too coarse-grained & messy)
and git-reverts #111647.

CC `@fee1-dead` (#108801) `@klensy` (#111647)
r? `@compiler-errors`

`@rustbot` label F-c_str_literals beta-nominated
2023-07-06 09:20:33 +08:00
jyn
fd7f53112a Update compiler-builtins to 0.1.95
This pulls in the new `outline-atomics` intrinsics.
2023-07-05 10:41:41 -05:00
León Orell Valerian Liehr
9dbe67fc8c
Revert "use c literals in library"
This reverts commit f212ba6d6d.
2023-07-05 13:11:26 +02:00
León Orell Valerian Liehr
5b25f9d8bd
Revert "fix ptr cast"
This reverts commit 2f459f7f14.
2023-07-05 13:11:26 +02:00
bors
dfe0683138 Auto merge of #112594 - ChrisDenton:process=-kill, r=Amanieu
Return `Ok` on kill if process has already exited

This will require an FCP from `@rust-lang/libs-api.`

Fixes #112423. See that issue for more details.
2023-07-05 11:04:17 +00:00
Chris Denton
9e5f61fcdd
Workaround for old android not having echo 2023-07-05 09:54:16 +01:00
Chris Denton
4309954187
Test Child::kill behaviour on exited process 2023-07-04 09:50:49 +01:00
Jubilee Young
079949da8e Update std to backtrace 0.3.68
Dedup addr2line, miniz_oxide, object in .lock
2023-07-02 17:02:45 -07:00
Nilstrieb
1e5d8fbcc9 downgrade compiler_builtins
The outline-atomics support in compiler_builtins messed up and wasn't limited to linux only.
https://github.com/rust-lang/compiler-builtins/pull/532/files#r1249354225
2023-07-02 21:02:31 +02:00
Matthias Krüger
c4ba0a6912
Rollup merge of #113202 - guilliamxavier:patch-1, r=workingjubilee
std docs: factorize literal in Barrier example

Motivated by https://www.reddit.com/r/rust/comments/rnh5hu/barrier_question_barrier_does_not_sync_many/ (but maybe not worth it?)
2023-07-02 10:27:20 +02:00
Chris Denton
e7fda447e7
Return Ok on kill if process has already exited 2023-07-01 01:38:39 +01:00
Guilliam Xavier
e34ff93c6b
std docs: factorize literal in Barrier example 2023-06-30 16:11:30 +02:00
Tshepang Mbambo
5b46aa1122
make HashMap::or_insert_with example more simple 2023-06-29 09:33:15 +02:00
João M. Bezerra
11f35d6016 std: remove an allocation in Path::with_extension
`Path::with_extension` used to reallocate (and copy) paths twice per
call, now it does it once, by checking the size of the previous and new
extensions it's possible to call `PathBuf::with_capacity` and pass the
exact capacity it takes.

Also reduce the memory consumption of the path returned from
`Path::with_extension` by using exact capacity instead of using
amortized exponential growth.
2023-06-27 18:45:47 -03:00
Yuki Okushi
f95be95737
Stabilize chown functions (unix_chown)
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-06-25 23:28:25 +09:00
bors
c51fbb3dd3 Auto merge of #113001 - ChrisDenton:win-arm32-shim, r=thomcc
Move windows-sys arm32 shim to c.rs

This moves the arm32 shim in to c.rs instead of appending to the generated file itself.

This makes it simpler to change these workarounds if/when needed. The downside is we need to exclude a couple of functions from being generated (see the comment). A metadata solution could help here but they'll be easy enough to add back if that happens.
2023-06-25 11:27:19 +00:00
Matthias Krüger
48247884c9
Rollup merge of #113009 - ChrisDenton:remove-path, r=workingjubilee
Remove unnecessary `path` attribute

Follow up to #111401. I missed this at the time but it should now be totally unnecessary since the other include was removed.

r? `@workingjubilee`
2023-06-25 02:04:21 +02:00
Matthias Krüger
2ed4368d2f
Rollup merge of #112956 - Amanieu:weak-intrinsics, r=Mark-Simulacrum
Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std`

This was added in rust-lang/compiler-builtins#526 to force all compiler-builtins intrinsics to use weak linkage.
2023-06-25 02:04:20 +02:00
Matthias Krüger
8630b1b3f4
Rollup merge of #112950 - tshepang:patch-4, r=Mark-Simulacrum
DirEntry::file_name: improve explanation
2023-06-25 02:04:20 +02:00
Chris Denton
e2eff0d4ab
Remove unnecessary path attribute 2023-06-24 19:56:29 +01:00
Chris Denton
8a7399cd45
Move arm32 shim to c.rs 2023-06-24 17:30:27 +01:00
Michael Goulet
ee8b035fab
Rollup merge of #112763 - Patryk27:bump-compiler-builtins, r=Amanieu
Bump compiler_builtins

Actually closes https://github.com/rust-lang/rust/issues/108489.

Note that the example code given [in compiler_builtins](https://github.com/rust-lang/compiler-builtins/pull/527) doesn't compile on current rustc since we're still waiting for https://reviews.llvm.org/D153197 (aka `LLVM ERROR: Expected a constant shift amount!`), but it's a step forward anyway.
2023-06-23 19:47:20 -07:00
Michael Goulet
4a01a38466
Rollup merge of #111087 - ibraheemdev:patch-15, r=dtolnay
Implement `Sync` for `mpsc::Sender`

`mpsc::Sender` is currently `!Sync` because the previous implementation contained an optimization where the channel started out as single-producer and was dynamically upgraded on the first clone, which relied on a unique reference to the sender. This optimization is one of the main reasons the old implementation was so complex and was removed in #93563. `mpsc::Sender` can now soundly implement `Sync`.

Note for any potential confusion, this chance does *not* add MPMC behavior. This only affects the already `Send + Clone` *sender*, not *receiver*.

It's technically possible to rely on the `!Sync` behavior in the same way as a `PhantomData<*mut T>`, but that seems very unlikely in practice. Either way, this change is insta-stable and needs an FCP.

`@rustbot` label +T-libs-api -T-libs
2023-06-23 19:47:19 -07:00
Tobias Bucher
11fecf619a Add Read, Write and Seek impls for Arc<File> where appropriate
If `&T` implements these traits, `Arc<T>` has no reason not to do so
either. This is useful for operating system handles like `File` or
`TcpStream` which don't need a mutable reference to implement these
traits.

CC #53835.
CC #94744.
2023-06-23 14:55:43 +02:00
Tobias Bucher
9fc2da1b54 Forward io::{Read,Seek,Write} impls of File to &File
This reduces code duplication.
2023-06-23 14:54:24 +02:00
Amanieu d'Antras
4a9f292e50 Expose compiler-builtins-weak-intrinsics feature for -Zbuild-std
This was added in rust-lang/compiler-builtins#526 to force all
compiler-builtins intrinsics to use weak linkage.
2023-06-23 11:15:34 +01:00
Tshepang Mbambo
6f61f6ba11
DirEntry::file_name: improve explanation 2023-06-23 04:47:30 +02:00
Thom Chiovoloni
5ef4d1fb2e
Actually save all the files 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
37854aab76
Update tvOS support elsewhere in the stdlib 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
49da0acb71
Avoid fork/exec spawning on tvOS/watchOS, as those functions are marked as prohibited 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
f978d7ea42
Finish up preliminary tvos support in libstd 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
bdc3db944c
wip: Support Apple tvOS in libstd 2023-06-21 14:59:37 -07:00
Guillaume Gomez
38916c71cb
Rollup merge of #112863 - clubby789:stderr-typo, r=albertlarsan68
Fix copy-paste typo in `eprint(ln)` docs

Fixes #112862
2023-06-21 15:45:17 +02:00
Guillaume Gomez
476798d4fd
Rollup merge of #99587 - ibraheemdev:park-orderings, r=m-ou-se
Document memory orderings of `thread::{park, unpark}`

Document `thread::park/unpark` as having acquire/release synchronization. Without that guarantee, even the example in the documentation can deadlock:

```rust
let flag = Arc::new(AtomicBool::new(false));

let t2 = thread::spawn(move || {
    while !flag.load(Ordering::Acquire) {
        thread::park();
    }
});

flag.store(true, Ordering::Release);
t2.thread().unpark();

// t1: flag.store(true)
// t1: thread.unpark()
// t2: flag.load() == false

// t2 now parks, is immediately unblocked but never
// acquires the flag, and thus spins forever
```

Multiple calls to `unpark` should also maintain a release sequence to make sure operations released by previous `unpark`s are not lost:

```rust
let a = Arc::new(AtomicBool::new(false));
let b = Arc::new(AtomicBool::new(false));

let t2 = thread::spawn(move || {
    while !a.load(Ordering::Acquire) || !b.load(Ordering::Acquire) {
        thread::park();
    }
});

thread::spawn(move || {
    a.store(true, Ordering::Release);
    t2.thread().unpark();
});

b.store(true, Ordering::Release);
t2.thread().unpark();

// t1: a.store(true)
// t1: t2.unpark()
// t3: b.store(true)
// t3: t2.unpark()

// t2 now parks, is immediately unblocked but never
// acquires the store of `a`, only the store of `b` which
// was released by the most recent unpark, and thus spins forever
```

This is of course a contrived example, but is reasonable to rely upon in real code.

Note that all implementations of park/unpark already comply with the rules, it's just undocumented.
2023-06-21 15:45:15 +02:00
Mara Bos
3acb1d2b9b
"Memory Orderings" -> "Memory Ordering"
Co-authored-by: yvt <i@yvt.jp>
2023-06-21 12:43:22 +02:00
clubby789
7201271fe8 Fix typo in eprintln docs 2023-06-21 01:08:10 +01:00
Ibraheem Ahmed
bf27f12d94 relaxed orderings in thread::park example 2023-06-20 20:05:31 -04:00
Guillaume Gomez
816b659157
Rollup merge of #112464 - eval-exec:exec/fix-connect_timeout-overflow, r=ChrisDenton
Fix windows `Socket::connect_timeout` overflow

This PR want to close #112405

- [x] add unit test
2023-06-20 14:23:39 +02:00
Eval EXEC
a0c757a13f
Remove useless unit tests 2023-06-20 18:47:31 +08:00
Eval EXEC
30e1c1a53c
Ignore connect_timeout unit test on SGX platform
Co-authored-by: Chris Denton <christophersdenton@gmail.com>
2023-06-20 18:43:12 +08:00
Michael Goulet
e24fe97bd9
Rollup merge of #112606 - clarfonthey:ip-display, r=thomcc
Alter `Display` for `Ipv6Addr` for IPv4-compatible addresses

ACP: rust-lang/libs-team#239
2023-06-19 17:53:35 -07:00
Vas
748e2c6df9 Document thread names for SGX compilation target 2023-06-19 10:25:25 +02:00
Patryk Wychowaniec
70ce2139e8
Bump compiler_builtins 2023-06-18 13:29:36 +02:00
Eval EXEC
f65b5d0ddf
Add unit test to connect to an unreachable address
Signed-off-by: Eval EXEC <execvy@gmail.com>
2023-06-18 15:59:25 +08:00
Matthias Krüger
eb40590579
Rollup merge of #112685 - cuviper:wasm-dlmalloc, r=Mark-Simulacrum
std: only depend on dlmalloc for wasm*-unknown

It was already filtered out for emscripten, but wasi doesn't need dlmalloc
either since it reuses `unix/alloc.rs`.
2023-06-18 08:06:42 +02:00
Matthias Krüger
876f00a655
Rollup merge of #107200 - mina86:c, r=Amanieu
io: soften ‘at most one write attempt’ requirement in io::Write::write

At the moment, documentation of std::io::Write::write indicates that
call to it ‘represents at most one attempt to write to any wrapped
object’.  It seems that such wording was put there to contrast it with
pre-1.0 interface which attempted to write all the data (it has since
been changed in [RFC 517]).

However, the requirement puts unnecessary constraints and may
complicate adaptors which perform non-trivial transformations on the
data.  For example, they may maintain an internal buffer which needs
to be written out before the write method accepts more data.  It might
be natural to code the method such that it flushes the buffer and then
grabs another chunk of user data.  With the current wording in the
documentation, the adaptor would be forced to return Ok(0).

This commit softens the wording such that implementations can choose
code structure which makes most sense for their particular use case.

While at it, elaborate on the meaning of `Ok(0)` return pointing out
that the write_all methods interprets it as an error.

[RFC 517]: https://rust-lang.github.io/rfcs/0517-io-os-reform.html
2023-06-18 08:06:41 +02:00
bors
ed7281e784 Auto merge of #112595 - hargoniX:l4re_fix, r=Mark-Simulacrum
fix: get the l4re target working again

This is based on work from https://github.com/rust-lang/rust/pull/103966, addressing the review comment by `@m-ou-se` at the time and "fixing" the (probably newly) missing read_buf.
2023-06-17 21:59:08 +00:00
Eval EXEC
fca9e6e706
Add unit test for TcpStream::connect_timeout
Signed-off-by: Eval EXEC <execvy@gmail.com>
2023-06-18 01:56:11 +08:00
Eval EXEC
22f62df337
Fix windows Socket::connect_timeout overflow
Signed-off-by: Eval EXEC <execvy@gmail.com>
2023-06-18 01:56:11 +08:00