Commit graph

18660 commits

Author SHA1 Message Date
ClearLove
d2ff65807c
Update library/core/src/intrinsics/mod.rs
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-13 11:33:55 +08: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
0c4415cdd6
Rollup merge of #138387 - RalfJung:intrinsic-arg-names, r=oli-obk
intrinsics: remove unnecessary leading underscore from argument names

This is unnecessary since https://github.com/rust-lang/rust/pull/135840.
2025-03-12 17:59:10 +01: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
Mara Bos
90645c187c Reduce FormattingOptions to 64 bits. 2025-03-12 16:32:00 +01:00
Berrysoft
bd385f3064 Fix panic handler for cygwin 2025-03-12 15:48:05 +08:00
Matthias Krüger
4198902e9a
Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnay
Add PeekMut::refresh

I'm not sure if this should go through ACP or not. BinaryHeap is not the most critical data structure in the standard library and it would be understandable if maintainer throughput is thus too limited to accept this PR without a proper design phase that ensures the required understanding of consequence over a longer time period.

This aims to improve the useability of heaps for priority-based work queues. In certain scenarios, modifications on the most relevant or critical items are performed until a condition that determines the work items have been sufficiently addressed. For instance the criticality could be a deadline that is relaxed whenever some part of a work item is completed. Such a loop will repeatedly access the most critical item and put it back in a sorted position when it is complete. Crucially, due to the ordering invariant we know that all necessary work was performed when the completed item remains the most critical. Getting this information from the heap position avoids a (potentially more costly) check on the item state itself.

A customized `drop` with boolean result would avoid up to two more comparisons performed in both the last no-op refresh and Drop code but this occurs once in each execution of the above scenario whereas refresh occurs any number of times. Also note that the comparison overhead of Drop is only taken if the element is mutably inspected to determine the end condition, i.e. not when refresh itself is the break condition.
2025-03-12 08:06:46 +01:00
Ralf Jung
cf318a79d6 intrinsics: remove unnecessary leading underscore from argument names 2025-03-12 08:04:09 +01: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
beetrees
7c0726521f
Add From<{integer}> for f16/f128 impls 2025-03-11 18:58:54 +00: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
Nicole L
d3c55cd52b
Remove unnecessary parens
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-03-11 11:16:10 -07: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
b130747e92 Migrate windows-targets to Rust 2024 2025-03-11 09:46:35 -07:00
Eric Huss
ba06ce6114 Migrate the sysroot crate to Rust 2024 2025-03-11 09:46:35 -07:00
Eric Huss
32c61f70e7 Migrated the rustc-std-workspace crates to Rust 2024 2025-03-11 09:46:35 -07:00
Eric Huss
80311c4d86 Migrate profiler_builtins to Rust 2024 2025-03-11 09:46:35 -07:00
Eric Huss
0b2489c226 Migrate proc_macro to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
f1a95138d9 Migrate test to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
993359e701 Migrate std to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
540ef90832 Migrate unwind to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
985f66bc22 Migrate panic_unwind to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
b9454af36d Migrate panic_abort to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
f505d4e8e3 Migrate alloc to Rust 2024 2025-03-11 09:46:34 -07:00
Eric Huss
0e071c2c6a Migrate core to Rust 2024 2025-03-11 09:46:34 -07:00
Aurelia Molzer
436959e3f7 Add PeekMut::refresh
This improves the useability of heaps for priority-based work queues. In
certain scenarios, modifications on the most relevant or critical items are
performed until a condition that determines the work items have been
sufficiently addressed. The loop will repeatedly access the most critical
item and put it back in a sorted position when it is complete. Crucially,
due to the ordering invariant we know that all work was performed when the
completed item remains the most critical. Getting this information from the
heap position avoids a (potentially more costly) check on the item state
itself.

A customized `drop` with boolean result would avoid up to two more
comparisons performed in both the last no-op refresh and Drop code but this
occurs once in each execution of the above scenario whereas refresh occurs
any number of times. Also note that the comparison overhead of Drop is only
taken if the element is mutably inspected to determine the end condition,
i.e. not when refresh itself is the break condition.
2025-03-11 15:58:00 +01:00
Sean Cross
e1854933d8 bump libc to 0.2.171 to fix xous
Due to a reorganization in the `libc` crate, the `xous` target broke
with version `0.2.170`. Bump libc to `0.2.171` to fix nightly.

Signed-off-by: Sean Cross <sean@xobs.io>
2025-03-11 22:50:57 +08:00
Ralf Jung
b06a1364f4 remove must_use from <*const T>::expose_provenance 2025-03-11 14:42:47 +01: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
Jakub Beránek
bb2324a656
Rollup merge of #135987 - hkBst:patch-20, r=joboet
Clarify iterator by_ref docs

fixes #95143
2025-03-11 13:30:49 +01:00
Trevor Gross
47ba5bd41e Enable f16 tests for powf
The LLVM issue [1] was fixed with [2], which is included in the LLVM20
upgrade. Tests no longer fail, so enable them here.

[1]: https://github.com/llvm/llvm-project/pull/98681
[2]: https://github.com/llvm/llvm-project/pull/98681
2025-03-11 12:13:01 +00: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
xizheyin
a9b536f8a4
std: Mention clone-on-write mutation in Arc<T>
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-11 19:05:24 +08:00
bors
705421b522 Auto merge of #135651 - arjunr2:master, r=davidtwco
Support for `wasm32-wali-linux-musl` Tier-3 target

Adding a new target -- `wasm32-wali-linux-musl` -- to the compiler can target the [WebAssembly Linux Interface](https://github.com/arjunr2/WALI) according to MCP rust-lang/compiler-team#797
Preliminary support involves minimal changes, primarily

* A new target spec for `wasm32_wali_linux_musl` that bridges linux options with supported wasm options. Right now, since there is no canonical Linux ABI for Wasm, we use `wali` in the vendor field, but this can be migrated in future version.
* Dependency patches to the following crates are required and these crates can be updated to bring target support:
  - **stdarch** rust-lang/stdarch#1702
  - **libc** rust-lang/libc#4244
  - **cc** rust-lang/cc-rs#1373
* Minimal additions for FFI support

cc `@tgross35` for libc-related changes

Tier-3 policy:
> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I will take responsibility for maintaining this target as well as issues

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

The target name is consistent with naming patterns from currently supported targets for arch (wasm32), OS, (linux) and env (musl)

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

No naming confusion is introduced.

> If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

Compliant

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

It's fully open source

> The target must not introduce license incompatibilities. Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Noted

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

Compliant

> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

All tools are open-source

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

No terms present

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

I am not a reviewer

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

This target supports the full standard library with appropriate configuration stubs where necessary (however, similar to all existing wasm32 targets, it excludes dynamic linking or hardware-specific features)

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Preliminary documentation is provided at https://github.com/arjunr2/WALI. Further detailed docs (if necessary) can be added once this PR lands

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Understood

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

To the best of my knowledge, it does not break any existing target in the ecosystem -- only minimal configuration-specific additions were made to support the target.

> Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

We can upstream LLVM target support
2025-03-11 07:21:45 +00:00
bors
374ce1f909 Auto merge of #136932 - m-ou-se:fmt-width-precision-u16, r=scottmcm
Reduce formatting `width` and `precision` to 16 bits

This is part of https://github.com/rust-lang/rust/issues/99012

This is reduces the `width` and `precision` fields in format strings to 16 bits. They are currently full `usize`s, but it's a bit nonsensical that we need to support the case where someone wants to pad their value to eighteen quintillion spaces and/or have eighteen quintillion digits of precision.

By reducing these fields to 16 bit, we can reduce `FormattingOptions` to 64 bits (see https://github.com/rust-lang/rust/pull/136974) and improve the in memory representation of `format_args!()`. (See additional context below.)

This also fixes a bug where the width or precision is silently truncated when cross-compiling to a target with a smaller `usize`. By reducing the width and precision fields to the minimum guaranteed size of `usize`, 16 bits, this bug is eliminated.

This is a breaking change, but affects almost no existing code.

---

Details of this change:

There are three ways to set a width or precision today:

1. Directly a formatting string, e.g. `println!("{a:1234}")`
2. Indirectly in a formatting string, e.g. `println!("{a:width$}", width=1234)`
3. Through the unstable `FormattingOptions::width` method.

This PR:

- Adds a compiler error for 1. (`println!("{a:9999999}")` no longer compiles and gives a clear error.)
- Adds a runtime check for 2. (`println!("{a:width$}, width=9999999)` will panic.)
- Changes the signatures of the (unstable) `FormattingOptions::[get_]width` methods to use a `u16` instead.

---

Additional context for improving `FormattingOptions` and `fmt::Arguments`:

All the formatting flags and options are currently:

- The `+` flag (1 bit)
- The `-` flag (1 bit)
- The `#` flag (1 bit)
- The `0` flag (1 bit)
- The `x?` flag (1 bit)
- The `X?` flag (1 bit)
- The alignment (2 bits)
- The fill character (21 bits)
- Whether a width is specified (1 bit)
- Whether a precision is specified (1 bit)
- If used, the width (a full usize)
- If used, the precision (a full usize)

Everything except the last two can simply fit in a `u32` (those add up to 31 bits in total).

If we can accept a max width and precision of u16::MAX, we can make a `FormattingOptions` that is exactly 64 bits in size; the same size as a thin reference on most platforms.

If, additionally, we also limit the number of formatting arguments, we can also reduce the size of `fmt::Arguments` (that is, of a `format_args!()` expression).
2025-03-11 04:07:05 +00:00
Arjun Ramesh
336a327f7c Target definition for wasm32-wali-linux-musl to support the Wasm Linux
Interface

This commit does not patch libc, stdarch, or cc
2025-03-10 21:26:45 -04:00
Scott McMurray
3c74d02319 debug-assert that the size_hint is well-formed in collect 2025-03-10 18:22:28 -07:00
Kevin Reid
8f32547147 Move offset_of_enum documentation to unstable book; add offset_of_slice. 2025-03-10 17:29:51 -07:00
Kevin Reid
58d4395c1a Expand and organize offset_of! documentation.
* Give example of how to get the offset of an unsized tail field
  (prompted by discussion <https://github.com/rust-lang/rust/pull/133055#discussion_r1986422206>).
* Specify the return type.
* Add section headings.
* Reduce “Visibility is respected…”, to a single sentence.
2025-03-10 16:23:54 -07:00
Kevin Reid
96814ae55f Rewrite example to not deal with Copy at all.
It also now demonstrates how to avoid memory leaks.
2025-03-10 15:03:36 -07:00
Nicole L
2b3b0bd50b Remove unused file 2025-03-10 14:19:27 -07:00
Kevin Reid
2cc999d0d4 Rewrite comments about dropping and leaking. 2025-03-10 13:54:07 -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