about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2025-03-14Rollup merge of #138477 - compiler-errors:deny-bikeshed-guaranteed-no-drop, ↵León Orell Valerian Liehr-1/+5
r=lcnr Deny impls for `BikeshedGuaranteedNoDrop` r? lcnr
2025-03-14Rollup merge of #138353 - RalfJung:expose-provenance-must-use, r=ibraheemdevLeón Orell Valerian Liehr-1/+0
remove must_use from <*const T>::expose_provenance `<*mut T>::expose_provenance` does not have this attribute, and in fact the function is documented to have a side-effect, so there are perfectly legitimate use-cases where the return value would be ignored.
2025-03-14Auto merge of #138480 - jhpratt:rollup-y3b8wu5, r=jhprattbors-12/+173
Rollup of 16 pull requests Successful merges: - #136001 (Overhaul examples for PermissionsExt) - #136230 (Reword incorrect documentation about SocketAddr having varying layout) - #136892 (Sync Fuchsia target spec with clang Fuchsia driver) - #136911 (Add documentation URL to selected jobs) - #137870 ( Improve HashMap docs for const and static initializers) - #138179 (Add `src/tools/x` to the main workspace) - #138389 (use `expect` instead of `allow`) - #138396 (Enable metrics and verbose tests in PR CI) - #138398 (atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance) - #138432 (fix: remove the check of lld not supporting `@response-file)` - #138434 (Visit `PatField` when collecting lint levels) - #138441 (update error message) - #138442 (EUV: fix place of deref pattern's interior's scrutinee) - #138457 (Remove usage of legacy scheme paths on RedoxOS) - #138461 (Remove an outdated line from a test comment) - #138466 (Remove myself from libs review) Failed merges: - #138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-14Rollup merge of #138398 - RalfJung:atomic-intrinsics-provenance, r=nnethercoteJacob Pratt-1/+152
atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance The provenance semantics match what Miri implements and what the `AtomicPtr` API expects.
2025-03-14Rollup merge of #136230 - clarfonthey:net-memory-layout-assumptions, r=cuviperJacob Pratt-11/+21
Reword incorrect documentation about SocketAddr having varying layout This has no longer been the case since these types were moved to `core`. The note on portability remains, but it is reworded to not imply that the size varies by target.
2025-03-14Auto merge of #138157 - scottmcm:inline-more-tiny-things, r=oli-obkbors-2/+7
Allow more top-down inlining for single-BB callees This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them. Fixes #138136 ~~Draft as it's built atop #138135, which adds a mir-opt test that's a nice demonstration of this. To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
2025-03-14Deny impls for BikeshedGuaranteedNoDropMichael Goulet-1/+5
2025-03-13Rollup merge of #138162 - ehuss:library-2024, r=cuviperMatthias Krüger-1/+1
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-13atomic intrinsics: clarify which types are supported and (if applicable) ↵Ralf Jung-1/+152
what happens with provenance
2025-03-12Allow more top-down inlining for single-BB calleesScott McMurray-2/+7
This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
2025-03-13Update library/core/src/intrinsics/mod.rsClearLove-1/+1
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-13Update library/core/src/intrinsics/mod.rsClearLove-1/+1
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-13Update library/core/src/intrinsics/mod.rsClearLove-1/+1
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-12Reduce FormattingOptions to 64 bits.Mara Bos-187/+232
2025-03-12intrinsics: remove unnecessary leading underscore from argument namesRalf Jung-324/+317
2025-03-11Implement SliceIndex for ByteStrThalia Archibald-88/+97
2025-03-11Move ByteStr compare and index traits to a separate moduleThalia Archibald-273/+282
This parallels the layout of `core::str`.
2025-03-11Add `From<{integer}>` for `f16`/`f128` implsbeetrees-2/+48
2025-03-11Auto merge of #128440 - oli-obk:defines, r=lcnrbors-0/+23
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-11Migrate core to Rust 2024Eric Huss-1/+1
2025-03-11remove must_use from <*const T>::expose_provenanceRalf Jung-1/+0
2025-03-11Rollup merge of #135987 - hkBst:patch-20, r=joboetJakub Beránek-3/+15
Clarify iterator by_ref docs fixes #95143
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+23
2025-03-11Auto merge of #135651 - arjunr2:master, r=davidtwcobors-1/+4
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-11Auto merge of #136932 - m-ou-se:fmt-width-precision-u16, r=scottmcmbors-34/+46
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-10Target definition for `wasm32-wali-linux-musl` to support the Wasm LinuxArjun Ramesh-1/+4
Interface This commit does not patch libc, stdarch, or cc
2025-03-10debug-assert that the size_hint is well-formed in `collect`Scott McMurray-0/+9
2025-03-10Move `offset_of_enum` documentation to unstable book; add `offset_of_slice`.Kevin Reid-17/+9
2025-03-10Expand and organize `offset_of!` documentation.Kevin Reid-21/+41
* 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-10Rewrite example to not deal with `Copy` at all.Kevin Reid-17/+19
It also now demonstrates how to avoid memory leaks.
2025-03-10Rewrite comments about dropping and leaking.Kevin Reid-16/+26
2025-03-10Changing #[stable] tagNathaniel Woods-1/+1
2025-03-10Added `Clone` implementation for `ChunkBy`Nathaniel Woods-0/+7
2025-03-10add missing doc for intrinsicLemonJ-7/+24
2025-03-10Add #[track_caller] to from_usize.Mara Bos-0/+1
2025-03-10Remove unnecessary semicolon.Mara Bos-1/+1
2025-03-10Limit formatting width and precision to 16 bits.Mara Bos-34/+45
2025-03-10Rollup merge of #137585 - xizheyin:issue-135801, r=workingjubileeMatthias Krüger-5/+5
Update documentation to consistently use 'm' in atomic synchronization example Fixes #135801
2025-03-09Clarify iterator by_ref docsMarijn Schouten-3/+15
2025-03-08Add inherent versions of MaybeUninit::fill methods for slicesltdk-139/+181
2025-03-08Use `disjoint_bitor` inside `borrowing_sub`Tobias Decking-3/+8
2025-03-08Reword documentation about SocketAddr having varying layoutltdk-11/+21
2025-03-08Remove unneeded parentheses.Markus Reiter-6/+6
2025-03-07Expand `CloneToUninit` documentation.Kevin Reid-28/+131
* Clarify relationship to `dyn` after #133003. * Add an example of using it with `dyn` as #133003 enabled. * Add an example of implementing it. * Add links to Rust Reference for the mentioned concepts. * Mention that its method should rarely be called. * Replace parameter name `dst` with `dest` to avoids confusion between “DeSTination” and “Dynamically-Sized Type”. * Various small corrections.
2025-03-07Rollup merge of #138000 - RalfJung:atomic-rmw, r=AmanieuJacob Pratt-2/+3
atomic: clarify that failing conditional RMW operations are not 'writes' Fixes https://github.com/rust-lang/rust/issues/136669 r? ``@Amanieu`` Cc ``@rust-lang/opsem`` ``@chorman0773`` ``@gnzlbg`` ``@briansmith``
2025-03-07Rollup merge of #137606 - davidtwco:next-edition, r=traviscross,ehussJacob Pratt-0/+23
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-07Use `intrinsics::assume` instead of `hint::assert_unchecked`.Markus Reiter-2/+8
2025-03-07Never inline `lookup_slow`.Markus Reiter-0/+2
2025-03-07Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakisMatthias Krüger-0/+70
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-07Auto merge of #138155 - matthiaskrgr:rollup-xq5buio, r=matthiaskrgrbors-222/+184
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