Commit Graph

5037 Commits

Author SHA1 Message Date
Matthias Krüger
835edc1397
Rollup merge of #116341 - Ayush1325:uefi-args, r=Mark-Simulacrum
Implement sys::args for UEFI

- Uses `EFI_LOADED_IMAGE_PROTOCOL`, which is implemented for all loaded images.

Tested on qemu with OVMF

cc ``@nicholasbishop``
cc ``@dvdhrm``
2023-10-15 21:29:07 +02:00
Matthias Krüger
e063d8a591
Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnay
Broaden the consequences of recursive TLS initialization

This PR updates the documentation of `LocalKey` to clearly disallow the behaviour described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525738849). This allows using `OnceCell` for the lazy initialization of TLS variables, which panics on reentrant initialization instead of updating the value like TLS variables currently do.

``@rustbot`` label +T-libs-api
r? ``@m-ou-se``
2023-10-15 21:29:06 +02:00
bors
d60d63fbf7 Auto merge of #116527 - sthibaul:libc, r=Mark-Simulacrum
Bump libc dependency

To get GNU/Hurd support, so that CI of external repositories (e.g. getrandom) can build std.
2023-10-15 15:17:17 +00:00
Ayush Singh
6713ae9d42
Implement args for UEFI
- Uses `EFI_LOADED_IMAGE_PROTOCOL`
- verify that cli args are valid UTF-16
- Update Docs

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-10-15 18:45:13 +05:30
bors
ff5664d600 Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrum
Make `try_exists` return `Ok(true)` for Windows Unix Sockets

This is a follow up to #109106 but for[ `fs::try_exists`](https://doc.rust-lang.org/std/fs/fn.try_exists.html), which doesn't need to get the metadata of a file (which can fail even if a file exists).

`fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). This PR fixes it by checking for an error code that's returned when there's a failure to use a reparse point.

## Reparse points

A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`.

So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist on the filesystem so `try_exists` should report that as `Ok(true)`.

r? libs
2023-10-15 05:50:30 +00:00
Guillaume Gomez
fcd75ccc90
Rollup merge of #116540 - daxpedda:once-cell-lock-try-insert, r=Mark-Simulacrum
Implement `OnceCell/Lock::try_insert()`

I took inspiration from [`once_cell`](https://crates.io/crates/once_cell):
- [`once_cell::unsync::OnceCell::try_insert()`](874f9373ab/src/lib.rs (L551-L563))
- [`once_cell::sync::OnceCell::try_insert()`](874f9373ab/src/lib.rs (L1080-L1087))

I tried to change as little code as possible in the first commit and applied some obvious optimizations in the second one.

ACP: https://github.com/rust-lang/libs-team/issues/276
Tracking issue: #116693
2023-10-14 22:35:05 +02:00
ivmarkov
b3c95c522c Fix broken build on ESP-IDF caused by #115108 2023-10-14 10:20:48 +00:00
bors
39acbed8d6 Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkan
Bump bootstrap compiler to just-released beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-14 05:44:48 +00:00
Peter Jaszkowiak
49aa5a23ca Revert "Invoke backtrace-rs buildscript in std buildscript"
This reverts commit 93677276bc
because it caused issues for projects building the standard
library with non-cargo build systems.
2023-10-13 13:43:00 -06:00
bors
985795270e Auto merge of #115108 - ijackson:broken-wait-status, r=dtolnay
Fix exit status / wait status on non-Unix cfg(unix) platforms

Fixes #114593

Needs FCP due to behavioural changes (NB only on non-Unix `#[cfg(unix)]` platforms).

Also, I think this is likely to break in CI.  I have not been yet able to compile the new bits of `process_unsupported.rs`, although I have compiled the new module.  I'd like some help from people familiar with eg emscripten and fuchsia (which are going to be affected, I think).
2023-10-13 14:53:35 +00:00
daxpedda
6db2587999
Implement OnceCell/Lock::try_insert() 2023-10-13 14:54:32 +02:00
Chris Denton
2f5dea0978
Test that unix sockets exist on Windows 2023-10-13 06:02:38 +01:00
Chris Denton
2b7fe7e0a1
Make try_exists return Ok(true) for Windows UDS
`fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). Fix this by checking for an error code that's returned when there's a failure to use a reparse point.

A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`.

So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist so `try_exists` should report that as `Ok(true)`.
2023-10-13 06:02:18 +01:00
bors
f562931178 Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubilee
Remove unnecessary tmp variable in default_read_exact

This `tmp` variable has existed since the original implementation (added in ff81920f03), but it's not necessary (maybe non-lexical lifetimes helped?).

It's common to read std source code to understand how things actually work, and this tripped me up on my first read.
2023-10-12 00:45:22 +00:00
bors
6d05c430d2 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo

*Blocked on https://github.com/rust-lang/cargo/pull/12800*

## Summary

In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.

Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).

The Rust logo is also no longer shown by default for non-Rust docs.

### Screenshots

<details><summary>Before</summary>

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b)
| In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376)

[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar

</details>

#### Whole sidebar screenshots

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7)
| In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47)

#### Different logo configurations

|         | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root    | ![short-root]    | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]

[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30

##### Without a logo

![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab)

### Preview pages

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html

## Motivation

This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).

Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).

[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018

## Guide-level explanation

This PR cleans up some of the sidebar navigation.

It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).

It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.

## Drawbacks

While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.

## Rationale and alternatives

I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.

## Prior art

This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.

[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html

## Unresolved questions

Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.

## Future possibilities

Beyond this, plenty of other changes could be made to improve the layout, like

* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
  * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
  * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
  * We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
  * A possibility: add a Back arrow next to the "In [module]" header?
    ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23)
* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.

But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
Qiu Chaofan
14d29be03c Support AIX in Rust standard library 2023-10-09 14:02:57 +08:00
Michael Howell
c6e6ecb1af rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
Samuel Thibault
04d4336009 Bump libc dependency
To get GNU/Hurd support, so that CI of external repositories (e.g. getrandom)
can build std.
2023-10-08 19:56:44 +02:00
bors
fc01a7432b Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee
Use `HashMap::with_capacity_and_hasher` instead of using base

Cleans up the internal logic for `HashMap::with_capacity` slightly.
2023-10-07 05:26:12 +00:00
Wilfred Hughes
dca90f7ec1 Remove unnecessary tmp variable in default_read_exact
This variable seems to serve no purpose, and it's a little confusing
when reading std source code, so remove it.
2023-10-07 01:16:45 -04:00
bors
4ea5190026 Auto merge of #116318 - pitaj:android-backtrace-build, r=workingjubilee
Invoke `backtrace-rs` buildscript in `std` buildscript

Based on #99883 by `@Arc-blroth`
Depends on rust-lang/backtrace-rs#556 and rust-lang/cc-rs#705
2023-10-07 02:20:50 +00:00
bors
93b6a36568 Auto merge of #116501 - workingjubilee:rollup-fpzov6m, r=workingjubilee
Rollup of 4 pull requests

Successful merges:

 - #116277 (dont call mir.post_mono_checks in codegen)
 - #116400 (Detect missing `=>` after match guard during parsing)
 - #116458 (Properly export function defined in test which uses global_asm!())
 - #116500 (Add tvOS to target_os for register_dtor)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-07 00:27:14 +00:00
Jubilee
4b102b0d8d
Rollup merge of #116500 - simlay:tvos-support-for-register_dtor, r=workingjubilee
Add tvOS to target_os for register_dtor

Closes #116491.
2023-10-06 16:37:48 -07:00
bors
8fdb0a9b57 Auto merge of #114709 - ShE3py:wasi-io-error-more, r=workingjubilee
Use `io_error_more` on WASI

#86442 added many variants to [`io::ErrorKind`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html), but `sys::wasi::decode_error_kind()` wasn't modified to use them.

The preview1 `errno` list:
4712d490fd/legacy/preview1/docs.md (-errno-variant)

Original implementation: #63814

`@rustbot` label +A-error-handling +C-enhancement +O-wasi
2023-10-06 22:39:41 +00:00
Sebastian Imlay
3abef68e63 Add tvOS to target_os for register_dtor 2023-10-06 18:11:49 -04:00
Matthias Krüger
7f0cf8c0e4
Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviper
Minor doc clarification in Once::call_once
2023-10-06 21:17:51 +02:00
ShE3py
3706e6f61a
Use io_error_more on WASI 2023-10-06 19:05:45 +02:00
bors
1bc0463b18 Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #115454 (Clarify example in docs of str::char_slice)
 - #115522 (Clarify ManuallyDrop bit validity)
 - #115588 (Fix a comment in std::iter::successors)
 - #116198 (Add more diagnostic items for clippy)
 - #116329 (update some comments around swap())
 - #116475 (rustdoc-search: fix bug with multi-item impl trait)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-06 13:07:15 +00:00
Peter Hall
c95015c295 Minor doc clarification in Once::call_once 2023-10-06 12:20:39 +01:00
Guillaume Gomez
3785fed021
Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin
Add more diagnostic items for clippy
2023-10-06 13:18:34 +02:00
bors
6683f13fa1 Auto merge of #111595 - fortanix:raoul/waitqueue_clarifications, r=workingjubilee
`waitqueue` clarifications for SGX platform

The documentation of `waitqueue` functions on the `x86_64-fortanix-unknown-sgx` platform is incorrect at some places and on others missing. This PR improves upon this.

cc: `@jethrogb`
2023-10-06 11:12:13 +00:00
bors
fd80c02c16 Auto merge of #116463 - ChrisDenton:nlibc, r=workingjubilee
Remove libc

We don't use much libc on Windows and it seemed silly to keep if for the sake of [two well documented constants](https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170).
2023-10-06 03:39:22 +00:00
bors
579be69de9 Auto merge of #101150 - jethrogb:jb/cleanup-sgx-user-memory-copies, r=workingjubilee
Clean up SGX user memory copies

Follow-up on #98126 and #100383

r? `@cuviper`
cc `@raoulstrackx`
2023-10-06 01:50:10 +00:00
Chris Denton
c8f3aa451a
Remove libc
We don't use much libc on Windows.
2023-10-06 00:35:00 +01:00
Jason Newcomb
d464b72970 Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
Ramon de C Valle
7b45674015 Disable CFI for core and std CFI violations
Works around #115199 by temporarily disabling CFI for core and std CFI
violations to allow the user rebuild and use both core and std with CFI
enabled using the Cargo build-std feature.
2023-10-04 10:05:54 -07:00
Matthias Krüger
d5bd019645
Rollup merge of #116146 - Milo123459:milo/clarify-arg-documentation, r=thomcc
Clarify `arg` and `args` documentation

Fixes #95400
2023-10-04 05:02:04 +02:00
Matthias Krüger
36e234a0fa
Rollup merge of #115961 - Kriskras99:master, r=thomcc
Replace 'mutex' with 'lock' in RwLock documentation

When copying the documentation for `clear_poison` from Mutex, not every occurence of 'mutex' was replaced with 'lock'.
2023-10-04 05:02:03 +02:00
Mark Rousskov
787d32324c Bump version placeholders 2023-10-03 20:26:36 -04:00
bors
187b8131d4 Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubilee
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`.

For debugging the third one, it was really hard to find someone else who already had that problem. I only managed to find this thread: https://www.mail-archive.com/netdev@vger.kernel.org/msg159519.html
2023-10-03 20:35:38 +00:00
Matthias Krüger
a4ba529474
Rollup merge of #116282 - rustaceanclub:master, r=davidtwco
Fix broken links

The previous address is no longer available, replace it with the latest available one.
2023-10-03 16:24:16 +02:00
Peter Jaszkowiak
93677276bc Invoke backtrace-rs buildscript in std buildscript
Based on #99883 by @Arc-blroth
Depends on rust-lang/backtrace-rs#556 and rust-lang/cc-rs#705
2023-10-02 19:34:27 -06:00
Tyler Mandry
1edf7233fa
Rollup merge of #116289 - linkmauve:patch-1, r=the8472
Add missing #[inline] on AsFd impl for sys::unix::fs::File

This operation should be extremely cheap, at most the `mov` of the underlying file descriptor, but due to this missing `#[inline]` it is currently a function call.
2023-10-02 16:09:42 -04:00
bors
79bfd93d5a Auto merge of #116207 - Ayush1325:uefi_stdio, r=Mark-Simulacrum
Stdio support for UEFI

- Uses Simple Text Output Protocol and Simple Text Input Protocol
- Reading is done one character at a time
- Writing is done with max 4096 characters

# Quirks
## Output Newline
- UEFI uses CRLF for newline. So when running the application in UEFI shell (qemu VGA), the output of `println` looks weird.
- However, since the UEFI shell supports piping output, I am unsure if doing any output post-processing is a good idea. UEFI shell `cat` command seems to work fine with just LF.

## Input Newline
- `Stdin.read_line()` method is broken in UEFI shell. Pressing enter seems to be read as CR, which means LF is never encountered.
- Works fine with input redirection from file.

CC `@dvdhrm`
2023-10-02 00:03:52 +00:00
Ayush Singh
3f4a289016
Stdio for UEFI
- Uses Simple Text Output Protocol and Simple Text Input Protocol
- Reading is done one character at a time
- Writing is done with max 4096 characters

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-10-02 00:07:11 +05:30
bors
2f89c414f2 Auto merge of #116157 - the8472:doc-monotonoic-suspend, r=Mark-Simulacrum
Document that Instant may or may not include system-suspend time

Since people are still occasionally surprised by this let's make it more explicit. This doesn't add any new guarantees, only documents the status quo.

Related issues: #87906 #79462
2023-09-30 19:49:34 +00:00
linkmauve
133aa56a84
Add missing #[inline] on AsFd impl for sys::unix::fs::File
This operation should be extremely cheap, at most the mov of the underlying
file descriptor, but due to this missing #[inline] it is currently a function
call.
2023-09-30 17:56:42 +02:00
cui fliter
6ef3fd7138 Fix broken links
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-30 10:26:04 +08:00
bors
dd91aba2fd Auto merge of #114882 - ChrisDenton:riddle-me, r=dtolnay
Update windows ffi bindings

Bump `windows-bindgen` to version 0.51.1. This brings with it some changes to the generated FFI bindings, but little that affects the code.

One change that does have more of an impact is `SOCKET` being `usize` instead of either `u64` or `u32` (as is used in std's public `SOCKET` type). However, it's now easy enough to abstract over that difference.

Finally I added a few new bindings that are likely to be used in pending PRs, mostly to make sure they're ok with the new metadata.

r? libs
2023-09-28 13:35:36 +00:00
bors
c01d8d238c Auto merge of #114428 - ChaiTRex:master, r=dtolnay
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process`

Implementing suggestion from https://github.com/rust-lang/rust/issues/84908#issuecomment-912352902:

> I believe the impl on ExitStatusError should be
>
> ```rust
> impl From<ExitStatusError> for ExitStatus
> ```
>
> rather than
>
> ```rust
> impl Into<ExitStatus> for ExitStatusError
> ```
>
> (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
2023-09-28 11:47:54 +00:00