about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2025-02-04Auto merge of #136533 - jhpratt:rollup-s0ign8n, r=jhprattbors-168/+184
Rollup of 5 pull requests Successful merges: - #134777 (Enable more tests on Windows) - #135621 (Move some std tests to integration tests) - #135844 ( Add new tool for dumping feature status based on tidy ) - #136167 (Implement unstable `new_range` feature) - #136334 (Extract `core::ffi` primitives to a separate (internal) module) Failed merges: - #136201 (Removed dependency on the field-offset crate, alternate approach) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-04Rollup merge of #136518 - Urgau:fn_ptr-public-bound, r=NoratriebJacob Pratt-0/+3
Add note about `FnPtr` trait being exposed as public bound
2025-02-04Rollup merge of #136511 - joshtriplett:nonzero-cast-signed-unsigned, r=dtolnayJacob Pratt-2/+64
Add `cast_signed` and `cast_unsigned` methods for `NonZero` types Requested in https://github.com/rust-lang/rust/issues/125882 . Note that this keeps the same names as the methods currently present on other integer types. If we want to rename them, we can rename them all at the same time.
2025-02-04Rollup merge of #136398 - pitaj:unsafecell_access, r=dtolnayJacob Pratt-0/+84
add UnsafeCell direct access APIs - Implementation for ACP: https://github.com/rust-lang/libs-team/issues/521 - Tracking issue #136327
2025-02-04Rollup merge of #136334 - ricci009:primitivers, r=tgross35Jacob Pratt-168/+181
Extract `core::ffi` primitives to a separate (internal) module ### Introduce library/core/src/ffi/primitives.rs The regex preprocessing for PR #133944 would be more robust if the relevant types from core/src/ffi/mod.rs were first moved to library/core/src/ffi/primitives.rs, then there isn't a need to deal with traits / c_str / va_list / whatever might wind up in that module in the future r? `@tgross35`
2025-02-04Rollup merge of #136167 - pitaj:new_range, r=NadrierilJacob Pratt-0/+3
Implement unstable `new_range` feature Switches `a..b`, `a..`, and `a..=b` to resolve to the new range types. For rust-lang/rfcs#3550 Tracking issue #123741 also adds the re-export that was missed in the original implementation of `new_range_api`
2025-02-04Auto merge of #135265 - pascaldekloe:fmt-int-speed, r=tgross35,ChrisDentonbors-68/+75
Display of integers without raw pointers and without overflowing_literals The benchmarks as is measure formatting speed of literals. The first commit `black_box`-es input to simulate runtime speed instead. The second commit replaces `unsafe` pointer optimizations with plain array indices. The performance is equivalent on Apple M1. Needs peer review on Intel. Happy to do the 128-bit version too if such change is welcome.
2025-02-04specify a prim@slice in docsmay-1/+1
i am not quite sure how this failure is in any way related to this pr, since i am only touching inherent functions on str? but sure.
2025-02-04implement inherent str constructorsmay-0/+176
2025-02-03Add note about `FnPtr` being exposed as public boundUrgau-0/+3
2025-02-03primitive type migration from mod.rs to primitives.rsricci009-168/+181
2025-02-03Rename rustc_contract to contractCelina G. Val-10/+10
This has now been approved as a language feature and no longer needs a `rustc_` prefix. Also change the `contracts` feature to be marked as incomplete and `contracts_internals` as internal.
2025-02-03Improve contracts intrisics and remove wrapper functionCelina G. Val-26/+23
1. Document the new intrinsics. 2. Make the intrinsics actually check the contract if enabled, and remove `contract::check_requires` function. 3. Use panic with no unwind in case contract is using to check for safety, we probably don't want to unwind. Following the same reasoning as UB checks.
2025-02-03Separate contract feature gates for the internal machineryFelix S. Klock II-11/+11
The extended syntax for function signature that includes contract clauses should never be user exposed versus the interface we want to ship externally eventually.
2025-02-03Desugars contract into the internal AST extensionsFelix S. Klock II-0/+31
Check ensures on early return due to Try / Yeet Expand these two expressions to include a call to contract checking
2025-02-03Add `cast_signed` and `cast_unsigned` methods for `NonZero` typesJosh Triplett-0/+47
2025-02-03Express contracts as part of function header and lower it to the contract ↵Celina G. Val-1/+1
lang items includes post-developed commit: do not suggest internal-only keywords as corrections to parse failures. includes post-developed commit: removed tabs that creeped in into rustfmt tool source code. includes post-developed commit, placating rustfmt self dogfooding. includes post-developed commit: add backquotes to prevent markdown checking from trying to treat an attr as a markdown hyperlink/ includes post-developed commit: fix lowering to keep contracts from being erroneously inherited by nested bodies (like closures). Rebase Conflicts: - compiler/rustc_parse/src/parser/diagnostics.rs - compiler/rustc_parse/src/parser/item.rs - compiler/rustc_span/src/hygiene.rs Remove contracts keywords from diagnostic messages
2025-02-03contracts: added lang items that act as hooks for rustc-injected code to invoke.Felix S. Klock II-0/+38
see test for an example of the kind of injected code that is anticipated here.
2025-02-03Contracts core intrinsics.Felix S. Klock II-0/+32
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-02-03Mark `std::fmt::from_fn` as `#[must_use]`Yotam Ofek-0/+1
2025-02-03Rollup merge of #136289 - Pyr0de:oncecell-docs, r=tgross35Matthias Krüger-25/+28
OnceCell & OnceLock docs: Using (un)initialized consistently Changed * `set` / `initialize` / `full` to `initialized state` * `uninitialize` / `empty` to `uninitialized state` * `f` to `f()` * Added explaination of `uninitialized state` & `initialized state` [OnceCell Docs](https://doc.rust-lang.org/nightly/std/cell/struct.OnceCell.html) [OnceLock Docs](https://doc.rust-lang.org/nightly/std/sync/struct.OnceLock.html) Fixes #85716 ``@rustbot`` label +A-docs
2025-02-03no unsafe pointer and no overflowing_literals in fmt::Display of integersPascal S. de Kloe-68/+75
2025-02-03For NonZero impl macros, give unsigned impls access to the corresponding ↵Josh Triplett-2/+17
signed type There was a macro parameter giving signed impls access to the corresponding unsigned type, but not the other way around. This will allow implementing methods converting in both directions.
2025-02-03OnceCell & OnceLock docs: Using (un)initialized consistentlyPyrode-25/+28
2025-02-02Docs for f16 and f128: correct a typo and add detailsLaine Taffin Altman-7/+7
2025-02-02Rollup merge of #136434 - ↵Matthias Krüger-1/+5
RalfJung:rustc_allowed_through_unstable_modules-deprecation-required, r=compiler-errors rustc_allowed_through_unstable_modules: require deprecation message This changes the `#[rustc_allowed_through_unstable_modules]` attribute so that a deprecation message (ideally directing people towards the stable path) is required.
2025-02-02Rollup merge of #136283 - hkBst:patch-31, r=workingjubileeMatthias Krüger-4/+5
Update encode_utf16 to mention it is native endian Fixes #83102
2025-02-02Rollup merge of #134272 - RalfJung:destabilize-rustc_encodable_decodable, ↵Matthias Krüger-38/+0
r=oli-obk Remove rustc_encodable_decodable feature This has been shown in future-compat reports since Rust 1.79 (https://github.com/rust-lang/rust/pull/116016), released June 2024. Let's see if crater still finds any issues. Part of https://github.com/rust-lang/rust/issues/134301. Cc ``@rust-lang/libs-api``
2025-02-02rustc_allowed_through_unstable_modules: require deprecation messageRalf Jung-1/+5
2025-02-01Use `widening_mul`Tobias Decking-20/+1
2025-02-01add UnsafeCell direct access APIsPeter Jaszkowiak-0/+84
2025-02-01Rollup merge of #136364 - hkBst:ptr_cmp_docs, r=tgross35Matthias Krüger-3/+8
document that ptr cmp is unsigned Fixes #77497
2025-02-01Rollup merge of #136307 - WaffleLapkin:minminmin, r=scottmcmMatthias Krüger-33/+137
Implement all mix/max functions in a (hopefully) more optimization amendable way Previously the graph was like this: ``` min -> Ord::min -> min_by -> match on compare() (in these cases compare = Ord::cmp) ^ | min_by_key ``` now it looks like this: ``` min -> Ord::min -> `<=` <- min_by_key min_by -> `Ordering::is_le` of `compare()` ``` (`max*` and `minmax*` are the exact same, i.e. they also use `<=` and `is_le`) I'm not sure how to test this, but it should probably be easier for the backend to optimize. r? `@scottmcm` cc https://github.com/rust-lang/rust/issues/115939#issuecomment-2622161134
2025-02-01document ptr comparison being by addressMarijn Schouten-3/+8
2025-01-31More PR feedbackScott McMurray-7/+5
2025-01-31PR feedbackScott McMurray-9/+8
2025-01-31Add `unchecked_disjoint_bitor` with fallback intrinsic implementationScott McMurray-3/+116
2025-02-01Rollup merge of #136351 - Darksonn:coerce-pointee-docs, r=compiler-errorsMatthias Krüger-1/+189
Add documentation for derive(CoercePointee) Part of [RFC 3621][rfc] tracked by #123430. This text is heavily based on the guide-level explanation from the RFC. ``@rustbot`` label F-derive_coerce_pointee [rfc]: https://rust-lang.github.io/rfcs/3621-derive-smart-pointer.html
2025-02-01Rollup merge of #136163 - uellenberg:driftsort-off-by-one, r=Mark-SimulacrumMatthias Krüger-8/+22
Fix off-by-one error causing slice::sort to abort the program Fixes #136103. Based on the analysis by ``@jonathan-gruber-jg`` and ``@orlp.``
2025-01-31doc all differences of ptr:copy(_nonoverlapping) with memcpy and memmoveMarijn Schouten-3/+6
2025-01-31Auto merge of #134424 - 1c3t3a:null-checks, r=saethlinbors-0/+16
Insert null checks for pointer dereferences when debug assertions are enabled Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a `MirPass`. This inserts checks in the same places as the `CheckAlignment` pass and additionally also inserts checks for `Borrows`, so code like ```rust let ptr: *const u32 = std::ptr::null(); let val: &u32 = unsafe { &*ptr }; ``` will have a check inserted on dereference. This is done because null references are UB. The alignment check doesn't cover these places, because in `&(*ptr).field`, the exact requirement is that the final reference must be aligned. This is something to consider further enhancements of the alignment check. For now this is implemented as a separate `MirPass`, to make it easy to disable this check if necessary. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177. r? `@saethlin`
2025-01-31Add documentation for derive(CoercePointee)Alice Ryhl-1/+189
2025-01-31Insert null checks for pointer dereferences when debug assertions are enabledBastian Kersting-0/+16
Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2025-01-31Update encode_utf16 to mention it is native endianMarijn Schouten-4/+5
2025-01-31Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhprattbors-0/+18
Rollup of 9 pull requests Successful merges: - #132156 (When encountering unexpected closure return type, point at return type/expression) - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle) - #136281 (`rustc_hir_analysis` cleanups) - #136297 (Fix a typo in profile-guided-optimization.md) - #136300 (atomic: extend compare_and_swap migration docs) - #136310 (normalize `*.long-type.txt` paths for compare-mode tests) - #136312 (Disable `overflow_delimited_expr` in edition 2024) - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics) - #136323 (Fix a typo in conventions.md) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-31Rollup merge of #136300 - RalfJung:compare-and-swap, r=joboetJacob Pratt-0/+18
atomic: extend compare_and_swap migration docs Fixes https://github.com/rust-lang/rust/issues/80486
2025-01-31Rollup merge of #136296 - RalfJung:float-min-max, r=tgross35Jacob Pratt-8/+16
float::min/max: mention the non-determinism around signed 0 Turns out this can actually produce different results on different machines [in practice](https://github.com/rust-lang/rust/issues/83984#issuecomment-2623859230); that seems worth documenting. I assume LLVM will happily const-fold these operations so so there could be different results for the same input even on the same machine, depending on whether things get const-folded or not. `@nikic` I remember there was an LLVM soundness fix regarding scalar evolution for loops that had to recognize certain operations as non-deterministic... it seems to me that pass would also have to avoid predicting the result of `llvm.{min,max}num`, for the same reason? r? `@tgross35` Cc `@rust-lang/libs-api` If this lands we should also make Miri non-deterministic here. Fixes https://github.com/rust-lang/rust/issues/83984
2025-01-31Rollup merge of #135414 - tgross35:stabilize-const_black_box, r=dtolnayJacob Pratt-1/+4
Stabilize `const_black_box` This has been unstably const since #92226, but a tracking issue was never created. Per [discussion on Zulip][zulip], there should not be any blockers to making this const-stable. The function does not provide any functionality at compile time but does allow code reuse between const- and non-const functions, so stabilize it here. [zulip]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
2025-01-31implement all min/max fns in terms of `<`/`is_lt`Waffle Lapkin-15/+9
`<` seems to be the "lucky one" for llvm
2025-01-30implement unstable `new_range` featurePeter Jaszkowiak-0/+3
for RFC 3550, tracking issue #123741