Commit Graph

13830 Commits

Author SHA1 Message Date
Matthias Krüger
b961f25c21
Rollup merge of #121809 - tgross35:suggest-path-split-fixup, r=Amanieu
Remove doc aliases to PATH

Remove aliases for `split_paths` and `join_paths` as should have been done in <https://github.com/rust-lang/rust/pull/119748> (Bors merged the wrong commit).
2024-02-29 20:50:06 +01:00
Matthias Krüger
2fdcdd9025
Rollup merge of #121753 - mu001999:core/add_cfg, r=cuviper
Add proper cfg to keep only one AlignmentEnum definition for different target_pointer_widths

Detected by #121752

Only one AlignmentEnum would be used with a specified target_pointer_width
2024-02-29 20:50:03 +01:00
Matthias Krüger
419f7aeed6
Rollup merge of #121681 - jswrenn:nix-visibility-analysis, r=compiler-errors
Safe Transmute: Revise safety analysis

This PR migrates `BikeshedIntrinsicFrom` to a simplified safety analysis (described [here](https://github.com/rust-lang/project-safe-transmute/issues/15)) that does not rely on analyzing the visibility of types and fields.

The revised analysis treats primitive types as safe, and user-defined types as potentially carrying safety invariants. If Rust gains explicit (un)safe fields, this PR is structured so that it will be fairly easy to thread support for those annotations into the analysis.

Notably, this PR removes the `Context` type parameter from `BikeshedIntrinsicFrom`. Most of the files changed by this PR are just UI tests tweaked to accommodate the removed parameter.

r? `@compiler-errors`
2024-02-29 20:50:03 +01:00
Trevor Gross
582ad492cd Remove doc aliases to PATH
Remove aliases for `split_paths` and `join_paths` as should have been
done in <https://github.com/rust-lang/rust/pull/119748> (Bors merged the
wrong commit).
2024-02-29 14:28:47 -05:00
Guillaume Gomez
eea8ceed54
Rollup merge of #121596 - ChrisDenton:tls, r=joboet
Use volatile access instead of `#[used]` for `on_tls_callback`

The first commit adds a volatile load of `p_thread_callback` when registering a dtor so that the compiler knows if the callback is used or not. I don't believe the added volatile instruction is otherwise significant in the context. In my testing using the volatile load allowed the compiler to correctly reason about whether `on_tls_callback` is used or not, allowing it to be omitted entirely in some cases. Admittedly it usually is used due to `Thread` but that can be avoided (e.g. in DLLs or with custom entry points that avoid the offending APIs). Ideally this would be something the compiler could help a bit more with so we didn't have to use tricks like `#[used]` or volatile. But alas.

I also used this as an opportunity to clean up the `unused` lints which I don't think serve a purpose any more.

The second commit removes the volatile load of `_tls_used` with `#cfg[target_thread_local]` because `#[thread_local]` already implies it. And if it ever didn't then `#[thread_local]` would be broken when there aren't any dtors.
2024-02-29 17:08:37 +01:00
Guillaume Gomez
bc23b84386
Rollup merge of #121793 - tbu-:pr_floating_point_32, r=Amanieu
Document which methods on `f32` are precise

Same as #118217 but for `f32`.
2024-02-29 14:33:53 +01:00
Guillaume Gomez
ad74598dbc
Rollup merge of #121765 - hermit-os:errno, r=ChrisDenton
add platform-specific function to get the error number for HermitOS

Extending `std` to get the last error number for HermitOS.

HermitOS is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-02-29 14:33:51 +01:00
Guillaume Gomez
0c2cb39f95
Rollup merge of #118217 - tbu-:pr_floating_point, r=Amanieu
Document which methods on `f64` are precise
2024-02-29 14:33:49 +01:00
Tobias Bucher
7400f22d92 Document which methods on f32 are precise
Same as #118217 but for `f32`.
2024-02-29 12:38:21 +01:00
Tobias Bucher
b5307f5d95 Document the precision of f64 methods 2024-02-29 11:58:13 +01:00
Jacob Pratt
20a1bf6c17
Rollup merge of #121778 - ibraheemdev:patch-19, r=RalfJung
Document potential memory leak in unbounded channel

Follow up on https://github.com/rust-lang/rust/pull/121646.
2024-02-29 05:25:29 -05:00
Jacob Pratt
769eb2cd61
Rollup merge of #121768 - ecton:condvar-unwindsafe, r=m-ou-se
Implement unwind safety for Condvar on all platforms

Closes #118009

This commit adds unwind safety consistency to Condvar. Previously, only select platforms implemented unwind safety through auto traits. Known by this committer: On Linux, `Condvar` implemented `UnwindSafe` but on Mac and Windows, it did not. This change changes the implementation from auto to explicit.

In #118009, it was suggested that the platform differences were a bug and that a simple PR could address this. In trying to determine the best information to put in the `#[stable]` attribute, it [was suggested](https://github.com/rust-lang/rust/issues/121690#issuecomment-1968298470) I copy the stability information from the previous unwind safety implementations.
2024-02-29 05:25:29 -05:00
Jacob Pratt
6d865038a5
Rollup merge of #120291 - pitaj:string-sliceindex, r=Amanieu
Have `String` use `SliceIndex` impls from `str`

This PR simplifies the implementation of `Index` and `IndexMut` on `String`, and in the process enables indexing `String` by any user types that implement `SliceIndex<str>`.

Similar to #47832

r? libs

Not sure if this warrants a crater run.
2024-02-29 05:25:26 -05:00
Jacob Pratt
06d487888b
Rollup merge of #119748 - tgross35:suggest-path-split, r=Amanieu
Increase visibility of `join_path` and `split_paths`

Add some crosslinking among `std::env` pages to make it easier to discover `join_paths` and `split_paths`. Also add aliases to help anyone searching for `PATH`.
2024-02-29 05:25:26 -05:00
Ibraheem Ahmed
7c9fa952c3
fix typos
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-02-29 01:33:02 -05:00
Ibraheem Ahmed
9c6a0766be
document potential memory leak in unbounded channel 2024-02-29 00:56:31 -05:00
r0cky
61fcdf6655 Add proper cfg 2024-02-29 09:25:28 +08:00
Matthias Krüger
332b9be7a1
Rollup merge of #110543 - joboet:reentrant_lock, r=m-ou-se
Make `ReentrantLock` public

Implements the ACP rust-lang/libs-team#193.

``@rustbot`` label +T-libs-api +S-waiting-on-ACP
2024-02-29 00:16:58 +01:00
Jonathan Johnson
55129453c6
Implement unwind safety for Condvar
Closes #118009

This commit adds unwind safety to Condvar. Previously, only select
platforms implemented unwind safety through auto traits. Known by this
committer: Linux was unwind safe, but Mac and Windows are not before
this change.
2024-02-28 14:56:36 -08:00
Stefan Lankes
3726cbb5fe add platform-specific function to get the error number for HermitOS
Extending `std` to get the last error number for HermitOS.

HermitOS is a tier 3 platform and this PR changes only files,
wich are related to the tier 3 platform.
2024-02-28 23:01:56 +01:00
Guillaume Gomez
2492f93222
Rollup merge of #121691 - janstarke:handle-missing-creation-time-as-unsupported, r=cuviper
handle unavailable creation time as `io::ErrorKind::Unsupported`
2024-02-28 16:04:53 +01:00
Guillaume Gomez
d8404084c0
Rollup merge of #120051 - riverbl:os-str-display, r=m-ou-se
Add `display` method to `OsStr`

Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode.

Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`.

This change also makes the `std::ffi::os_str` module public (see https://github.com/rust-lang/libs-team/issues/326#issuecomment-1894160023).

- ACP: https://github.com/rust-lang/libs-team/issues/326
- Tracking issue: #120048
2024-02-28 16:04:49 +01:00
bors
ef324565d0 Auto merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se
Add a new `wasm32-wasi-preview2` target

This is the initial implementation of the MCP https://github.com/rust-lang/compiler-team/issues/694 creating a new tier 3 target `wasm32-wasi-preview2`. That MCP has been seconded and will most likely be approved in a little over a week from now. For more information on the need for this target, please read the [MCP](https://github.com/rust-lang/compiler-team/issues/694).

There is one aspect of this PR that will become insta-stable once these changes reach a stable compiler:
* A new `target_family` named `wasi` is introduced. This target family incorporates all wasi targets including `wasm32-wasi` and its derivative `wasm32-wasi-preview1-threads`. The difference between `target_family = wasi` and `target_os = wasi` will become much clearer when `wasm32-wasi` is renamed to `wasm32-wasi-preview1` and the `target_os` becomes `wasm32-wasi-preview1`. You can read about this target rename in [this MCP](https://github.com/rust-lang/compiler-team/issues/695) which has also been seconded and will hopefully be officially approved soon.

Additional technical details include:
* Both `std::sys::wasi_preview2` and `std::os::wasi_preview2` have been created and mostly use `#[path]` annotations on their submodules to reach into the existing `wasi` (soon to be `wasi_preview1`) modules. Over time the differences between `wasi_preview1` and `wasi_preview2` will grow and most like all `#[path]` based module aliases will fall away.
* Building `wasi-preview2` relies on a [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) in the same way that `wasi-preview1` does (one must include a `wasi-root` path in the `Config.toml` pointing to sysroot included in the wasi-sdk). The target should build against [wasi-sdk v21](https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-21) without modifications. However, the wasi-sdk itself is growing [preview2 support](https://github.com/WebAssembly/wasi-sdk/pull/370) so this might shift rapidly. We will be following along quickly to make sure that building the target remains possible as the wasi-sdk changes.
* This requires a [patch to libc](https://github.com/rylev/rust-libc/tree/wasm32-wasi-preview2) that we'll need to land in conjunction with this change. Until that patch lands the target won't actually build.
2024-02-27 20:57:38 +00:00
Jan Starke
7e10a5c724
handle unavailable creation time as io::ErrorKind::Unsupported 2024-02-27 17:45:20 +01:00
Peter Jaszkowiak
5d59d0c7d7 have String use SliceIndex impls from str 2024-02-27 09:41:32 -07:00
Jack Wrenn
23ab1bda92 safe transmute: revise safety analysis
Migrate to a simplified safety analysis that does not use visibility.

Closes https://github.com/rust-lang/project-safe-transmute/issues/15
2024-02-27 16:22:32 +00:00
bors
8790c3cc7c Auto merge of #119636 - devnexen:linux_tcp_defer_accept, r=m-ou-se
os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`.

allows for socket to process only when there is data to process, the option sets a number of seconds until the data is ready.
2024-02-27 16:00:39 +00:00
Ryan Levick
5e9bed7b1e
Rename wasm32-wasi-preview2 to wasm32-wasip2
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27 10:14:45 -05:00
Ryan Levick
f115064631 Add the wasm32-wasi-preview2 target
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27 09:58:04 -05:00
Ralf Jung
f5c80dcd5a intrinsics.rs: add some notes on unwinding 2024-02-27 12:28:25 +01:00
bors
71ffdf7ff7 Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #121598 (rename 'try' intrinsic to 'catch_unwind')
 - #121639 (Update books)
 - #121648 (Update Vec and String `{from,into}_raw_parts`-family docs)
 - #121651 (Properly emit `expected ;` on `#[attr] expr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-27 00:55:14 +00:00
Matthias Krüger
94609dbb03
Rollup merge of #121648 - jieyouxu:from-into-raw-parts-docs, r=Nilstrieb
Update Vec and String `{from,into}_raw_parts`-family docs

- Fix documentation argument order to match the code argument order for consistency.
- Add return argument description for `{Vec,String}::into_raw_parts` to match their `from*` counterparts.
2024-02-27 00:40:01 +01:00
Matthias Krüger
d95c321062
Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk
rename 'try' intrinsic to 'catch_unwind'

The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO.

Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-27 00:40:00 +01:00
bors
5c786a7fe3 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics

`@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26 22:24:16 +00:00
许杰友 Jieyou Xu (Joe)
bfeea294cc
Document args returned from String::into_raw_parts 2024-02-26 19:32:32 +00:00
许杰友 Jieyou Xu (Joe)
dd24a462d5
Document args returned from Vec::into_raw_parts{,_with_alloc} 2024-02-26 19:32:32 +00:00
许杰友 Jieyou Xu (Joe)
26bdf2900a
Rearrange String::from_raw_parts doc argument order to match code argument order 2024-02-26 19:32:26 +00:00
许杰友 Jieyou Xu (Joe)
a1b93e8fed
Rearrange Vec::from_raw_parts{,_in} doc argument order to match code argument order 2024-02-26 19:32:17 +00:00
Ibraheem Ahmed
580b003edd
fix race between block initialization and receiver disconnection 2024-02-26 13:53:35 -05:00
Chris Denton
ad4c4f4654
Remove _tls_used trickery unless needed 2024-02-26 11:35:38 -03:00
Chris Denton
2fc091f510
Use volatile to make p_thread_callback used 2024-02-26 11:35:28 -03:00
Ralf Jung
a3c0f3af9c miri: rename miri_start_panic → miri_start_unwind 2024-02-26 11:10:18 +01:00
Ralf Jung
b4ca582b89 rename 'try' intrinsic to 'catch_unwind' 2024-02-26 11:10:18 +01:00
bors
dc00e8cdb6 Auto merge of #121317 - ChrisDenton:win10-sync, r=Mark-Simulacrum
Always use WaitOnAddress on Win10+

`WaitOnAddress` and `WakeByAddressSingle` are always available since Windows 8 so they can now be used without needing to delay load. I've also moved the Windows 7 thread parking fallbacks into a separate sub-module.
2024-02-26 06:31:30 +00:00
bors
b0d3e04ca9 Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25 19:11:06 +00:00
bors
8c0b1fcd29 Auto merge of #121591 - matthiaskrgr:rollup-8wfhh3v, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #119590 (Stabilize `cfg_target_abi`)
 - #120805 (make non-PartialEq-typed consts as patterns a hard error)
 - #121060 (Add newtypes for bool fields/params/return types)
 - #121284 (Add test cases for inlining compiler-private items)
 - #121324 (pattern_analysis: factor out unspecialization)
 - #121409 (Prevent cycle in implied predicates computation)
 - #121513 (Fix sgx unit test compilation)
 - #121570 (Make most bootstrap step types !Copy)
 - #121586 (Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-25 16:18:45 +00:00
Matthias Krüger
f54863636a
Rollup merge of #121513 - nshyrei:fix_tests_module, r=cuviper
Fix sgx unit test compilation

Fixes a compilation error:
```
error[E0583]: file not found for module `tests`
 --> library/std/src/sys/locks/rwlock/sgx.rs:2:1
  |
2 | mod tests;
  | ^^^^^^^^^^
  |
  = help: to create the module `tests`, create file "library/std/src/sys/locks/rwlock/sgx/tests.rs" or "library/std/src/sys/locks/rwlock/sgx/tests/mod.rs"
  = note: if there is a `mod tests` elsewhere in the crate already, import it with `use crate::...` instead

For more information about this error, try `rustc --explain E0583`.
error: could not compile `std` (lib test) due to 1 previous error`
```
When running command:
```
 `TF_BUILD=True RUST_TEST_THREADS=1 ./x.py test --stage 1 "library/std" tests/assembly tests/run-make --target=x86_64-fortanix-unknown-sgx --no-doc --exclude src/tools/linkchecker --exclude src/tools/rust-demangler --no-fail-fast 2>&1
```
The fix is done by moving a file to the location suggested by the compiler.

The issue was introduced by PR: https://github.com/rust-lang/rust/pull/121177
2024-02-25 17:05:22 +01:00
Matthias Krüger
e13f454874
Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb
Stabilize `cfg_target_abi`

This stabilizes the `cfg` option called `target_abi`:

```rust
#[cfg(target_abi = "eabihf")]
```

Tracking issue: #80970

fixes #78791
resolves #80970
2024-02-25 17:05:19 +01:00
Chris Denton
08caefbb10
Windows: Use ProcessPrng for random keys 2024-02-25 10:13:37 -03:00
Ralf Jung
cc3df0af7b remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics 2024-02-25 08:14:52 +01:00