Commit graph

4389 commits

Author SHA1 Message Date
bors 7201301df6 Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore
Fixes https://github.com/rust-lang/rust/issues/109631
Fixes https://github.com/rust-lang/rust/issues/109614
Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09 13:05:56 +00:00
Yuki Okushi 1e4361a23f
Rollup merge of #110060 - WaffleLapkin:sync_refs, r=jyn514
Document that `&T` and `&mut T` are `Sync` if `T` is

Proof: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fec8dc9ec36e873bf2962a2367d67045
2023-04-09 12:35:54 +09:00
Vadim Petrochenkov 612ddd2196 std: Mark two reexports that should be inlined as doc(inline) 2023-04-08 13:29:16 +03:00
bors c49c4fba11 Auto merge of #109995 - enkron:u/enkron/substitute-hardcoded-port-num-in-listen-on-fn, r=the8472
chore(tcp): change a hardcoded port number in a doctest to `port` var

The `listen_on` function in the example has a `port` option but doesn't use it
2023-04-08 06:54:40 +00:00
Sergei Belokon 081e222d99 fix(tcp): remove redundant format! macro call 2023-04-08 08:20:05 +10:00
Maybe Waffle 5f50c0f7ac Document that &T and &mut T are Sync if T is 2023-04-07 18:36:48 +00:00
bors b6f6104a1f Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieu
Stabilize is_some_and

This stabilizes the following public API:

```rust
impl<T> Option<T> {
    pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool;
}

impl<T, E> Result<T, E> {
    pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool;
    pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool;
}
```

Closes #93050 (tracking issue).

`@rustbot` label +T-libs-api -T-libs
2023-04-07 08:09:20 +00:00
bors 97879ce24b Auto merge of #109990 - gwy15:remove-bufwriter-useless-mut-pointer, r=jyn514
Remove an unnecessary `mut` in `BufWriter::into_parts`.

`ptr::read` takes `*const T` so `&mut` is not necessary.
2023-04-07 05:49:34 +00:00
Matthias Krüger 17ed06aad2
Rollup merge of #109960 - thomcc:symlink-junction-buffer-overrun, r=ChrisDenton
Fix buffer overrun in bootstrap and (test-only) symlink_junction

I don't think these can be hit in practice, due to their inputs being valid paths. It's also not security-sensitive code, but just... bad vibes.

I think this is still not really the right way to do this (in terms of path correctness), but is no worse than it was.

r? `@ChrisDenton`
2023-04-07 00:00:25 +02:00
Matthias Krüger b7e6973287
Rollup merge of #109806 - Zoxc:gnu-tls, r=pnkfelix
Workaround #109797 on windows-gnu

The addition of `#[inline]` here in https://github.com/rust-lang/rust/pull/108089 caused an unrelated linking issue (https://github.com/rust-lang/rust/issues/109797). This PR removes this attribute again on Windows to avoid regressions.
2023-04-07 00:00:23 +02:00
Jonas Platte 443928f7e3
Stabilize is_some_and 2023-04-06 23:14:23 +02:00
Sergei Belokon 502cb6f4b9 chore(tcp): change the hardcoded port number to port var
The `listen_on` function in the example has a `port` option but doesn't
use it
2023-04-06 18:32:01 +10:00
管唯宇 9169107c1c Remove an unnecessary mut in BufWriter::into_parts.
`ptr::read` takes `*const T` so `&mut` is not necessary.
2023-04-06 11:48:16 +08:00
Thom Chiovoloni 6861750e66
Fix buffer overrun in (test-only) symlink_junction 2023-04-05 00:37:30 -07:00
bors 1767585509 Auto merge of #109756 - cr1901:msp-shift, r=Mark-Simulacrum
Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive…

… fixes.

This fixes unsoundness on MSP430 where `compiler-builtins` and LLVM didn't agree on the width of the shift amount argument of the shifting primitives (4 bytes vs 2 bytes). See https://github.com/rust-lang/compiler-builtins/pull/522 for more details.
2023-04-03 13:09:08 +00:00
Matthias Krüger f2f5efce9c
Rollup merge of #109722 - hermitcore:read, r=Mark-Simulacrum
Implement read_buf for RustHermit

In principle, this PR extends rust-lang/rust#108326 for RustyHermit.
2023-04-03 08:58:53 +02:00
Taiki Endo 455a9601da Fix typo in std/src/os/fd/owned.rs 2023-04-02 02:14:37 +09:00
Guillaume Gomez 6c93c63771
Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddle
Move `doc(primitive)` future incompat warning to `invalid_doc_attributes`

Fixes #88070.

It's been a while since this was turned into a "future incompatible lint" so I think we can now turn it into a hard error without problem.

r? `@jyn514`
2023-03-31 22:32:49 +02:00
John Kåre Alsaker 6c941362c9 Workaround #109797 on windows-gnu 2023-03-31 09:37:39 +02:00
Guillaume Gomez 364e961417 Replace doc(primitive) with rustc_doc_primitive 2023-03-30 22:56:52 +02:00
beetrees 8d1bf505ff
Refactor glibc time64 support, riscv32 always has 64-bit time_t 2023-03-30 19:43:47 +01:00
bors 8a7ca936e6 Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se
Partial stabilization of `once_cell`

This PR aims to stabilize a portion of the `once_cell` feature:

- `core::cell::OnceCell`
- `std::cell::OnceCell` (re-export of the above)
- `std::sync::OnceLock`

This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag.

Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue)

Future steps for separate PRs:
- ~~Add `#[inline]` to many methods~~ #105651
- Update cranelift usage of the `once_cell` crate
- Update rust-analyzer usage of the `once_cell` crate
- Update error messages discussing once_cell

## To be stabilized API summary

```rust
// core::cell (in core/cell/once.rs)

pub struct OnceCell<T> { .. }

impl<T> OnceCell<T> {
    pub const fn new() -> OnceCell<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceCell<T>;
impl<T: Debug> Debug for OnceCell<T>
impl<T> Default for OnceCell<T>;
impl<T> From<T> for OnceCell<T>;
impl<T: PartialEq> PartialEq for OnceCell<T>;
impl<T: Eq> Eq for OnceCell<T>;
```

```rust
// std::sync (in std/sync/once_lock.rs)

impl<T> OnceLock<T> {
    pub const fn new() -> OnceLock<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceLock<T>;
impl<T: Debug> Debug for OnceLock<T>;
impl<T> Default for OnceLock<T>;
impl<#[may_dangle] T> Drop for OnceLock<T>;
impl<T> From<T> for OnceLock<T>;
impl<T: PartialEq> PartialEq for OnceLock<T>
impl<T: Eq> Eq for OnceLock<T>;
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>;
unsafe impl<T: Send> Send for OnceLock<T>;
unsafe impl<T: Sync + Send> Sync for OnceLock<T>;
impl<T: UnwindSafe> UnwindSafe for OnceLock<T>;
```

No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate:

```rust
impl<T> OnceCell<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}

impl<T> OnceLock<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}
```

I am new to this process so would appreciate mentorship wherever needed.
2023-03-30 10:12:23 +00:00
William D. Jones 01f49b350d Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive fixes. 2023-03-30 00:39:49 -04:00
bors 10338571cf Auto merge of #107221 - kleisauke:getentropy-emscripten, r=ChrisDenton
Use `getentropy()` instead of `/dev/urandom` on Emscripten

`/dev/urandom` is usually available on Emscripten, except when using
the special `NODERAWFS` filesystem backend, which replaces all normal
filesystem access with direct Node.js operations.

Since this filesystem backend directly access the filesystem on the
OS, it is not recommended to depend on `/dev/urandom`, especially
when trying to run the Wasm binary on OSes that are not Unix-based.

This can be considered a non-functional change, since Emscripten
implements `/dev/urandom` in the same way as `getentropy()` when not
linking with `-sNODERAWFS`.
2023-03-30 00:25:41 +00:00
Trevor Gross d1b28b75d2 Documentation updates to better share the purpose of OnceCell/OnceLock 2023-03-29 18:04:44 -04:00
Trevor Gross dc4ba57566 Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
Matthias Krüger 57f1d114cd
Rollup merge of #107387 - joboet:hermit_random, r=ChrisDenton
Use random `HashMap` keys on Hermit

Initializing the keys with random data provided by the libOS avoids HashDOS attacks and similar issues.

CC `@stlankes`
2023-03-29 21:19:47 +02:00
bors f98598c6cd Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3
Support TLS access into dylibs on Windows

This allows access to `#[thread_local]`  in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it.

`convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls.

A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms.

This fixes https://github.com/rust-lang/rust/issues/84933.
2023-03-29 16:20:37 +00:00
Stefan Lankes a9aaf3fedb Implement read_buf for RustHermit
In principle, this PR extends rust-lang/rust#108326 for RustyHermit.

Signed-off-by: Stefan Lankes <slankes@eonerc.rwth-aachen.de>
2023-03-29 15:29:36 +02:00
joboet f6bde0352b
std: use cvt to handle errors from read_entropy on Hermit 2023-03-29 10:52:48 +02:00
bors f346fb0bc6 Auto merge of #108792 - Amanieu:ohos, r=petrochenkov
Add OpenHarmony targets

- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`

Compiler team MCP: https://github.com/rust-lang/compiler-team/issues/568
2023-03-29 07:16:16 +00:00
John Kåre Alsaker 3019a341f3 Use #[inline] on Windows for thread local access 2023-03-29 08:55:25 +02:00
Amanieu d'Antras e3968be331 Add OpenHarmony targets
- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`
2023-03-28 16:01:13 +01:00
nils 857b631616
Rollup merge of #91793 - devnexen:anc_data_fbsd, r=ChrisDenton
socket ancillary data implementation for FreeBSD (from 13 and above).

introducing new build config as well.
2023-03-28 12:51:10 +02:00
Josh Triplett b38732f25c Add "Platform-specific behavior" heading and link to changes disclaimer 2023-03-28 11:26:43 +09:00
Josh Triplett 1354a38afd Document the heuristics IsTerminal uses on Windows 2023-03-28 10:49:35 +09:00
David CARLIER ed5c0f66ac socket ancillary data implementation for FreeBSD (from 13 and above).
introducing new build config as well.
2023-03-27 16:48:41 +01:00
Matthias Krüger 704991c959
Rollup merge of #102742 - bjorn3:cleanup_rust_start_panic, r=ChrisDenton
Remove unnecessary raw pointer in __rust_start_panic arg

It is no longer necessary as __rust_start_panic switched to the Rust abi.
2023-03-27 08:46:52 +02:00
Matthias Krüger fe0b0428b8
Rollup merge of #98651 - mattfbacon:master, r=ChrisDenton
Follow C-RW-VALUE in std::io::Cursor example

rustc-dev-guide says to do this:

r? ``@steveklabnik``
2023-03-27 08:46:51 +02:00
Matthias Krüger 102bbbd940
Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-parts, r=m-ou-se,the8472
Stabilize `nonnull_slice_from_raw_parts`

FCP is done: https://github.com/rust-lang/rust/issues/71941#issuecomment-1100910416
Note that this doesn't const-stabilize `NonNull::slice_from_raw_parts` as `slice_from_raw_parts_mut` isn't const-stabilized yet. Given #67456 and #57349, it's not likely available soon, meanwhile, stabilizing only the feature makes some sense, I think.

Closes #71941
2023-03-27 08:46:50 +02:00
bjorn3 b874502a20 Remove unnecessary raw pointer in __rust_start_panic arg
It is no longer necessary as __rust_start_panic switched to the Rust abi.
2023-03-26 16:40:18 +00:00
Matthias Krüger 936377a0aa
Rollup merge of #109406 - WaffleLapkin:🥛, r=cuviper
Remove outdated comments

What the title said
2023-03-24 07:13:04 +01:00
Matthias Krüger cca2630bc9
Rollup merge of #109368 - hermitcore:typo, r=cuviper
fix typo in the creation of OpenOption for RustyHermit

Due to this typo we have to build a workaround for issue hermitcore/libhermit-rs#191.

RustyHermit is a tier 3 platform and backward compatibility does not have to be guaranteed.
2023-03-24 01:22:06 +01:00
Matthias Krüger 605a4fc7ab
Rollup merge of #109142 - the8472:mutex-block-docs, r=cuviper
Add block-based mutex unlocking example

This modifies the existing example in the Mutex docs to show both `drop()` and block based early unlocking.

Alternative to #81872, which is getting closed.
2023-03-24 01:22:05 +01:00
Matthias Krüger aeabe34d79
Rollup merge of #106964 - workingjubilee:crouching-ioerror-hidden-documentation, r=ChrisDenton
Clarify `Error::last_os_error` can be weird

Fundamentally, querying the OS for error codes is a process that is deeply subject to the whims of chance and fortune. We can account for OS, but not for every combination of platform APIs. A compiled binary may not recognize new errors introduced years later. We should clarify a few especially odd situations, and what they mean: We can effectively promise nothing... if you ask for Rust to decode errors where none have occurred.

This allows removing mention of ErrorKind::Uncategorized.
That error variant is hidden deliberately, so we should not explicitly mention it.

This fixes #106937.

Since you had an opinion also: Does this solution seem acceptable?
r? ``@ChrisDenton``
2023-03-23 19:55:42 +01:00
Matthias Krüger 93a82a44a1
Rollup merge of #108164 - joboet:discard_messages_mpmc_array, r=Amanieu
Drop all messages in bounded channel when destroying the last receiver

Fixes #107466 by splitting the `disconnect` function for receivers/transmitters and dropping all messages in `disconnect_receivers` like the unbounded channel does. Since all receivers must be dropped before the channel is, the messages will already be discarded at that point, so the `Drop` implementation for the channel can be removed.

``@rustbot`` label +T-libs +A-concurrency
2023-03-21 19:00:11 +01:00
Matthias Krüger 1a43859a74
Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplett
Windows: make `Command` prefer non-verbatim paths

When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2023-03-21 19:00:10 +01:00
nils 82dc127d7b
Rollup merge of #108326 - tmiasko:read-buf, r=thomcc
Implement read_buf for a few more types

Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout,
ChildStderr (and internally for AnonPipe, Handle, Socket), so
that it skips buffer initialization.

The other provided methods like read_to_string and read_to_end are
implemented in terms of read_buf and so benefit from the optimization
as well.

This commit also implements read_vectored and is_read_vectored where
applicable.
2023-03-21 13:00:21 +01:00
bors 3ff4d56650 Auto merge of #108262 - ChrisDenton:libntdll, r=Mark-Simulacrum
Distribute libntdll.a with windows-gnu toolchains

This allows the OS loader to load essential functions (e.g. read/write file) at load time instead of lazily doing so at runtime.

r? libs
2023-03-21 02:23:27 +00:00
Maybe Waffle c513c3b9a5 Remove outdated comments 2023-03-20 17:42:04 +00:00