Commit Graph

7464 Commits

Author SHA1 Message Date
cyrgani
a72402a0f9 add last std diagnostic items for clippy 2025-02-18 10:54:37 +01:00
Thalia Archibald
d2f15971de Remove std::os::wasi::fs::FileExt::tell
Following #137165 (Use `tell` for `<File as Seek>::stream_position`),
`tell` is now directly exposed via `stream_position`, making
`<File as FileExt>::tell` redundant. Remove it.
2025-02-17 20:21:05 -08:00
Kornel
40ecda6a33
Remove obsolete MinGW ThinLTO+TLS workaround
#109797 is fixed
2025-02-17 22:10:25 +00:00
Matthias Krüger
10018d8e10
Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDenton
Use `tell` for `<File as Seek>::stream_position`

Some platforms have a more efficient way to get the current offset of the file than by seeking. For example, Wasi has `fd_tell` and SOLID has `SOLID_FS_Ftell`. Implement `<File as Seek>::stream_position()` in terms of those.

I do not use any APIs that were not already used in `std`. Although, the `libc` crate has [`ftell`](https://docs.rs/libc/latest/libc/fn.ftell.html), [`ftello`](https://docs.rs/libc/latest/libc/fn.ftello.html), and [`ftello64`](https://docs.rs/libc/latest/libc/fn.ftello64.html), I do not know platform coverage. It appears that Windows has no `tell`-like API.

I have checked that it builds on each relevant platform.
2025-02-17 17:06:10 +01:00
Thalia Archibald
7112474134 Use tell for <File as Seek>::stream_position 2025-02-17 05:25:14 -08:00
Martin Nordholts
f6485ff617 tests: Also gate f16::erfc() doctest with reliable_f16_math cfg
In 136324 the doctest for `f16::erf()` was gated with
`reliable_f16_math`. Add the same gate on `f16::erfc()` to
avoid:

    rust_out.71e2e529d20ea47d-cgu.0:\
    (.text._ZN8rust_out4main43_doctest_main_library_std_src_f16_rs_1321_017h485f3ffe6bf2a981E+0x38): \
    undefined reference to `__gnu_h2f_ieee'

on MIPS (and maybe other architectures).
2025-02-17 11:59:09 +01:00
Matthias Krüger
c04801dbb9
Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDenton
Use `const_error!` when possible

Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
2025-02-17 06:37:37 +01:00
Thalia Archibald
05e4175d79 Synchronize platform adaptors for OsString/OsStr
* Order items as the average of the two adaptors. Enables easier diffs.
* Consistently apply #[inline].
* Implement FromInner<Vec<u8>> for bytes::Buf.
* Implement Clone::clone_from for wtf8::Buf.
2025-02-16 15:21:46 -08:00
Thalia Archibald
8b1a3a26c7 Simplify control flow with while-let 2025-02-16 15:19:08 -08:00
Thalia Archibald
09dc38f23b Improve WTF-8 comments 2025-02-16 14:43:31 -08:00
Matthias Krüger
53b4c7c631
Rollup merge of #136986 - ehuss:library-unsafe-fun, r=Noratrieb
Apply unsafe_op_in_unsafe_fn to the standard library

This applies unsafe_op_in_unsafe_fn to the standard library in preparation for updating to Rust 2024.

Closes https://github.com/rust-lang/rust/issues/127747 (I think?) cc ``@workingjubilee``
I have been testing a variety of targets, and I feel like they are all pretty much covered. I'll continue doing some testing async, but I don't expect to catch any more.
2025-02-16 17:14:03 +01:00
HTGAzureX1212
eec49bbf59 add MAX_LEN_UTF8 and MAX_LEN_UTF16 constants 2025-02-16 21:08:38 +08:00
bors
8c07d140e0 Auto merge of #137065 - jhpratt:rollup-ree9mej, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - #135687 (re-export `FromCoroutine` from `core::iter`)
 - #135813 (CI: split i686-mingw job to three free runners)
 - #136749 (Implement Extend<AsciiChar> for String)
 - #136879 (Add safe new() to NotAllOnes)
 - #136978 (Windows: Update generated bindings)
 - #137028 (mir_build: Clarify some code for lowering `hir::PatExpr` to THIR)
 - #137029 (Remove unnecessary check code in unused_delims)
 - #137056 (made check_argument_compat public for use in miri)
 - #137062 (Forward all default methods for I/O impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-15 07:52:03 +00:00
Jacob Pratt
ba89ea8add
Rollup merge of #137062 - thaliaarchi:io-optional-methods/write, r=workingjubilee
Forward all default methods for I/O impls

Forward all default methods for `&mut T` and `Box<T>` to the inner `io::Read`, `io::Write`, `io::Seek`, and `io::BufRead` types.
2025-02-15 02:37:33 -05:00
Jacob Pratt
224be79129
Rollup merge of #136978 - ChrisDenton:windows-bindgen, r=Amanieu
Windows: Update generated bindings

Update to windows-bindgen 0.59.

This update is aimed at reducing churn in the future, but means a bit more churn now:

- `bindings.txt` no longer needs us to write the namespace for each item. This is good because it means in the future we won't need to change them if the namespace changes. However, there are a few where we still need to disambiguate due to duplicate items (this is a bug in the upstream metadata).
- The output in `windows-sys.rs` is now sorted. It was mostly sorted before but not intentionally. This should mean future changes are less noisy.

The actual code changes are minimal here. A few types are now `bool` instead of `BOOLEAN`, which is more convenient.
2025-02-15 02:37:30 -05:00
Jacob Pratt
1524b5319a
Rollup merge of #136879 - kornelski:non1, r=Noratrieb
Add safe new() to NotAllOnes

Replaces duplicated `unsafe` code with a single, easier to verify implementation.
2025-02-15 02:37:29 -05:00
Thalia Archibald
11c174006e Forward all default methods for I/O impls 2025-02-14 21:48:12 -08:00
bors
f77247ac59 Auto merge of #136324 - GrigorenkoPV:erf, r=tgross35
Implement `f{16,32,64,128}::{erf,erfc}` (`#![feature(float_erf)]`)

Tracking issue: #136321

try-job: x86_64-gnu-aux
2025-02-15 04:52:50 +00:00
Jubilee
922119b79c
Rollup merge of #136983 - ehuss:misc-2024-prep, r=tgross35
Prepare standard library for Rust 2024 migration

This includes a variety of commits preparing the standard library for migration to Rust 2024.

The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.
2025-02-14 14:05:24 -08:00
Eric Huss
4f4ea35a69 std: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Eric Huss
d5f0aa49e7 Fix safety of windows uwp functions
These functions were changed to be safe in
https://github.com/rust-lang/rust/pull/127763, but this particular UWP
version was missed. Otherwise this causes unnecessary unsafe block
warnings/errors.
2025-02-14 07:36:17 -08:00
Matthias Krüger
b5fce2ab8e
Rollup merge of #136967 - DaniPopes:io-repeat-fill, r=joboet
Use `slice::fill` in `io::Repeat` implementation

Use the existing `fill` methods on slices instead of manually writing the fill loop.
2025-02-14 16:23:32 +01:00
Matthias Krüger
c21a76fde0
Rollup merge of #136886 - ehuss:remove-prelude-common, r=jhpratt
Remove the common prelude module

This fixes the issues described in https://github.com/rust-lang/rust/issues/136102. Primarily, this resolves some issues with how the documentation for the prelude is generated:

- It avoids showing "unstable" for macros in the prelude that are actually stable.
- Avoids duplication of some pages due to the previous lack of `doc(no_inline)`.
- Makes the different edition preludes consistent, and sets a pattern that can be used by future editions.

We may need to rearrange these modules in the future if we decide to remove anything from the prelude again. If we do, I think we should look into a different solution that avoids the documentation problems.

Closes https://github.com/rust-lang/rust/issues/136102
2025-02-14 16:23:30 +01:00
Matthias Krüger
678ff2a59b
Rollup merge of #136052 - no1wudi:fix, r=workingjubilee
Correct comment for FreeBSD and DragonFly BSD in unix/thread
2025-02-14 16:23:29 +01:00
Kornel
00964aa401
Add safe new to NotAllOnes 2025-02-14 12:00:13 +00:00
Jubilee
dfc235f80c
Rollup merge of #136908 - mustartt:aix-mutex-destory-einval, r=joboet
[AIX] expect `EINVAL` for `pthread_mutex_destroy`

Calling `pthread_mutex_destory` on a mutex initalized with the static initializer macro `PTHREAD_MUTEX_INITIALIZER` will result in `EINVAL` if the mutex is not lock/unlocked prior to calling `pthread_mutex_destroy`.
2025-02-13 21:37:51 -08:00
Pavel Grigorenko
b8f0ed37bd Implement f{16,32,64,128}::{erf,erfc}
Also add
```rust
// #[unstable(feature = "float_gamma", issue = "99842")]
```
to `gamma`-function-related methods on `f16` & `f128`,
as per https://github.com/rust-lang/rust/pull/136324#issuecomment-2626270247
2025-02-14 01:23:16 +03:00
Eric Huss
ef20a1b1f8 std: Apply deprecated_safe_2024 2025-02-13 13:10:28 -08:00
Eric Huss
1b3940f07f std: Apply fixes for tail drop expressions 2025-02-13 13:10:27 -08:00
Eric Huss
1ba59f868a std: Apply rust_2024_incompatible_pat 2025-02-13 13:10:27 -08:00
Eric Huss
7dc9e05742 std: Apply dependency_on_unit_never_type_fallback
This generates a warning of irrefutable patterns. I decided to slightly
tweak the example so the closure returns unit, since the intent wasn't
to show the weird behavior of returning `!`.
2025-02-13 13:10:27 -08:00
Eric Huss
c1791a1b48 std: Apply missing_unsafe_on_extern 2025-02-13 13:10:27 -08:00
Eric Huss
9e60b0e554 std: Apply unsafe_attr_outside_unsafe 2025-02-13 13:10:27 -08:00
bors
a567209daa Auto merge of #134633 - GrigorenkoPV:get_disjoint_mut, r=cuviper
Stabilize `get_many_mut` as `get_disjoint_mut`

Tracking issue: #104642

Closes #104642

FCP completed in https://github.com/rust-lang/rust/issues/104642#issuecomment-2558161073
2025-02-13 21:09:31 +00:00
Eric Huss
b7c975b22e library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00
xizheyin
c1ecdf1124 Consistently using as_mut_ptr() and as_ptr() in thread
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-13 19:39:05 +08:00
xizheyin
7e7f5d3856 Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in unix
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-13 19:39:05 +08:00
DaniPopes
1a3efd27ab
Use slice::fill in io::Repeat implementation
Use the existing `fill` methods on slices instead of manually
writing the fill loop.
2025-02-13 12:23:52 +01:00
Chris Denton
26eeac1a1e
Windows: Update generated bindings to 0.59 2025-02-13 10:32:59 +00:00
Jacob Pratt
f9142b0785
Rollup merge of #136949 - ehuss:wasm-bench-time, r=jhpratt
Fix import in bench for wasm

This import was causing annoying unused import errors when checking the standard library for some wasm targets. The problem is that everything here is disabled if it is wasm32, but this import wasn't cfg'd.
2025-02-13 03:53:33 -05:00
Jacob Pratt
9a26bb1892
Rollup merge of #136945 - samueltardieu:push-rsqlyknnvyqm, r=fmease
Add diagnostic item for `std::io::BufRead`

This will be used in Clippy to detect unbuffered calls to `Read::bytes()`.
2025-02-12 20:10:03 -05:00
Jacob Pratt
de712f9e0a
Rollup merge of #136818 - a1phyr:io_repeat_exact, r=jhpratt
Implement `read*_exact` for `std:io::repeat`

cc #136756
2025-02-12 20:10:01 -05:00
Jacob Pratt
4ce473ccba
Rollup merge of #136699 - joboet:netaddr_from_inner, r=cuviper
std: replace the `FromInner` implementation for addresses with private conversion functions

Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed.

I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside  `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
2025-02-12 20:09:59 -05:00
Eric Huss
c91737373a Fix import in bench for wasm 2025-02-12 14:44:30 -08:00
Samuel Tardieu
f8930b44a5 Add diagnostic item for std::io::BufRead
This will be used in Clippy to detect unbuffered calls to
`Read::bytes()`.
2025-02-12 22:22:15 +01:00
joboet
80c60fe783
std: replace the FromInner implementation for addresses with private conversion functions
Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed.

I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside  `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
2025-02-12 14:13:35 +01:00
bors
552a959051 Auto merge of #136918 - GuillaumeGomez:rollup-f6h21gg, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #134981 ( Explain that in paths generics can't be set on both the enum and the variant)
 - #136698 (Replace i686-unknown-redox target with i586-unknown-redox)
 - #136767 (improve host/cross target checking)
 - #136829 ([rustdoc] Move line numbers into the `<code>` directly)
 - #136875 (Rustc dev guide subtree update)
 - #136900 (compiler: replace `ExternAbi::name` calls with formatters)
 - #136913 (Put kobzol back on review rotation)
 - #136915 (documentation fix: `f16` and `f128` are not double-precision)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-12 12:42:25 +00:00
bors
021fb9c09a Auto merge of #136897 - workingjubilee:revert-unfcped-stab, r=WaffleLapkin
Revert "Stabilize `extended_varargs_abi_support`"

I cannot find an FCP for this, despite it being a stabilization PR which normally means we do an FCP of some kind? It would seem reasonable for _either_ compiler or lang to have FCPed it? I am thus opening a revert PR, which mostly-cleanly applies, so that we can later actually land this properly with a stability report and FCP.

- https://github.com/rust-lang/rust/issues/136896
- https://github.com/rust-lang/rust/pull/116161
- https://github.com/rust-lang/rust/issues/100189
2025-02-12 09:44:30 +00:00
eyelash
4f37b458fc
f128 is quadruple-precision 2025-02-12 09:55:45 +01:00
eyelash
0ca8353651
f16 is half-precision 2025-02-12 09:54:33 +01:00
Henry Jiang
4b086d4711 expect EINVAL for pthread_mutex_destroy for aix 2025-02-12 00:54:00 -05:00
Jubilee Young
cafa646f21 library: amend revert of extended_varargs_abi_support for beta diff
And leave a comment on the unusual `cfg_attr`

Co-authored-by: waffle <waffle.lapkin@gmail.com>
2025-02-11 20:03:56 -08:00
Kevin Reid
d2ed8cf661 Optionally add type names to TypeIds.
This feature is intended to provide expensive but thorough help for
developers who have an unexpected `TypeId` value and need to determine
what type it actually is. It causes `impl Debug for TypeId` to print
the type name in addition to the opaque ID hash, and in order to do so,
adds a name field to `TypeId`. The cost of this is the increased size of
`TypeId` and the need to store type names in the binary; therefore, it
is an optional feature.

It may be enabled via `cargo -Zbuild-std -Zbuild-std-features=debug_typeid`.
(Note that `-Zbuild-std-features` disables default features which you
may wish to reenable in addition; see
<https://doc.rust-lang.org/cargo/reference/unstable.html#build-std-features>.)

Example usage and output:

```
fn main() {
    use std::any::{Any, TypeId};
    dbg!(TypeId::of::<usize>(), drop::<usize>.type_id());
}
```

```
TypeId::of::<usize>() = TypeId(0x763d199bccd319899208909ed1a860c6 = usize)
drop::<usize>.type_id() = TypeId(0xe6a34bd13f8c92dd47806da07b8cca9a = core::mem::drop<usize>)
```

Also added feature declarations for the existing `debug_refcell` feature
so it is usable from the `rust.std-features` option of `config.toml`.
2025-02-11 18:42:19 -08:00
Jubilee Young
d97bde059a Revert "Stabilize extended_varargs_abi_support"
This reverts commit 685f189b43.
2025-02-11 17:22:27 -08:00
Eric Huss
8c24c0a023 Remove the common prelude module
This fixes the issues described in
https://github.com/rust-lang/rust/issues/136102. Primarily, this
resolves some issues with how the documentation for the prelude is
generated:

- It avoids showing "unstable" for macros in the prelude that are
  actually stable.
- Avoids duplication of some pages due to the previous lack of
  `doc(no_inline)`.
- Makes the different edition preludes consistent, and sets a pattern
  that can be used by future editions.

We may need to rearrange these modules in the future if we decide to
remove anything from the prelude again. If we do, I think we should look
into a different solution that avoids the documentation problems.
2025-02-11 13:04:27 -08:00
Josh Triplett
bc59397f8f Document that locking a file fails on Windows if the file is opened only for append 2025-02-11 21:11:05 +01:00
Josh Triplett
16abb39c9d Reword file lock documentation to clarify advisory vs mandatory
Remove the word "advisory", and make it more explicit that the lock may
be advisory or mandatory depending on platform.
2025-02-11 21:11:05 +01:00
Matthias Krüger
45a0ec81ea
Rollup merge of #136354 - hkBst:patch-34, r=ibraheemdev
Update docs for impl keyword

This started as a fix for #79878, but also introduces some structure (headings), and elaborates a tiny bit on impl Trait syntax.
2025-02-11 18:04:40 +01:00
Marijn Schouten
166680c480 Update docs for impl keyword 2025-02-11 08:04:32 +01:00
Jacob Pratt
2996cfdcc3
Rollup merge of #136704 - benschulz:patch-1, r=ibraheemdev
Improve examples for file locking

The `lock` and `try_lock` documentation states that "if the file not open for writing, it is unspecified whether this function returns an error." With this change, the examples use `File::create` instead of `File::open`, eliminating the possibility of someone blindly copying code with unspecified behavior.
2025-02-11 01:02:40 -05:00
Thalia Archibald
593c88fc49 Fix long lines which rustfmt fails to format
rustfmt fails to format this match expression, because it has several
long string literals over the maximum line width. This seems to exhibit
rustfmt issues #3863 (Gives up on chains if any line is too long) and
#3156 (Fail to format match arm when other arm has long line).
2025-02-10 18:51:29 -08:00
Thalia Archibald
9e390b2995 Fix &&str and trailing commas in io::const_error! 2025-02-10 16:34:13 -08:00
Thalia Archibald
7edd034a1f Use io::const_error! when possible over io::Error::new 2025-02-10 16:20:21 -08:00
Matthias Krüger
ad92b850c6
Rollup merge of #136714 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.146

Exposes the error function so we can expose this in the standard library [1].

[1]: https://github.com/rust-lang/compiler-builtins/pull/753
2025-02-10 16:38:26 +01:00
Benoît du Garreau
321fab4337 Implement read*_exact for std:io::repeat
cc #136756
2025-02-10 13:43:12 +01:00
Jubilee
ffa8a96040
Rollup merge of #136805 - RalfJung:miri-win-delete-self, r=Noratrieb
ignore win_delete_self test in Miri

Follow-up to https://github.com/rust-lang/rust/pull/134679, fixes miri-test-libstd on Windows

Cc `@ChrisDenton` `@Mark-Simulacrum`
2025-02-10 00:51:58 -08:00
Jubilee
72f0205d28
Rollup merge of #136705 - compiler-errors:edition-library, r=jhpratt
Some miscellaneous edition-related library tweaks

Some library edition tweaks that can be done separately from upgrading the whole standard library to edition 2024 (which is blocked on getting the submodules upgraded, for example)
2025-02-10 00:51:54 -08:00
Jubilee
f471ce39fb
Rollup merge of #136552 - ChrisDenton:option-find-handle, r=Mark-Simulacrum
Use an `Option` for `FindNextFileHandle` in `ReadDir` instead of `INVALID_FILE_HANDLE` sentinel value

Sometimes we store an invalid handle when we don't want to return an error. We then check the handle before use in order to avoid actually using the invalid handle. However, using an `Option` for this is better and avoids us forgetting to check the handle is valid. This was noticed due to us closing the handle without checking for validity: bd6a6777f5/library/std/src/sys/pal/windows/fs.rs (L148-L151)
2025-02-10 00:51:53 -08:00
Ralf Jung
2f3c943f42 ignore win_delete_self test in Miri 2025-02-10 08:08:32 +01:00
Christopher Berner
82af73dd4c Stabilize file_lock 2025-02-09 13:55:42 -08:00
Michael Goulet
4312d7b541 Fix pattern matching mode changes and unsafe_op_in_unsafe_fn 2025-02-09 17:11:13 +00:00
Michael Goulet
a4e7f8f9bf Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
Michael Goulet
9c486a74da Mark link_section attr with unsafe 2025-02-09 17:10:50 +00:00
bors
124cc92199 Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum
Update bootstrap compiler and rustfmt

The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same
time.
2025-02-09 15:44:16 +00:00
bors
a26e97be88 Auto merge of #136754 - Urgau:rollup-qlkhjqr, r=Urgau
Rollup of 5 pull requests

Successful merges:

 - #134679 (Windows: remove readonly files)
 - #136213 (Allow Rust to use a number of libc filesystem calls)
 - #136530 (Implement `x perf` directly in bootstrap)
 - #136601 (Detect (non-raw) borrows of null ZST pointers in CheckNull)
 - #136659 (Pick the max DWARF version when LTO'ing modules with different versions )

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-09 12:54:26 +00:00
Jubilee
e7ad8cec96
Rollup merge of #136686 - bjoernager:master, r=jhpratt
Clean up `HashMap` and `HashSet` docs.

This commit makes some small, pedantic changes to the docs for `HashMap` and `HashSet`, which fixes that:

* "HashMap" is not always formatted as code (as in `HashMap`), and that
* `HashSet` sometimes references `HashMap` instead of itself.
2025-02-08 20:41:20 -08:00
Urgau
9530d243d7
Rollup merge of #136213 - erickt:fs, r=Mark-Simulacrum
Allow Rust to use a number of libc filesystem calls

This allows Rust on Fuchsia to use a number of function calls from libc:

* dirfd
* fdatasync
* flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN
* fstatat

cc #120426

try-job: dist-various-2
2025-02-09 00:37:27 +01:00
Urgau
34182470eb
Rollup merge of #134679 - ChrisDenton:rm-readonly, r=Mark-Simulacrum
Windows: remove readonly files

When calling `remove_file`, we shouldn't fail to delete readonly files. As the test makes clear, this make the Windows behaviour consistent with other platforms. This also makes us internally consistent with `remove_dir_all`.

try-job: x86_64-msvc-ext1
2025-02-09 00:37:26 +01:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Matthias Krüger
02b8bea084
Rollup merge of #135696 - joboet:move_pal_io, r=Noratrieb
std: move `io` module out of `pal`, get rid of `sys_common::io`

Part of #117276.

This does two related things:
1. It moves the platform-specific definitions for `IoSlice`, `IoSliceMut` and `is_terminal` out of `pal` and into `sys` and unifies some of them.
2. It gets rid of `sys_common::io`, moving the non-platform-specific test helpers into `std::test_helpers` and the buffer size definition to the new `sys::io` module.
2025-02-08 21:37:24 +01:00
bors
0148a2be13 Auto merge of #136713 - matthiaskrgr:rollup-sy6py39, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #135179 (Make sure to use `Receiver` trait when extracting object method candidate)
 - #136554 (Add `opt_alias_variances` and use it in outlives code)
 - #136556 ([AIX] Update tests/ui/wait-forked-but-failed-child.rs to accomodate exiting and idle processes.)
 - #136589 (Enable "jump to def" feature on rustc docs)
 - #136615 (sys: net: Add UEFI stubs)
 - #136635 (Remove outdated `base_port` calculation in std net test)
 - #136682 (Move two windows process tests to tests/ui)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-08 02:57:14 +00:00
Trevor Gross
38a8302616 Update compiler-builtins to 0.1.146
Exposes the error function so we can expose this in the standard
library [1].

[1]: https://github.com/rust-lang/compiler-builtins/pull/753
2025-02-07 20:58:28 +00:00
Matthias Krüger
0a33d7ccd1
Rollup merge of #136682 - ChrisDenton:move-win-proc-tests, r=joboet
Move two windows process tests to tests/ui

Spawning processes from std unit tests is not something it's well suited for so moving them into tests/ui is more robust and means we don't need to hack around `cmd.exe`.

Follow up to #136630
2025-02-07 21:31:04 +01:00
Matthias Krüger
353650332d
Rollup merge of #136635 - jieyouxu:base_port, r=joboet
Remove outdated `base_port` calculation in std net test

This was never modified since `std::net` was originally introduced in 395709ca6d, when at that time, each CI runner was running multiple jobs concurrently. This seems to have originally caused issues with jobs fighting over the same ports. This is not the case in the current CI infrastructure, so remove this relic in favor of a simple constant base port number.

I double-checked `19600` and nearby port numbers, and this isn't a well-known port number AFAICT[^1].

Closes #136633.

[^1]: At the time of writing.
2025-02-07 21:31:03 +01:00
Matthias Krüger
ca56709e78
Rollup merge of #136615 - Ayush1325:uefi-net-unsupported, r=joboet
sys: net: Add UEFI stubs

- Just a copy of sys/net/unsupported.
- Will make the future net PRs easier to review.
- The reason for a separate folder instead of standalone file is that UEFI has separate the protocols for v4 and v6, and thus will need some abstractions to implement the Rust interface.

r? ``@jhpratt``
2025-02-07 21:31:02 +01:00
Ben Schulz
8ea20c82bb
Improve examples for file locking 2025-02-07 20:36:32 +01:00
Matthias Krüger
26b288760e
Rollup merge of #135945 - estebank:useless-parens, r=compiler-errors
Remove some unnecessary parens in `assert!` conditions

While working on #122661, some of these started triggering our "unnecessary parens" lints due to a change in the `assert!` desugaring. A cursory search identified a few more. Some of these have been carried from before 1.0, were a bulk rename from the previous name of `assert!` left them in that state. I went and removed as many of these unnecessary parens as possible in order to have fewer annoyances in the future if we make the lint smarter.
2025-02-07 18:26:26 +01:00
joboet
7433ba62b1
std: get rid of sys_common::io 2025-02-07 16:54:07 +01:00
joboet
a9df224ac7
std: move io module out of pal 2025-02-07 16:54:07 +01:00
Gabriel Bjørnager Jensen
450b864d69 Clean up 'HashMap' and 'HashSet' docs; 2025-02-07 13:40:23 +01:00
Matthias Krüger
d9f95ecd09
Rollup merge of #136634 - bjoernager:const-mut-cursor, r=m-ou-se
Stabilise `Cursor::{get_mut, set_position}` in `const` scenarios.

Closes: #130801

This PR stabilises the `const_mut_cursor` feature gate.
2025-02-07 12:02:00 +01:00
Chris Denton
630727006f
Move two windows process tests to tests/ui 2025-02-07 10:43:50 +00:00
Esteban Küber
3815ed63ed Remove some unnecessary parens in assert! conditions
While working on #122661, some of these started triggering our "unnecessary parens" lints due to a change in the `assert!` desugaring. A cursory search identified a few more. Some of these have been carried from before 1.0, were a bulk rename from the previous name of `assert!` left them in that state. I went and removed as many of these unnecessary parens as possible in order to have fewer annoyances in the future if we make the lint smarter.
2025-02-06 22:28:44 +00:00
Matthias Krüger
0fb72ee57c
Rollup merge of #136152 - Urgau:stabilize-map_many_mut, r=joshtriplett
Stabilize `map_many_mut` feature

This PR stabilize `HashMap::get_many_mut` as `HashMap::get_disjoint_mut` and `HashMap::get_many_unchecked_mut` as `HashMap::get_disjoint_unchecked_mut` per FCP.

FCP at https://github.com/rust-lang/rust/issues/97601#issuecomment-2532710423
Fixes #97601
r? libs
2025-02-06 21:56:26 +01:00
Gabriel Bjørnager Jensen
4500ed5256 Stabilise 'Cursor::{get_mut, set_position}' in 'const' scenarios; 2025-02-06 11:54:25 +01:00
Jieyou Xu
9e345fd3ed tests(std/net): remove outdated base_port calculation
This was never modified since `std::net` was originally introduced, when
each CI job was running multiple jobs concurrently which caused issues
with fighting over the same ports. This is not the case in the current
CI infrastructure, so remove this relic.
2025-02-06 18:51:54 +08:00
许杰友 Jieyou Xu (Joe)
9c5f025c18 tests(std): don't output to std{out,err} in test_creation_flags and test_proc_thread_attributes 2025-02-06 17:18:00 +08:00
Ayush Singh
46272855a6
sys: net: Add UEFI stubs
- Just a copy of sys/net/unsupported.
- Will make the future net PRs easier to review.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-02-06 10:25:40 +05:30
许杰友 Jieyou Xu (Joe)
f30ce21602
Rollup merge of #136537 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.145

This includes https://github.com/rust-lang/compiler-builtins/pull/752 which is required for LLVM 20.
2025-02-05 19:09:37 +08:00
许杰友 Jieyou Xu (Joe)
ff339fbbf4
Rollup merge of #136449 - joboet:move_pal_net, r=ChrisDenton
std: move network code into `sys`

As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules.

I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2025-02-05 19:09:35 +08:00
许杰友 Jieyou Xu (Joe)
cc58e8b7ec
Rollup merge of #136418 - Ayush1325:command-env, r=jhpratt
uefi: process: Add support for command environment variables

Set environment variables before launching the process and restore the prior variables after the program exists.

This is the same implementation as the one used by UEFI Shell Execute [0].

[0]: 2d2642f483/ShellPkg/Application/Shell/ShellProtocol.c (L1700)
2025-02-05 19:09:35 +08:00
Chris Denton
bd6a6777f5
Use Option for FindNextFileHandle 2025-02-04 18:11:59 +00:00
Ralf Jung
04e7a10af6 intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic 2025-02-04 16:27:29 +01:00
bors
01e4f19cc8 Auto merge of #136534 - jhpratt:rollup-dnz57dq, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - #136398 (add UnsafeCell direct access APIs)
 - #136465 (Some `rustc_middle` cleanups)
 - #136479 (std::fs: further simplify dirent64 handling)
 - #136504 (Fix last compare-mode false negatives in tests)
 - #136511 (Add `cast_signed` and `cast_unsigned` methods for `NonZero` types)
 - #136518 (Add note about `FnPtr` trait being exposed as public bound)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-04 14:59:25 +00:00
Trevor Gross
90fee92fcc Update compiler-builtins to 0.1.145
This includes [1] which is required for LLVM 20.

[1]: https://github.com/rust-lang/compiler-builtins/pull/752
2025-02-04 11:49:01 +00:00
Jacob Pratt
1baf59e5f6
Rollup merge of #136479 - RalfJung:dirent64, r=tgross35
std::fs: further simplify dirent64 handling

Follow-up to https://github.com/rust-lang/rust/pull/134678.

r? `@tgross35`
2025-02-04 05:38:04 -05:00
Jacob Pratt
d31e137d6a
Rollup merge of #136167 - pitaj:new_range, r=Nadrieril
Implement unstable `new_range` feature

Switches `a..b`, `a..`, and `a..=b` to resolve to the new range types.

For rust-lang/rfcs#3550
Tracking issue #123741

also adds the re-export that was missed in the original implementation of `new_range_api`
2025-02-04 05:36:52 -05:00
Jacob Pratt
d2aa3dec8a
Rollup merge of #135621 - bjorn3:move_tests_to_stdtests, r=Noratrieb
Move some std tests to integration tests

Unit tests directly inside of standard library crates require a very fragile way of building that is hard to reproduce outside of bootstrap.

Follow up to https://github.com/rust-lang/rust/pull/133859
2025-02-04 05:36:50 -05:00
Matthias Krüger
f2b7a299d2
Rollup merge of #136289 - Pyr0de:oncecell-docs, r=tgross35
OnceCell & OnceLock docs: Using (un)initialized consistently

Changed
* `set` / `initialize` / `full` to `initialized state`
* `uninitialize` / `empty` to `uninitialized state`
* `f` to `f()`
* Added explaination of `uninitialized state` & `initialized state`

[OnceCell Docs](https://doc.rust-lang.org/nightly/std/cell/struct.OnceCell.html)
[OnceLock Docs](https://doc.rust-lang.org/nightly/std/sync/struct.OnceLock.html)

Fixes #85716
``@rustbot`` label +A-docs
2025-02-03 21:11:33 +01:00
Pyrode
f8b01b3d19 OnceCell & OnceLock docs: Using (un)initialized consistently 2025-02-03 17:48:39 +05:30
Ralf Jung
49ea67aa91 std::fs: further simplify dirent64 handling 2025-02-03 12:05:23 +01:00
bjorn3
cc7e3a6228 Remove stabilized feature gate 2025-02-02 18:28:08 +00:00
joboet
4f834264ab
std: move network code into sys
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules.

I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2025-02-02 19:12:06 +01:00
Matthias Krüger
48aede0773
Rollup merge of #134272 - RalfJung:destabilize-rustc_encodable_decodable, r=oli-obk
Remove rustc_encodable_decodable feature

This has been shown in future-compat reports since Rust 1.79 (https://github.com/rust-lang/rust/pull/116016), released June 2024. Let's see if crater still finds any issues.

Part of https://github.com/rust-lang/rust/issues/134301.

Cc ``@rust-lang/libs-api``
2025-02-02 18:05:22 +01:00
Matthias Krüger
555dd6fe76
Rollup merge of #136133 - hkBst:patch-23, r=ibraheemdev
Fix sentence in process::abort
2025-02-02 12:31:55 +01:00
Ayush Singh
1ed804ddb9
uefi: process: Add support for command environment variables
Set environment variables before launching the process and restore the
prior variables after the program exists.

This is the same implementation as the one used by UEFI Shell Execute [0].

[0]: 2d2642f483/ShellPkg/Application/Shell/ShellProtocol.c (L1700)

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-02-02 08:26:20 +05:30
Matthias Krüger
cbcb695f9e
Rollup merge of #136360 - slanterns:once_wait, r=tgross35
Stabilize `once_wait`

Closes: https://github.com/rust-lang/rust/issues/127527.

`@rustbot` label: +T-libs-api

r? libs-api
2025-02-01 16:41:04 +01:00
Matthias Krüger
9dfdef618c
Rollup merge of #135684 - ranger-ross:mutex-docs, r=joboet
docs: Documented Send and Sync requirements for Mutex + MutexGuard

This an attempt to continue where #123225 left off.

I did some light clean up from the work done in that PR.
I also documented the `!Send` + `Sync` implementations for `MutexGuard` to the best of my knowledge.
Let me know if I got anything wrong 😄

fixes #122856

cc: ``@IoaNNUwU``

r? ``@joboet``
2025-02-01 16:41:03 +01:00
Marijn Schouten
06171066d2 Fix sentence in process::abort 2025-02-01 13:32:01 +01:00
Ross Sullivan
3d84a49c37
docs: Documented Send and Sync requirements for Mutex + MutexGuard 2025-02-01 14:20:03 +09:00
Slanterns
6fa6168e71
stabilize once_wait 2025-02-01 02:10:02 +08:00
Tommaso Allevi
ca58e23ede
Update fs.rs 2025-01-31 11:01:37 +01:00
Peter Jaszkowiak
95eaadc773 std::range 2025-01-30 20:37:56 -07:00
Matthias Krüger
867317835d
Rollup merge of #136288 - joshtriplett:would-you-could-you-with-some-locks--would-you-could-you-in-some-docs, r=m-ou-se
Improve documentation for file locking

Add notes to each method stating that locks get dropped on close.

Clarify the return values of the try methods: they're only defined if
the lock is held via a *different* file handle/descriptor. That goes
along with the documentation that calling them while holding a lock via
the *same* file handle/descriptor may deadlock.

Document the behavior of unlock if no lock is held.

r? `@m-ou-se`
(Documentation changes requested in https://github.com/rust-lang/rust/issues/130994 .)
2025-01-30 20:47:09 +01:00
Matthias Krüger
55c7a02a8b
Rollup merge of #135475 - Ayush1325:uefi-absolute-path, r=jhpratt
uefi: Implement path

This PR is split off from https://github.com/rust-lang/rust/pull/135368 to reduce noise.

UEFI paths can be of 4 types:
1. Absolute Shell Path: Uses shell mappings
2. Absolute Device Path: this is what we want
3. Relative root: path relative to the current root.
4. Relative

Absolute shell path can be identified with `:` and Absolute Device path can be identified with `/`. Relative root path will start with `\`.

The algorithm is mostly taken from edk2 UEFI shell implementation and is somewhat simple. Check for the path type in order.

For Absolute Shell path, use `EFI_SHELL->GetDevicePathFromMap` to get a BorrowedDevicePath for the volume.

For Relative paths, we use the current working directory to construct the new path.

BorrowedDevicePath abstraction is needed to interact with `EFI_SHELL->GetDevicePathFromMap` which returns a Device Path Protocol with the lifetime of UEFI shell.

Absolute Shell paths cannot exist if UEFI shell is missing.

cc `@nicholasbishop`
2025-01-30 20:47:04 +01:00
Marijn Schouten
9cb74323aa
Improve instant docs 2025-01-30 15:03:50 +01:00
Josh Triplett
fb1ad2fe02 Improve documentation for file locking
Add notes to each method stating that locks get dropped on close.

Clarify the return values of the try methods: they're only defined if
the lock is held via a *different* file handle/descriptor. That goes
along with the documentation that calling them while holding a lock via
the *same* file handle/descriptor may deadlock.

Document the behavior of unlock if no lock is held.
2025-01-30 11:48:26 +01:00
bors
0cc4f4f7b8 Auto merge of #136248 - matthiaskrgr:rollup-leaxgfd, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #133382 (Suggest considering casting fn item as fn pointer in more cases)
 - #136092 (Test pipes also when not running on Windows and Linux simultaneously)
 - #136190 (Remove duplicated code in RISC-V asm bad-reg test)
 - #136192 (ci: remove unused windows runner)
 - #136205 (Properly check that array length is valid type during built-in unsizing in index)
 - #136211 (Update mdbook to 0.4.44)
 - #136212 (Tweak `&mut self` suggestion span)
 - #136214 (Make crate AST mutation accessible for driver callback)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-29 16:18:29 +00:00
Matthias Krüger
da7980b315
Rollup merge of #136092 - tbu-:pr_io_pipe_test, r=joboet
Test pipes also when not running on Windows and Linux simultaneously

Fixes https://github.com/rust-lang/rust/pull/135635#pullrequestreview-2574184488.

Based on top of #135635 to avoid merge conflicts.
2025-01-29 15:29:30 +01:00
León Orell Valerian Liehr
7e60f276ce
Rollup merge of #136186 - Ayush1325:uefi-process-args-fix, r=nicholasbishop,Noratrieb
uefi: process: Fix args

- While working on process env support, I found that args were currently broken. Not sure how I missed it in the PR, but well here is the fix.
- Additionally, no point in adding space at the end of args.
2025-01-29 06:03:25 +01:00
Erick Tryzelaar
719127c6d5 Allow Rust to use a number of libc filesystem calls
This allows Rust on Fuchsia to use a number of function calls from libc:

* dirfd
* fdatasync
* flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN
* fstatat
2025-01-28 20:48:39 +00:00
Pavel Grigorenko
1abc853562 Stabilize get_many_mut as get_disjoint_mut
* Renames the methods:
	* `get_many_mut` -> `get_disjoint_mut`
	* `get_many_unchecked_mut` -> `get_disjoint_unchecked_mut`
* Does not rename the feature flag: `get_many_mut`
* Marks the feature as stable
* Renames some helper stuff:
	* `GetManyMutError` -> `GetDisjointMutError`
	* `GetManyMutIndex` -> `GetDisjointMutIndex`
	* `get_many_mut_helpers` -> `get_disjoint_mut_helpers`
	* `get_many_check_valid` -> `get_disjoint_check_valid`

This only touches slice methods.
HashMap's methods and feature gates are not renamed here
(nor are they stabilized).
2025-01-28 17:59:31 +03:00
Ayush Singh
9c4fd25f27
uefi: process: Fix args
- While working on process env support, I found that args were currently
  broken. Not sure how I missed it in the PR, but well here is the fix.
- Additionally, no point in adding space at the end of args.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-28 19:10:28 +05:30
Matthias Krüger
9a192b254c
Rollup merge of #136012 - hkBst:patch-22, r=workingjubilee,tgross35
Document powf and powi values that are always 1.0

fixes bug #90429
2025-01-28 14:23:25 +01:00
Marijn Schouten
3d6c6fa04e Document powf and powi calls that always return 1.0 2025-01-28 08:24:39 +01:00
Urgau
885278b9eb Stabilize HashMap::get_many_mut as HashMap::get_disjoint_mut
as well as `HashMap::get_many_unchecked_mut` to
`HashMap::get_disjoint_unchecked_mut`.
2025-01-27 19:28:12 +01:00
Guillaume Gomez
4d5c8bdc9d
Rollup merge of #135876 - usamoi:mpmc-doc, r=tgross35
fix doc for std::sync::mpmc

fix document of `std::sync::mpmc` (tracked in https://github.com/rust-lang/rust/issues/126840)
2025-01-27 15:38:25 +01:00
usamoi
05364239a8 fix doc for std::sync::mpmc 2025-01-27 11:42:16 +08:00
León Orell Valerian Liehr
2949f2a5ef
Rollup merge of #135635 - tbu-:pr_io_pipe, r=joboet
Move `std::io::pipe` code into its own file

Also update the docs for the new location, create a section "Platform-specific behavior", don't hide required imports for code examples.
2025-01-27 04:34:51 +01:00
bors
15c6f7e1a3 Auto merge of #136087 - jhpratt:rollup-tam1mzn, r=jhpratt
Rollup of 7 pull requests

Successful merges:

 - #133631 (Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only))
 - #134358 (compiler: Set `target_abi = "ilp32e"` on all riscv32e targets)
 - #135812 (Fix GDB `OsString` provider on Windows )
 - #135842 (TRPL: more backward-compatible Edition changes)
 - #135946 (Remove extra whitespace from rustdoc breadcrumbs for copypasting)
 - #135953 (ci.py: check the return code in `run-local`)
 - #136019 (Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-26 12:10:05 +00:00
Tobias Bucher
93d347d7d2 Test pipes also when not running on Windows and Linux simultaneously
Fixes https://github.com/rust-lang/rust/pull/135635#pullrequestreview-2574184488.
2025-01-26 12:48:33 +01:00
Tobias Bucher
ad28cbb423 Update std::io::{pipe, PipeReader, PipeWriter} docs the new location
Also create a section "Platform-specific behavior", don't hide required
imports for code examples.
2025-01-26 12:42:52 +01:00
Tobias Bucher
68e983fcf7 Move std::io::pipe code into its own file 2025-01-26 12:40:36 +01:00
bjorn3
05cbf03d8f Move env modifying tests to a separate integration test 2025-01-26 10:28:05 +00:00
bjorn3
52907d713a Fix for SGX 2025-01-26 10:28:05 +00:00
bjorn3
e76d0b8193 Fix benchmarking of libstd 2025-01-26 10:28:05 +00:00
bjorn3
b8ae372e48 Move std::sync unit tests to integration tests
This removes two minor OnceLock tests which test private methods. The
rest of the tests should be more than enough to catch mistakes in those
private methods. Also makes ReentrantLock::try_lock public. And finally
it makes the mpmc tests actually run.
2025-01-26 10:28:05 +00:00
bjorn3
332fb7e6f1 Move std::thread_local unit tests to integration tests 2025-01-26 10:28:05 +00:00
bjorn3
4ce917dfd5 Move std::time unit tests to integration tests 2025-01-26 10:28:04 +00:00
bjorn3
b8fa843a1a Move std::path unit tests to integration tests 2025-01-26 10:28:04 +00:00
bjorn3
09c4dbf7fb Move std::panic unit tests to integration tests 2025-01-26 10:28:04 +00:00
bjorn3
9baeb45309 Move std::num unit tests to integration tests 2025-01-26 10:28:04 +00:00
bjorn3
29166cd617 Move std float unit tests to integration tests 2025-01-26 10:28:04 +00:00
bjorn3
03d44a641b Move std::error unit tests to integration tests 2025-01-26 10:28:04 +00:00
bjorn3
e00cbf304c Move std::env unit tests to integration tests 2025-01-26 10:28:04 +00:00
Jacob Pratt
0d0e841594
Rollup merge of #133631 - flba-eb:add_nto_qnx71_iosock_support, r=workingjubilee
Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only)

Changes of this pull request:

1. Refactor code for qnx nto targets to share more code in file `nto_qnx.rs`
1. Add support for an additional network stack on nto qnx 7.1.

   QNX 7.1 supports two network stacks:

   1. `io-pkt`, which is default
   2. `io-sock`, which is optional on 7.1 but default in QNX 8.0

   As one can see in the [io-sock migration notes](https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.io_sock/topic/migrate_app.html), this changes the libc API in a way similar to e.g. linux-gnu vs. linux-musl.

   This change adds a new target which has a different value for `target_env`, so that e.g. libc can distinguish between both APIs.

2. Add initial support for QNX 8.0, thanks to AkhilTThomas. As it turned out, the problem with forking many processes still exists in QNX 8.0. Because if this, we are now using it for any QNX version (i.e. not check for `target_env` anymore).
2025-01-26 01:51:14 -05:00
Chris Denton
962ebf0a48
Windows: Test that deleting a running binary fails 2025-01-26 06:17:12 +00:00
Chris Denton
50522fad48
Update platform information for remove_file 2025-01-26 05:42:58 +00:00
Chris Denton
457e528794
Windows: remove readonly files 2025-01-26 05:42:37 +00:00
Jacob Pratt
b58221ec9d
Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-Simulacrum
Update emscripten std tests

This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten.

Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2025-01-25 23:27:00 -05:00
Josh Triplett
687607c31e Improve and expand documentation of pipes
- Simplify some of the language
- Minor grammar fixes
- Don't imply that pipes *only* work across multiple processes; instead,
  *suggest* that they're typically used across two or more separate
  processes.
- Specify that portable applications cannot use multiple readers or
  multiple writers for messages larger than a byte, due to potential
  interleaving.
- Remove no-longer-referenced footnote URLs.
2025-01-25 22:15:54 +02:00
Huang Qi
b691e9f2e0 Correct comment for FreeBSD and DragonFly BSD in unix/thread
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-25 20:09:36 +08:00
Matthias Krüger
7a79024ef4
Rollup merge of #135991 - no1wudi:master, r=thomcc
Fix set_name in thread mod for NuttX

Replace `pthread_set_name_np` with `pthread_setname_np` for NuttX in the `set_name` function, this change aligns the implementation with the correct API available on NuttX

This patch ensures thread naming works correctly on NuttX platforms.

See also:
0f9f8c91ad/src/unix/nuttx/mod.rs (L562)
8f3a2a6f76/include/pthread.h (L511-L514)
2025-01-25 08:03:35 +01:00
Matthias Krüger
0741cc0ea7
Rollup merge of #135415 - Harshit933:hard-link-error, r=ChrisDenton
Add `File already exists` error doc to `hard_link` function

## Description
If the link path already exists, the error `AlreadyExists` is returned. This commit adds this error to the docs.

I tested it with the current rust master version, this error was returned when there is already a link for the file is present.
This was the error returned:
```
[harshit:../Desktop/rust_compiler_testing/hard_link (master|…5)] cargo +stage1 run
   Compiling hard_link v0.1.0 (/home/harshit/Desktop/rust_compiler_testing/hard_link)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/hard_link`
Err(Os { code: 17, kind: AlreadyExists, message: "File exists" })
```
This is my first PR on rust, any suggestions on which issue I can take next are most welcome 😄

Fixes #130117
2025-01-24 23:25:41 +01:00
Harshit Verma
ab274630b9 Add File already exists error doc to hard_link function
If the link path already exists, the error `AlreadyExists`
is returned. This commit adds this error to the docs.
2025-01-24 22:43:33 +05:30
Huang Qi
e170c9dec0 Fix set_name in thread mod for NuttX
Replace `pthread_set_name_np` with `pthread_setname_np` for NuttX in the `set_name` function,
this change aligns the implementation with the correct API available on NuttX

This patch ensures thread naming works correctly on NuttX platforms.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-24 21:21:30 +08:00
AkhilTThomas
3f045c9d2e add nto80 x86-64 and aarch64 target
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24 12:41:49 +00:00
Florian Bartels
efe53ddd58 Add support for QNX 7.1 with io-sock on x64
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24 12:32:20 +00:00
Florian Bartels
84c80151cf Add new target for supporting Neutrino QNX 6.1 with io-socket network stack on aarch64
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24 12:32:07 +00:00
bjorn3
a20996c180 Update a bunch of comments from before wasi support was added 2025-01-24 09:25:34 +00:00
bjorn3
88ff147c56 Remove a bunch of emscripten test ignores
They are either outdated as emscripten now supports i128 or they are
subsumed by #[cfg_attr(not(panic = "unwind"), ignore]
2025-01-24 09:25:34 +00:00
bjorn3
d0a70d9328 Fix testing of the standard library with Emscripten
This does need EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" avoid several OOMs.
2025-01-24 09:25:34 +00:00
Matthias Krüger
08d5b2303a
Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushi
Implement `ByteStr` and `ByteString` types

Approved ACP: https://github.com/rust-lang/libs-team/issues/502
Tracking issue: https://github.com/rust-lang/rust/issues/134915

These types represent human-readable strings that are conventionally,
but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using
escape sequences, and the `Display` impl uses the Unicode replacement
character.

This is a minimal implementation of these types and associated trait
impls. It does not add any helper methods to other types such as `[u8]`
or `Vec<u8>`.

I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`,
when those would be the second implementation for a type (counting the
`T` impl), to avoid potential inference failures. We can attempt to add
more impls later in standalone commits, and run them through crater.

In addition to the `bstr` feature, I've added a `bstr_internals` feature
for APIs provided by `core` for use by `alloc` but not currently
intended for stabilization.

This API and its implementation are based *heavily* on the `bstr` crate
by Andrew Gallant (`@BurntSushi).`

r? `@BurntSushi`
2025-01-23 19:54:23 +01:00
Matthias Krüger
3962bfaeed
Rollup merge of #135856 - fmease:library-mv-obj-save-dyn-compat-ii, r=tgross35
Library: Finalize dyn compatibility renaming

Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME.

Follow-up to #130827.
Part of #130852.
2025-01-22 20:37:28 +01:00
Matthias Krüger
0bdc1015cc
Rollup merge of #135837 - ChrisDenton:trunc, r=Noratrieb
Remove test panic from File::open

Fixes #135831
2025-01-22 20:37:27 +01:00
León Orell Valerian Liehr
9e98d25729
Library: Finalize dyn compatibility renaming 2025-01-22 04:46:55 +01:00
Chris Denton
fed5f98c47
Remove test panic from File::open 2025-01-21 17:31:17 +00:00
Marijn Schouten
fdc80af5c5
fix OsString::from_encoded_bytes_unchecked description 2025-01-21 14:36:18 +01:00
bors
b605c65b6e Auto merge of #135224 - wyfo:tls-panic-outline, r=cuviper
Outline panicking code for `LocalKey::with`

See https://github.com/rust-lang/rust/pull/115491 for prior related modifications.

https://godbolt.org/z/MTsz87jGj shows a reduction of the code size for TLS accesses.
2025-01-21 02:23:15 +00:00
许杰友 Jieyou Xu (Joe)
e7f53663de
Rollup merge of #135626 - clubby789:env-note, r=ibraheemdev
doc: Point to methods on `Command` as alternatives to `set/remove_var`

Make these methods more discoverable, as configuring a child process is a common reason for manipulating the environment.
2025-01-20 21:45:04 +08:00
许杰友 Jieyou Xu (Joe)
e1e26f339d
Rollup merge of #135491 - RalfJung:remove-dead-rustc_allowed_through_unstable_modules, r=Mark-Simulacrum
Remove dead rustc_allowed_through_unstable_modules for std::os::fd contents

As far as I was able to reconstruct, the history here is roughly as follows:
- https://github.com/rust-lang/rust/pull/99723 added some `rustc_allowed_through_unstable_modules` to the types in `std::os::fd::raw` since they were accessible on stable via the unstable `std::os::wasi::io::AsRawFd` path. (This was needed to fix https://github.com/rust-lang/rust/issues/99502.)
- Shortly thereafter, https://github.com/rust-lang/rust/pull/98368 re-organized things so that instead of re-exporting from an internal  `std::os::wasi::io::raw`,   `std::os::wasi::io::AsRawFd` is now directly re-exported from `std::os::fd`. This also made `library/std/src/os/wasi/io/raw.rs` entirely dead code as far as I can tell, it's not imported by anything any more.
- Shortly thereafter, https://github.com/rust-lang/rust/pull/103308 stabilizes `std::os::wasi::io`, so `rustc_allowed_through_unstable_modules` is not needed any more to access `std::os::wasi::io::AsRawFd`. There is even a comment in `library/std/src/os/wasi/io/raw.rs` saying the attribute can be removed now, but that file is dead code so it is not touched as part of the stabilization.

I did a grep for `pub use crate::os::fd` and all the re-exports I could find are in stable modules. So given all that, we can remove the  `rustc_allowed_through_unstable_modules` (hoping they are not also re-exported somewhere else, it's really hard to be sure about this).

I have checked that std still builds after this PR on the wasm32-wasip2 target.
2025-01-20 12:38:32 +08:00
许杰友 Jieyou Xu (Joe)
e5b85035fe
Rollup merge of #135446 - klensy:panic_immediate_abort_ext, r=Mark-Simulacrum
further improve panic_immediate_abort by removing rtprintpanic! messages

Reduces binary size using `panic_immediate_abort` by removing strings used by `rtprintpanic!`.

for `main.rs`
```rust
fn main() {
    println!("Hello, world!");
}
```
with `Cargo.toml`
```toml
[package]
name = "tst"
version = "0.1.0"
edition = "2024"

[dependencies]

[profile.release]
lto = true
codegen-units = 1
panic = "abort"

```

and build with `RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cargo +stage-1 b -r -Z build-std=std,panic_abort -Z build-std-features=optimize_for_size,panic_immediate_abort` for `x86_64-unknown-linux-gnu`

This reduces size:
| before |  after | type |
| - | - | - |
| 25256 | 21880 | unstripped |
| 18072 | 15288 | stripped |
2025-01-20 12:38:32 +08:00
Matthias Krüger
23fb4f22b3
Rollup merge of #135661 - tgross35:stabilize-float_next_up_down, r=scottmcm
Stabilize `float_next_up_down`

FCP completed at [1].

For `f16` and `f128`, this just removes the gates in comments and doctests.

Closes https://github.com/rust-lang/rust/issues/91399

[1]: https://github.com/rust-lang/rust/issues/91399#issuecomment-2598734570
2025-01-18 13:58:06 +01:00
Matthias Krüger
508c72b81e
Rollup merge of #135583 - NobodyXu:move-pipe-to-io, r=joshtriplett
Move `std::pipe::*` into `std::io`

Resolve concern from final comment period https://github.com/rust-lang/rust/issues/127154#issuecomment-2590419895
2025-01-18 13:58:03 +01:00
Trevor Gross
366cecacdd Stabilize float_next_up_down
FCP completed at [1].

Closes https://github.com/rust-lang/rust/issues/91399

[1]: https://github.com/rust-lang/rust/issues/91399#issuecomment-2598734570
2025-01-17 23:01:10 +00:00
Jiahao XU
81d70f92ab
Fix import of pipe in kernel_copy.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-18 00:44:44 +11:00
clubby789
f7c2d1194d doc: Point to methods on Command as alternatives to set/remove_var 2025-01-17 12:53:58 +00:00
Matthias Krüger
dbbbed0579
Rollup merge of #135556 - AeonSolstice:patch-1, r=tgross35
Clarify note in `std::sync::LazyLock` example

I doubt most people know what it means, as I did not until a week ago. In the current form, it seems like a `TODO:`.
2025-01-16 17:00:47 +01:00
Jiahao XU
efe888871c
Move std::pipe::* into std::io
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-17 01:30:05 +11:00
Ayush Singh
c1790b14bc
uefi: Implement path
UEFI paths can be of 4 types:
1. Absolute Shell Path: Uses shell mappings
2. Absolute Device Path: this is what we want
3: Relative root: path relative to the current root.
4: Relative

Absolute shell path can be identified with `:` and Absolute Device path
can be identified with `/`. Relative root path will start with `\`.

The algorithm is mostly taken from edk2 UEFI shell implementation and is
somewhat simple. Check for the path type in order.

For Absolute Shell path, use `EFI_SHELL->GetDevicePathFromMap` to
get a BorrowedDevicePath for the volume.

For Relative paths, we use the current working directory to construct
the new path.

BorrowedDevicePath abstraction is needed to interact with
`EFI_SHELL->GetDevicePathFromMap` which returns a Device Path Protocol
with the lifetime of UEFI shell.

Absolute Shell paths cannot exist if UEFI shell is missing.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-16 10:19:22 +05:30
Aeon
c4a5e12567
Clarify note in std::sync::LazyLock example 2025-01-15 16:08:22 -05:00
Guillaume Gomez
4c26dc5d3d
Rollup merge of #132654 - joboet:lazy_main, r=ChrisDenton
std: lazily allocate the main thread handle

https://github.com/rust-lang/rust/pull/123550 eliminated the allocation of the main thread handle, but at the cost of greatly increased complexity. This PR proposes another approach: Instead of creating the main thread handle itself, the runtime simply remembers the thread ID of the main thread. The main thread handle is then only allocated when it is used, using the same lazy-initialization mechanism as for non-runtime use of `thread::current`, and the `name` method uses the thread ID to identify the main thread handle and return the correct name ("main") for it.

Thereby, we also allow accessing `thread::current` before main: as the runtime no longer tries to install its own handle, this will no longer trigger an abort. Rather, the name returned from `name` will only be "main" after the runtime initialization code has run, but I think that is acceptable.

This new approach also requires some changes to the signal handling code, as calling `thread::current` would now allocate when called on the main thread, which is not acceptable. I fixed this by adding a new function (`with_current_name`) that performs all the naming logic without allocation or without initializing the thread ID (which could allocate on some platforms).

Reverts #123550, CC ``@GnomedDev``
2025-01-15 16:30:08 +01:00
Jacob Pratt
56eb7bd9a9
Rollup merge of #134678 - zachs18:offset-ptr-update, r=tgross35
Update `ReadDir::next` in `std::sys::pal::unix::fs` to use `&raw const (*p).field` instead of `p.byte_offset().cast()`

Since https://github.com/rust-lang/reference/pull/1387 and https://github.com/rust-lang/rust/pull/117572, `&raw mut (*p).field`/`addr_of!((*p).field)` is defined to have the same inbounds preconditions as `ptr::offset`/`ptr::byte_offset`. I.e. `&raw const (*p).field` does not require that `p: *const T` point to a full `size_of::<T>()` bytes of memory, only that `p.byte_add(offset_of!(T, field))` is defined.

The old comment "[...] we don't even get to use `&raw const (*entry_ptr).d_name` because that operation requires the full extent of *entry_ptr to be in bounds of the same allocation, which is not necessarily the case here [...]" is now outdated, and the code can be simplified to use `&raw const (*entry_ptr).field`.

-------

There should be no behavior differences from this PR.

The `: *const dirent64` on line 716 and the `const _: usize = mem::offset_of!(dirent64, $field);` and comment on lines 749-751 are just sanity checks and should not affect semantics.

Since the `offset_ptr!` macro is only called three times, and all with the same local variable entry_ptr, I just used the local variable directly in the macro instead of taking it as an input, and renamed the macro to `entry_field_ptr!`.

The whole macro could also be removed and replaced with just using `&raw const (*entry_ptr).field`  in the three places, but the comments on the macro seemed worthwhile to keep.
2025-01-15 04:08:12 -05:00
Zachary S
58d6301cad Update ReadDir::next in std::sys::pal::unix::fs to use &raw const (*ptr).field instead of ptr.offset(...).cast().
Also, the macro is only called three times, and all with the same local variable entry_ptr, so just use the local variable directly,
and rename the macro to entry_field_ptr.
2025-01-14 23:47:24 -06:00
Trevor Gross
f6a2db8e1b Update compiler-builtins to 0.1.143
0.1.142 fixes an issue parsing optimization flags, and 0.1.143 changes
`__rust_[ui]128_*` builtins to use a C-safe signature.
2025-01-15 04:02:19 +00:00
Trevor Gross
fcc34b2c44 Update compiler-builtins to 0.1.141
0.1.141 syncs changes from `libm`. Most of the `libm` changes are
testing- or configuration-related.
2025-01-14 18:36:45 +00:00
Ralf Jung
f3cf39f3be wasi/io: remove dead files 2025-01-14 17:28:33 +01:00
Ralf Jung
c2ed284435 remove unnecessary rustc_allowed_through_unstable_modules 2025-01-14 17:10:44 +01:00
Ralf Jung
9ac62f972f remove Rustc{En,De}codable from library and compiler 2025-01-14 16:16:38 +01:00
Ralf Jung
4df78a07e5 make rustc_encodable_decodable feature properly unstable 2025-01-14 16:16:38 +01:00