Commit Graph

7267 Commits

Author SHA1 Message Date
Matthias Krüger
d46cc71f54
Rollup merge of #135394 - clarfonthey:uninit-slices-part-2, r=tgross35
`MaybeUninit` inherent slice methods part 2

These were moved out of #129259 since they require additional libs-api approval. Tracking issue: #117428.

New API surface:

```rust
impl<T> [MaybeUninit<T>] {
    // replacing fill; renamed to avoid conflict
    pub fn write_filled(&mut self, value: T) -> &mut [T] where T: Clone;

    // replacing fill_with; renamed to avoid conflict
    pub fn write_with<F>(&mut self, value: F) -> &mut [T] where F: FnMut() -> T;

    // renamed to remove "fill" terminology, since this is closer to the write_*_of_slice methods
    pub fn write_iter<I>(&mut self, iter: I) -> (&mut [T], &mut Self) where I: Iterator<Item = T>;
}
```

Relevant motivation for these methods; see #129259 for earlier methods' motiviations.

* I chose `write_filled` since `filled` is being used as an object here, whereas it's being used as an action in `fill`.
* I chose `write_with` instead of `write_filled_with` since it's shorter and still matches well.
* I chose `write_iter` because it feels completely different from the fill methods, and still has the intent clear.

In all of the methods, it felt appropriate to ensure that they contained `write` to clarify that they are effectively just special ways of doing `MaybeUninit::write` for each element of a slice.

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

r? libs-api
2025-03-19 16:52:52 +01:00
bors
a7fc463dd8 Auto merge of #138693 - matthiaskrgr:rollup-ejq8mwp, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #136177 (clarify BufRead::{fill_buf, consume} docs)
 - #138654 (Remove the regex dependency from coretests)
 - #138655 (rustc-dev-guide sync)
 - #138656 (Remove double nesting in post-merge workflow)
 - #138658 (CI: mirror alpine and centos images to ghcr)
 - #138659 (coverage: Don't store a body span in `FunctionCoverageInfo`)
 - #138661 (Revert: Add *_value methods to proc_macro lib)
 - #138670 (Remove existing AFIDT implementation)
 - #138674 (Various codegen_llvm cleanups)
 - #138684 (use then in docs for `fuse` to enhance readability)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-19 12:39:34 +00:00
Mara Bos
f23e76e0d2 Allow spawning threads after TLS destruction. 2025-03-19 12:49:18 +01:00
bors
c4b38a5967 Auto merge of #138653 - matthiaskrgr:rollup-fwwqmr7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #136320 (exit: document interaction with C)
 - #138080 (Leave a breadcrumb towards bootstrap config documentation in `bootstrap.toml`)
 - #138301 (Implement `read_buf` for Hermit)
 - #138569 (rustdoc-json: Add tests for `#[repr(...)]`)
 - #138635 (Extract `for_each_immediate_subpat` from THIR pattern visitors)
 - #138642 (Unvacation myself)
 - #138644 (Add `#[cfg(test)]` for Transition in dfa in `rustc_transmute`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-19 09:28:24 +00:00
Matthias Krüger
b52275fd01
Rollup merge of #136177 - hkBst:patch-24, r=ibraheemdev
clarify BufRead::{fill_buf, consume} docs

Fixes #85394
2025-03-19 08:17:14 +01:00
Chris Denton
6b2fa32f14
Windows: fix FileType PartialEq implementation 2025-03-18 17:39:38 +00:00
Taiki Endo
68267d0aed Fix build failure on Trusty 2025-03-19 02:05:01 +09:00
Chris Denton
3bfb6af978
Test windows file type equality 2025-03-18 16:46:56 +00:00
Berrysoft
2a0cd874a9 Add stack overflow handler for cygwin 2025-03-18 23:00:33 +08:00
Ayush Singh
9fa158d70a
std: uefi: fs: Implement mkdir
- Since there is no direct mkdir in UEFI, first check if a file/dir with
  same path exists and then create the directory.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-18 19:32:46 +05:30
Marijn Schouten
e5b86e2c73
Apply suggestions from code review
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-03-18 11:16:18 +01:00
Matthias Krüger
800b8fbe39
Rollup merge of #138301 - thaliaarchi:io-optional-methods/hermit, r=tgross35
Implement `read_buf` for Hermit

Following https://github.com/hermit-os/kernel/pull/1606, it is now safe to implement `Read::read_buf` for file descriptors on Hermit.

cc ```@mkroening```
2025-03-18 10:09:29 +01:00
Matthias Krüger
098db784c7
Rollup merge of #136320 - RalfJung:exit, r=the8472
exit: document interaction with C

Cc https://github.com/rust-lang/rust/issues/126600
2025-03-18 10:09:28 +01:00
bors
75530e9f72 Auto merge of #135368 - Ayush1325:uefi-fs-2, r=jhpratt,nicholasbishop
uefi: fs: Implement exists

Also adds the initial file abstractions.

The file opening algorithm is inspired from UEFI shell. It starts by classifying if the Path is Shell mapping, text representation of device path protocol, or a relative path and converts into an absolute text representation of device path protocol.

After that, it queries all handles supporting
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the device path protocol prefix (similar to Windows drive). After that, it opens the file in the volume using the remaining pat.

It also introduces OwnedDevicePath and BorrowedDevicePath abstractions to allow working with the base UEFI and Shell device paths efficiently.

DevicePath in UEFI behaves like an a group of nodes laied out in the memory contiguously and thus can be modeled using iterators.

This is an effort to break the original PR (https://github.com/rust-lang/rust/pull/129700) into much smaller chunks for faster upstreaming.
2025-03-18 09:09:12 +00:00
Thalia Archibald
a0c3dd4df4 Optimize io::Write::write_fmt for constant strings
When the formatting args to `fmt::Write::write_fmt` are a statically
known string, it simplifies to only calling `write_str` without a
runtime branch. Do the same in `io::Write::write_fmt` with `write_all`.

Also, match the convention of `fmt::Write` for the name of `args`.
2025-03-18 01:40:27 -07:00
Ayush Singh
2e70cfc04d
uefi: fs: Implement exists
Also adds the initial file abstractions.

The file opening algorithm is inspired from UEFI shell. It starts by
classifying if the Path is Shell mapping, text representation of device
path protocol, or a relative path and converts into an absolute text
representation of device path protocol.

After that, it queries all handles supporting
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the
device path protocol prefix (similar to Windows drive). After that, it
opens the file in the volume using the remaining pat.

It also introduces OwnedDevicePath and BorrowedDevicePath abstractions
to allow working with the base UEFI and Shell device paths efficiently.

DevicePath in UEFI behaves like an a group of nodes laied out in the
memory contiguously and thus can be modeled using iterators.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-18 08:11:16 +05:30
Thalia Archibald
bcac931956 Update test for SGX now implementing read_buf
In #108326, `read_buf` was implemented for a variety of types, but SGX
was saved for later. Update a test from then, now that #137355
implemented it for SGX types.
2025-03-17 17:18:05 -07:00
Thalia Archibald
c5fc1931a0 Implement read_buf for Hermit 2025-03-17 16:53:37 -07:00
Ralf Jung
c133e22f7c move new section into platform-specific behavior, as it is unix-specific 2025-03-17 17:56:22 +01:00
bjorn3
42de015549 Mark imports of #[rustc_std_internal_symbol] items with this attribute
This ensures that they will be correctly mangled in a future commit.
2025-03-17 14:06:56 +00:00
Jacob Pratt
62c2a7b93b
Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplett
Stablize anonymous pipe

Since #135822 is staled, I create this PR to stablise anonymous pipe

Closes #127154

try-job: test-various
2025-03-17 05:47:50 -04:00
Jacob Pratt
b3b7a3b8d2
Rollup merge of #137621 - Berrysoft:cygwin-std, r=joboet
Add std support to cygwin target
2025-03-17 05:47:49 -04:00
Jacob Pratt
5144055055
Rollup merge of #138573 - Noratrieb:no-unsound-bad-bonk-bonk, r=workingjubilee
Make `_Unwind_Action` a type alias, not enum

It's bitflags in practice, so an enum is unsound, as an enum must only have the described values. The x86_64 psABI declares it as a `typedef int _Unwind_Action`, which seems reasonable. I made a newtype first but that was more annoying than just a typedef. We don't really use this value for much other than a short check.

I ran `x check library --target aarch64-unknown-linux-gnu,x86_64-pc-windows-gnu,x86_64-fortanix-unknown-sgx,x86_64-unknown-haiku,x86_64-unknown-fuchsi
a,x86_64-unknown-freebsd,x86_64-unknown-dragonfly,x86_64-unknown-netbsd,x86_64-unknown-openbsd,x86_64-unknown-redox,riscv64-linux-android,armv7-unknown-freebsd` (and some more but they failed to build for other reasons :D)

fixes #138558

r? workingjubilee have fun
2025-03-16 21:47:45 -04:00
Noratrieb
f20a6c70fb make _Unwind_Action a type alias, not enum
It's bitflags in practice, so an enum is unsound, as an enum must only
have the described values. The x86_64 psABI declares it as a `typedef
int _Unwind_Action`, which seems reasonable. I made a newtype first but
that was more annoying than just a typedef. We don't really use this
value for much other than a short check.
2025-03-16 21:32:41 +01:00
Ayush Singh
aa2c24b03b
uefi: Add OwnedEvent abstraction
- Events are going to become quite important for Networking, so needed
  owned abstractions.
- Switch to OwnedEvent abstraction for Exit boot services event.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-17 01:14:14 +05:30
许杰友 Jieyou Xu (Joe)
c29a29e717
Rollup merge of #137538 - tapanprakasht:fix-doc-path, r=thomcc
fix doc path in std::fmt macro

fixes https://github.com/rust-lang/rust/issues/137519
2025-03-16 13:19:52 +08:00
许杰友 Jieyou Xu (Joe)
26dea1d944
Rollup merge of #137492 - nabijaczleweli:master, r=thomcc
libstd: rustdoc: correct note on fds 0/1/2 pre-main

Closes: #137490
2025-03-16 13:19:52 +08:00
许杰友 Jieyou Xu (Joe)
8210b84aaf
Rollup merge of #138275 - folkertdev:expose-is-s390x-feature-detected, r=Mark-Simulacrum
expose `is_s390x_feature_detected!` from `std::arch`

tracking issue: https://github.com/rust-lang/rust/issues/135413
implementation: https://github.com/rust-lang/stdarch/pull/1699 (more features added in https://github.com/rust-lang/stdarch/pull/1720)

This macro was part of the recent `stdarch` synchronization, but not yet exposed via `std::arch`.

r? libs
2025-03-16 09:40:05 +08:00
许杰友 Jieyou Xu (Joe)
f16ce2ae6c
Rollup merge of #137890 - lolbinarycat:docs-bufreader-peek-consume, r=Mark-Simulacrum
doc: clarify that consume can be called after BufReader::peek

tracking issue #128405
2025-03-16 09:40:03 +08:00
bors
cb50d4d856 Auto merge of #137424 - Ayush1325:uefi-path-node, r=nicholasbishop,cuviper
uefi: helpers: Add DevicePathNode abstractions

- UEFI device path is a series of nodes layed out in a contiguous memory region. So it makes sense to use Iterator abstraction for modeling DevicePaths
- This PR has been split off from #135368 for easier review. The allow dead_code will be removed in #135368

cc `@nicholasbishop`
2025-03-14 13:55:32 +00:00
Tobias Bucher
bdaf23b4cd Forward stream_position in Arc<File> as well
It was missed in #137165.
2025-03-14 12:36:00 +01:00
Jacob Pratt
f6fcae0015
Rollup merge of #138457 - bjorn3:redox_scheme_paths, r=Noratrieb
Remove usage of legacy scheme paths on RedoxOS

The `name:/path` path syntax is getting phased out[^1] in favor of `/scheme/name/path`. Also using `null:` is no longer necessary as `/dev/null` is available on Redox OS too.

[^1]: https://gitlab.redox-os.org/redox-os/rfcs/-/blob/master/text/0006-scheme-path.md

cc `@jackpot51`
2025-03-14 01:37:36 -04:00
Jacob Pratt
936e51ee12
Rollup merge of #137870 - karolzwolak:lazylock-const-hashmaps-137566, r=cuviper
Improve HashMap docs for const and static initializers

Closes #137566.
I clarified the HashMap usage in const and static initializers.
I also added examples of how to construct such HashMaps wrapped in LazyLock.
2025-03-14 01:37:30 -04:00
Jacob Pratt
c62707eb74
Rollup merge of #136001 - hkBst:patch-21, r=cuviper
Overhaul examples for PermissionsExt

This fixes #91707 by including one overarching example, instead of the small examples that can be misleading.
2025-03-14 01:37:28 -04:00
bjorn3
43499bfe2e Remove has_redox_scheme
Redox OS is moving away from name:/path style paths to /scheme/name/path
style paths which are already handled correctly without has_redox_scheme.
2025-03-13 20:09:07 +00:00
Matthias Krüger
883f00ce34
Rollup merge of #138425 - cuviper:remove-hash_raw_entry, r=jhpratt
Remove `feature = "hash_raw_entry"`

The `hash_raw_entry` feature finished [fcp-close](https://github.com/rust-lang/rust/issues/56167#issuecomment-2293805510) back in August, and its remaining uses in the compiler have now been removed, so we should be all clear to remove it from `std`.

Closes #56167
2025-03-13 17:44:11 +01:00
bjorn3
83ee034d03 Remove usage of legacy scheme paths on RedoxOS
The name:/path path syntax is getting phased out in favor of
/scheme/name/path. Also using null: is no longer necessary as /dev/null
is available on Redox OS too.
2025-03-13 16:17:50 +00:00
Jiahao XU
6863a99841
Mv os-specific trait impl of Pipe* into std::os::*
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-14 01:03:56 +11:00
Jiahao XU
340a45282a
Stablize feature anonymous_pipe
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-14 00:52:45 +11:00
Matthias Krüger
3bfce83cb2
Rollup merge of #138370 - cuviper:try_oom_error, r=jhpratt
Simulate OOM for the `try_oom_error` test

We can create the expected error manually, rather than trying to produce
a real one, so the error conversion test can run on all targets. Before,
it was only running on 64-bit and not miri.

In Fedora, we also found that s390x was not getting the expected error,
"successfully" allocating the huge size because it was optimizing the
real `malloc` call away. It's possible to counter that by looking at the
pointer in any way, like a debug print, but it's more robust to just
deal with errors directly, since this test is only about conversion.

Related: #133806
2025-03-13 10:58:24 +01:00
Matthias Krüger
448aa30b5a
Rollup merge of #138162 - ehuss:library-2024, r=cuviper
Update the standard library to Rust 2024

This updates the standard library to Rust 2024. This includes the following notable changes:

- Macros are updated to use new expression fragment specifiers. This PR includes a test to illustrate the changes, primarily allowing `const {...}` expressions now.
- Some tests show a change in MIR drop order. We do not believe this will be an observable change ([see zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/268952-edition/topic/standard.20library.20migration/near/500972873)).

Fixes https://github.com/rust-lang/rust/issues/133081
2025-03-13 10:58:21 +01:00
Matthias Krüger
9527572460
Rollup merge of #137355 - thaliaarchi:io-optional-methods/sgx, r=ChrisDenton
Implement `read_buf` and vectored read/write for SGX stdio

Implement `read_buf`, `read_vectored`, and `write_vectored` for the SGX stdio types.

Additionally, extend `User<T>::copy_to_enclave` to work for copying to uninitialized values and fix unsoundness in `UserRef<[T]>::copy_to_enclave_vec`.

cc ``@jethrogb``

Tracked in https://github.com/rust-lang/rust/issues/136756
2025-03-13 10:58:19 +01:00
Matthias Krüger
a488cf8a70
Rollup merge of #136842 - randomPoison:trusty-libstd-v3, r=ChrisDenton
Add libstd support for Trusty targets

This PR adds support for `alloc` and `std` for the Trusty targets based on the internal patches used in Android. The original patches can be seen [here](https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main/patches/development/rustc-0023-Add-Trusty-OS-support-to-Rust-std.patch) and [here](https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main/patches/development/rustc-0054-Add-std-os-fd-support-for-Trusty.patch). Please let me know if there's any additional context I need to add.
2025-03-13 10:58:17 +01:00
bors
8536f201ff Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth
Rollup of 12 pull requests

Successful merges:

 - #134076 (Stabilize `std::io::ErrorKind::InvalidFilename`)
 - #137504 (Move methods from Map to TyCtxt, part 4.)
 - #138175 (Support rmeta inputs for --crate-type=bin --emit=obj)
 - #138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs)
 - #138280 (fix ICE in pretty-printing `global_asm!`)
 - #138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js)
 - #138331 (Use `RUSTC_LINT_FLAGS` more)
 - #138357 (merge `TypeChecker` and `TypeVerifier`)
 - #138394 (remove unnecessary variant)
 - #138403 (Delegation: one more ICE fix for `MethodCall` generation)
 - #138407 (Delegation: reject C-variadics)
 - #138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-13 01:37:26 +00:00
Josh Stone
2c0ad9d967 Remove feature = "hash_raw_entry" 2025-03-12 13:32:50 -07:00
Manish Goregaokar
185dd2d01b
Rollup merge of #134076 - GrigorenkoPV:InvalidFilename, r=joboet
Stabilize `std::io::ErrorKind::InvalidFilename`

FCP complete: https://github.com/rust-lang/rust/issues/130192#issuecomment-2674989358

Tracking issues: #86442 & #130192

This PR:
- Stabilizes `InvalidFilename` without changing its name to `InvalidFileName`.
- Fixes the doc comment (https://github.com/rust-lang/rust/issues/130192#issuecomment-2429534640)
- Does not separate "the name is too long" case into a separate `ErrorKind`. That case is currently documented to be covered by `InvalidFilename` in the doc. I'm not sure if it would be possible to change this later or if that would be an unacceptable breaking change.
- Does not map more raw OS errors to this `ErrorKind` (as suggested in https://github.com/rust-lang/rust/issues/86442#issuecomment-1441709738). This can presumably be addressed later.
2025-03-12 10:19:25 -07:00
Matthias Krüger
a21d41a22d
Rollup merge of #138269 - Ayush1325:uefi-fs-permission, r=joboet
uefi: fs: Implement FileType, FilePermissions and FileAttr

- In UEFI, both FileType and FilePermissions are represented by the attr bitfield.
- Using simple bools here since both are represented by a single bit.
- Add `FILE_PERMISSION` mask for constructing attribute while change permissions.

cc ````@nicholasbishop````
2025-03-12 17:59:07 +01:00
Berrysoft
bd385f3064 Fix panic handler for cygwin 2025-03-12 15:48:05 +08:00
Thalia Archibald
c62aa0baa1 Fix UserRef<[T]>::copy_to_enclave_vec
It reinterprets uninitialized memory as initialized and does not drop
existing elements of the Vec. Fix that.

Additionally, make it more general by appending, instead of overwriting
existing elements, and rename it to `append_to_enclave_vec`. A caller
can simply call `.clear()` before, for the old behavior.
2025-03-11 20:16:31 -07:00
bors
c625102320 Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #137715 (Allow int literals for pattern types with int base types)
 - #138002 (Disable CFI for weakly linked syscalls)
 - #138051 (Add support for downloading GCC from CI)
 - #138231 (Prevent ICE in autodiff validation by emitting user-friendly errors)
 - #138245 (stabilize `ci_rustc_if_unchanged_logic` test for local environments)
 - #138256 (Do not feed anon const a type that references generics that it does not have)
 - #138284 (Do not write user type annotation for const param value path)
 - #138296 (Remove `AdtFlags::IS_ANONYMOUS` and `Copy`/`Clone` condition for anonymous ADT)
 - #138352 (miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access)
 - #138354 (remove redundant `body`  arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 21:17:18 +00:00
Thalia Archibald
60805dc7e4 Deduplicate platform stdio types 2025-03-11 14:00:08 -07:00
Josh Stone
53f488aa4b Simulate OOM for the try_oom_error test
We can create the expected error manually, rather than trying to produce
a real one, so the error conversion test can run on all targets. Before,
it was only running on 64-bit and not miri.

In Fedora, we also found that s390x was not getting the expected error,
"successfully" allocating the huge size because it was optimizing the
real `malloc` call away. It's possible to counter that by looking at the
pointer in any way, like a debug print, but it's more robust to just
deal with errors directly, since this test is only about conversion.
2025-03-11 13:27:15 -07:00
Matthias Krüger
9746ac5c2f
Rollup merge of #138002 - 1c3t3a:fix-std-cfi-violation, r=rcvalle
Disable CFI for weakly linked syscalls

Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g. std::sys::random::getrandom, we can observe a CFI violation. This is the case for all consumers of the std::sys::pal::weak::syscall macro, as it is defining weak functions which don't show up in LLVM IR metadata. CFI fails for all these functions.

Similar to other such cases in
https://github.com/rust-lang/rust/issues/115199, this change stops emitting the CFI typecheck for consumers of the macro via the `#[no_sanitize(cfi)]` attribute.

r? ``````@rcvalle``````
2025-03-11 19:35:28 +01:00
bors
6650252439 Auto merge of #128440 - oli-obk:defines, r=lcnr
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type

Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed.

A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table.

Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable.

Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature.

One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now.

fixes #131298
2025-03-11 18:13:31 +00:00
Eric Huss
993359e701 Migrate std to Rust 2024 2025-03-11 09:46:34 -07:00
Jakub Beránek
95d9ade39d
Rollup merge of #137967 - mustartt:fix-aix-test-hangs, r=workingjubilee
[AIX] Fix hangs during testing

Fixes all current test hangs experienced during CI runs.
1. ipv6 link-local (the loopback device) gets assigned an automatic zone id of 1, causing the assert to fail and hang in `library/std/src/net/udp/tests.rs`
2. Const alloc does not fail gracefully
3. Debuginfo test has problem with gdb auto load safe path
2025-03-11 13:30:50 +01:00
Oli Scherer
cb4751d4b8 Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
Pavel Grigorenko
7475a3416b Stabilize std::io::ErrorKind::InvalidFilename 2025-03-11 14:07:31 +03:00
Nicole L
2b3b0bd50b Remove unused file 2025-03-10 14:19:27 -07:00
Nicole L
f5dd3d13fc Update Trusty support to account for recent libstd reorganization 2025-03-10 12:54:59 -07:00
Nicole LeGare
0b1a7ab339 Remove custom TLS implementation for Trusty targets 2025-03-10 10:00:25 -07:00
Nicole LeGare
22fea97c9d Disable unsupported tests
Unclear why this needs to be done manually and is not done by the existing Trusty patches.
2025-03-10 10:00:25 -07:00
Nicole LeGare
d633d8e074 Format after patches have been applied 2025-03-10 10:00:25 -07:00
Nicole LeGare
7f6ee12526 Apply rustc-0054-Add-std-os-fd-support-for-Trusty.patch 2025-03-10 10:00:24 -07:00
Nicole LeGare
87ca2dbb00 Apply rustc-0023-Add-Trusty-OS-support-to-Rust-std.patch 2025-03-10 10:00:24 -07:00
Paul Menage
9e5c942286 Mark some std tests as requiring panic = "unwind"
This allows these test modules to pass on builds/targets without
unwinding support, where `panic = "abort"` - the ignored tests are for
functionality that's not supported on those targets.
2025-03-10 08:31:06 -07:00
王宇逸
9cab8c25dc Remove stack overflow handler for cygwin 2025-03-10 21:23:32 +08:00
王宇逸
c3c02a517c Use __xpg_strerror_r on cygwin 2025-03-10 21:23:32 +08:00
王宇逸
b9fe8def52 Readd os::cygwin::raw as pub(crate) 2025-03-10 21:23:32 +08:00
王宇逸
c3051b1f5a Unify cygwin & horizon random impl 2025-03-10 21:23:32 +08:00
王宇逸
268e734996 Impl cygwin rand with getrandom 2025-03-10 21:23:31 +08:00
王宇逸
7d80aaaca8 Remove std::os::cygwin::raw 2025-03-10 21:23:31 +08:00
王宇逸
d24c6a29f5 Fix code style 2025-03-10 21:23:31 +08:00
王宇逸
1aad114afd Fix building for cygwin 2025-03-10 21:23:31 +08:00
Ookiineko
e3e98c84d3 Fix std::sys::unix::set_linger for Cygwin
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-10 21:23:31 +08:00
王宇逸
c9ccec93fa Initial STD support for Cygwin
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-10 21:23:31 +08:00
Bastian Kersting
e5dc1e3786 Add comments for #[no_sanitize(cfi)] in stdlib 2025-03-10 08:59:24 +00:00
Bastian Kersting
02bb2d4410 Disable CFI for weakly linked syscalls
Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g.
std::sys::random::getrandom, we can observe a CFI violation. This is
the case for all consumers of the std::sys::pal::weak::weak macro,
as it is defining weak functions which don't show up in LLVM IR
metadata. CFI fails for all these functions.

Similar to other such cases in
https://github.com/rust-lang/rust/issues/115199, this change stops
emitting the CFI typecheck for consumers of the macro via the
\#[no_sanitize(cfi)] attribute.
2025-03-10 08:51:04 +00:00
Thalia Archibald
523b9d9428 Implement default methods for io::Empty and io::Sink
Eliminate any redundant, unobservable logic from the their default
method implementations.

The observable changes are that `Write::write_fmt` for both types now
ignores the formatting arguments, so a user fmt impl which has side
effects is not invoked, and `Write::write_all_vectored` for both types
does not advance the borrowed buffers. Neither behavior is guaranteed by
the docs and the latter is documented as unspecified.

`Empty` is not marked as vectored, so that `Chain<Empty, _>` and
`Chain<_, Empty>` are not forced to be vectored.
2025-03-10 01:38:20 -07:00
Matthias Krüger
2f1908df61
Rollup merge of #138074 - thaliaarchi:hermit-seek, r=ChrisDenton
Support `File::seek` for Hermit

`lseek` was added in `hermit-abi` in commit [87dd201](87dd201a14) (add missing interface for lseek, 2024-07-15), which was just released in version 0.5.0.

cc ``@mkroening,`` ``@stlankes``

Fixes https://github.com/hermit-os/hermit-rs/issues/652
2025-03-10 09:32:13 +01:00
Thalia Archibald
8c7a94e4cd Implement read_buf and vectored read/write for SGX stdio 2025-03-10 00:48:13 -07:00
Jethro Beekman
b52666868f Copy from userspace to MaybeUninit
Co-authored-by: Thalia Archibald <thalia@archibald.dev>
2025-03-10 00:45:19 -07:00
Ayush Singh
e0a9dd31c1
uefi: fs: Partially implement FileAttr
- Just the permission and file type.
- FileTimes will need some new conversion functions and thus will come
  with a future PR. Trying to keep things simple here.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-10 08:16:56 +05:30
Ayush Singh
c717cc7cd2
uefi: fs: Implement FileType
- Similar to FilePermissions, using bool to represent the bitfield.
- FileType cannot be changed, so no need to worry about converting back
  to attribute.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-10 08:16:56 +05:30
Ayush Singh
1833737e16
uefi: fs: Implement FilePermission
- UEFI file permissions are indicated using a u64 bitfield used for
  readonly/filetype, etc.
- Using normal bool with to and from attribute conversions to
  FilePermission from overriding some other bitfields.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-10 08:16:55 +05:30
joboet
c52e0596c5
std: move stdio to sys
As per #117276, this moves the platform definitions of `Stdout` and friends into `sys`. This PR also unifies the UNIX and Hermit implementations and moves the `__rust_print_err` function needed by libunwind on SGX into the dedicated module for such helper functions.
2025-03-09 23:42:13 +01:00
Thalia Archibald
1abaacd375 Support File::seek for Hermit 2025-03-09 15:38:30 -07:00
Matthias Krüger
33530e4cb9
Rollup merge of #138276 - bdbai:fix-uwp-ntopenfile, r=ChrisDenton
Lazy load NtOpenFile for UWP

Lazily load `NtOpenFile` to allow libraries targeting UWP to build and link.

Fixes #138257 .

r? `@ChrisDenton`
2025-03-09 16:41:54 +01:00
bdbai
33c6c3a1e9 Lazy load NtOpenFile for UWP 2025-03-09 22:42:17 +08:00
Folkert de Vries
a312635821
expose is_s390x_feature_detected from std::arch 2025-03-09 14:04:39 +01:00
Thalia Archibald
685619e4c9 Move fs into sys 2025-03-08 16:22:37 -08:00
ltdk
8269132210 Add inherent versions of MaybeUninit::fill methods for slices 2025-03-08 18:41:35 -05:00
Jacob Pratt
6576d35aef
Rollup merge of #138189 - GuillaumeGomez:env-var, r=joshtriplett
Mention `env` and `option_env` macros in `std::env::var` docs

Fixes https://github.com/rust-lang/rust/issues/138159.

Just like there are mentions in `env!` and `option_env!` docs to `std::env::var`, it'd be nice to have a "mention back" as well.
2025-03-08 01:27:23 -05:00
Jacob Pratt
0c67061569
Rollup merge of #137528 - ChrisDenton:rename-win, r=joboet
Windows: Fix error in `fs::rename` on Windows 1607

Fixes #137499

There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work.

I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function).

try-job: dist-x86_64-mingw
try-job: dist-x86_64-msvc
2025-03-08 01:27:21 -05:00
Jacob Pratt
4ec8407196
Rollup merge of #137606 - davidtwco:next-edition, r=traviscross,ehuss
add a "future" edition

This idea has been discussed previously [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Continuous.20edition-like.20changes.3F/near/432559262) (though what I've implemented isn't exactly the "next"/"future" editions proposed in that message, just the "future" edition). I've found myself prototyping changes that involve edition migrations and wanting to target an upcoming edition for those migrations, but none exists. This should be permanently unstable and not removed.
2025-03-07 21:57:49 -05:00
Guillaume Gomez
17dd2b179c Mention env and option_env macros in std::env::var docs 2025-03-07 22:00:36 +01:00
Matthias Krüger
f5a143f796
Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis
Ergonomic ref counting

This is an experimental first version of ergonomic ref counting.

This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations.

RFC: https://github.com/rust-lang/rfcs/pull/3680
Tracking issue: https://github.com/rust-lang/rust/issues/132290
Project goal: https://github.com/rust-lang/rust-project-goals/issues/107

r? ```@nikomatsakis```
2025-03-07 19:15:33 +01:00
Chris Denton
3cb53df1fe
Return OutOfMemoryError and update docs 2025-03-07 17:51:56 +00:00
Chris Denton
0dfe2ae3fb
Windows: Use MoveFileEx by default in fs:rename 2025-03-07 17:51:49 +00:00
bors
03eb454523 Auto merge of #138155 - matthiaskrgr:rollup-xq5buio, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #137674 (Enable `f16` for LoongArch)
 - #138034 (library: Use `size_of` from the prelude instead of imported)
 - #138060 (Revert #138019 after further discussion about how hir-pretty printing should work)
 - #138073 (Break critical edges in inline asm before code generation)
 - #138107 (`librustdoc`: clippy fixes)
 - #138111 (Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-07 13:47:27 +00:00