Commit Graph

13844 Commits

Author SHA1 Message Date
Matthias Krüger
d0e5431eb0
Rollup merge of #109263 - squell:master, r=cuviper
fix typo in documentation for std::fs::Permissions

Please check and re-check this PR carefully to see if I got this right.

But by my logic, if the `read_only` function returns `true`, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that `read_only` being `false` doesn't mean *you* can actually write to the file, just that "in general" someone is able to.
2024-03-02 10:09:34 +01:00
Matthias Krüger
4f32f78fc6
Rollup merge of #121730 - ecnelises:aix_pgo, r=wesleywiser
Add profiling support to AIX

AIX ld needs special option to merge objects with profiling. Also, profiler_builtins should include builtins for AIX from compiler-rt.
2024-03-01 22:38:48 +01:00
Matthias Krüger
441217d9b5
Rollup merge of #121634 - RavuAlHemio:slice-prefix-suffix-docs, r=cuviper
Clarify behavior of slice prefix/suffix operations in case of equality

Operations such as starts_with, ends_with, strip_prefix and strip_suffix can be either strict (do not consider a slice to be a prefix/suffix of itself) or not. In Rust's case, they are not strict. Add a few phrases to the documentation to clarify this.
2024-03-01 22:38:47 +01:00
Matthias Krüger
68dd5e65a9
Rollup merge of #121850 - reitermarkus:generic-nonzero-unsafe-trait, r=Nilstrieb
Make `ZeroablePrimitive` trait unsafe.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? `@dtolnay`
2024-03-01 17:51:33 +01:00
Matthias Krüger
90ca049320
Rollup merge of #121736 - HTGAzureX1212:HTGAzureX1212/remove-mutex-unlock, r=jhpratt
Remove `Mutex::unlock` Function

As of the completion of the FCP in https://github.com/rust-lang/rust/issues/81872#issuecomment-1474104525, it has come to the conclusion to be closed.

This PR removes the function entirely in light of the above.

Closes #81872.
2024-03-01 17:51:30 +01:00
Markus Reiter
f6d2607163
Make ZeroablePrimitive trait unsafe. 2024-03-01 13:49:37 +01:00
bors
6f435eb0eb Auto merge of #114016 - krtab:delete_sys_memchr, r=workingjubilee
Delete architecture-specific memchr code in std::sys

Currently all architecture-specific memchr code is only used in `std::io`. Most of the actual `memchr` capacity exposed to the user through the slice API is instead implemented in `core::slice::memchr`.

Hence this commit deletes `memchr` from `std::sys[_common]` and replace calls to it by calls to `core::slice::memchr` functions. This deletes `(r)memchr` from the list of symbols linked to libc.

The interest of putting architecture specific code back in core is linked to the discussion to be had in #113654
2024-03-01 00:45:47 +00:00
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
HTGAzureX1212.
a9907b1fdf remove Mutex::unlock 2024-02-28 20:26:19 +08:00
Qiu Chaofan
9d71386252 Add profiling support to AIX
AIX ld needs special option to merge objects with profiling. Also,
profiler_builtins should include builtins for AIX from compiler-rt.
2024-02-28 17:41:12 +08: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
Ondřej Hošek
c9a4a4a192 Clarify behavior of slice prefix/suffix operations in case of equality
Operations such as starts_with, ends_with, strip_prefix and strip_suffix
can be either strict (do not consider a slice to be a prefix/suffix of
itself) or not. In Rust's case, they are not strict. Add a few phrases to
the documentation to clarify this.
2024-02-26 15:35:30 +01:00