about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-11-09Rename `elem_offset` to `element_offset`wr7-4/+4
2024-11-08remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic ↵Ralf Jung-78/+102
functions instead
2024-11-08mark is_val_statically_known intrinsic as stably const-callableRalf Jung-9/+5
2024-11-07core: move intrinsics.rs into intrinsics folderRalf Jung-0/+0
2024-11-07Rollup merge of #132665 - tyilo:nonzero-u-div-ceil, r=joboetJonas Böttiger-0/+29
Implement `div_ceil` for `NonZero<unsigned>` ACP: https://github.com/rust-lang/libs-team/issues/471
2024-11-06optimize char::to_digit and assert radix is at least 2Jacob Lifshay-13/+31
approved by t-libs: https://github.com/rust-lang/libs-team/issues/475#issuecomment-2457858458
2024-11-06Auto merge of #131721 - okaneco:const_eq_ignore_ascii_case, r=m-ou-sebors-3/+25
Add new unstable feature `const_eq_ignore_ascii_case` Tracking issue - #131719 Mark `[u8]`, `str` `eq_ignore_ascii_case` functions const --- The codegen for this implementation matches the existing `iter::zip` implementation better than incrementing with a counter while loop with counter - https://rust.godbolt.org/z/h9cs5zajc while let - https://rust.godbolt.org/z/ecMeMjjEb
2024-11-06Add `is_ascii` function optimized for x86-64 for [u8]okaneco-21/+69
The new `is_ascii` function is optimized to use the `pmovmskb` vector instruction which tests the high bit in a lane. This corresponds to the same check of whether a byte is ASCII so ASCII validity checking can be vectorized. This instruction does not exist on other platforms so it is likely to regress performance and is gated to all(target_arch = "x86_64", target_feature = "sse2"). Add codegen test Remove crate::mem import for functions included in the prelude
2024-11-06Auto merge of #132500 - RalfJung:char-is-whitespace-const, r=jhprattbors-3/+4
make char::is_whitespace unstably const I am adding this to the existing https://github.com/rust-lang/rust/issues/132241 feature gate, since `is_digit` and `is_whitespace` seem similar enough that one can group them together.
2024-11-05Add new implementation benchmarkokaneco-3/+42
Add LONG benchmarks for more comparison between the methods
2024-11-05Add new unstable feature `const_eq_ignore_ascii_case`okaneco-3/+25
Mark `[u8]`, `str` `eq_ignore_ascii_case` functions const
2024-11-06Auto merge of #132664 - matthiaskrgr:rollup-i27nr7i, r=matthiaskrgrbors-2/+3
Rollup of 5 pull requests Successful merges: - #131261 (Stabilize `UnsafeCell::from_mut`) - #131405 (bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip) - #132077 (Add a new `wide-arithmetic` feature for WebAssembly) - #132562 (Remove the `wasm32-wasi` target from rustc) - #132660 (Remove unused errs.rs file) Failed merges: - #131721 (Add new unstable feature `const_eq_ignore_ascii_case`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-05Rollup merge of #131261 - clarfonthey:unsafe-cell-from-mut, r=m-ou-seMatthias Krüger-2/+3
Stabilize `UnsafeCell::from_mut` Closes #111645. FCP: https://github.com/rust-lang/rust/issues/111645#issuecomment-2393893003 Note that because `const_mut_refs` and `const_refs_to_cell` was stabilized, it's okay to const-stabilize this method as well.
2024-11-05Auto merge of #132661 - matthiaskrgr:rollup-npytbl6, r=matthiaskrgrbors-456/+478
Rollup of 8 pull requests Successful merges: - #132259 (rustc_codegen_llvm: Add a new 'pc' option to branch-protection) - #132409 (CI: switch 7 linux jobs to free runners) - #132498 (Suggest fixing typos and let bindings at the same time) - #132524 (chore(style): sync submodule exclusion list between tidy and rustfmt) - #132567 (Properly suggest `E::assoc` when we encounter `E::Variant::assoc`) - #132571 (add const_eval_select macro to reduce redundancy) - #132637 (Do not filter empty lint passes & re-do CTFE pass) - #132642 (Add documentation on `ast::Attribute`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-05Implement div_ceil for NonZero<unsigned>Asger Hautop Drewsen-0/+29
2024-11-05Rollup merge of #132571 - RalfJung:const_eval_select_macro, r=oli-obkMatthias Krüger-456/+478
add const_eval_select macro to reduce redundancy I played around a bit with a macro to make const_eval_select invocations look a bit nicer and avoid repeating the argument lists. Here's what I got. What do you think? I didn't apply this everywhere yet because I wanted to gather feedback first. The second commit moves the macros from https://github.com/rust-lang/rust/pull/132542 into a more sensible place. It didn't seem worth its own PR and would conflict with this PR if done separately. Cc ``@oli-obk`` ``@saethlin`` ``@tgross35`` try-job: dist-aarch64-msvc
2024-11-05Rollup merge of #132473 - ZhekaS:core_fmt_radix_no_panic, r=joboetJubilee-1/+4
[core/fmt] Replace checked slice indexing by unchecked to support panic-free code Fixes #126425 Replace the potentially panicking `[]` indexing with `get_unchecked()` to prevent linking with panic-related code.
2024-11-05Rollup merge of #132153 - bjoernager:const-char-encode-utf16, r=dtolnayJubilee-3/+5
Stabilise `const_char_encode_utf16`. Closes: #130660 This PR stabilises the `const_char_encode_utf16` feature gate (i.e. support for `char::encode_utf16` in constant expressions). ~~Note that the linked tracking issue is as of this writing currently awaiting FCP until 2024-11-02.~~
2024-11-05add const_eval_select macro to reduce redundancyRalf Jung-456/+478
also move internal const_panic helpers to a better location
2024-11-04Rollup merge of #132606 - eduardosm:char-slice-str-pattern-doc, r=tgross35Jubilee-2/+2
Improve example of `impl Pattern for &[char]` The previous version used `['l', 'l']` as pattern, which would suggest that it matches the `ll` of `Hello world` as a whole.
2024-11-04most const intrinsics don't need an explicit rustc_const_unstable any moreRalf Jung-43/+35
2024-11-04add new rustc_const_stable_intrinsic attribute for const-stable intrinsicsRalf Jung-57/+57
2024-11-04convert all const-callable intrinsics into the new form (without extern block)Ralf Jung-968/+1110
2024-11-04Improve example of `impl Pattern for &[char]`Eduardo Sánchez Muñoz-2/+2
The previous version used `['l', 'l']` as pattern, which would suggest that it matches the `ll` of `Hello world` as a whole.
2024-11-04Fixed typo, rebasedEugene Shamis-1/+1
2024-11-04Updated SAFETY comment to address underflowEugene Shamis-2/+3
2024-11-04Replace checked slice indexing by unchecked to support panic-free codeEugene Shamis-1/+3
Fixes #126425 Replace the potentially panicking `[]` indexing with `get_unchecked()` to prevent linking with panic-related code.
2024-11-04Stabilise 'const_char_encode_utf16';Gabriel Bjørnager Jensen-3/+5
2024-11-03Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnayJubilee-931/+177
remove const-support for align_offset and is_aligned As part of the recent discussion to stabilize `ptr.is_null()` in const context, the general vibe was that it's okay for a const function to panic when the same operation would work at runtime (that's just a case of "dynamically detecting that something is not supported as a const operation"), but it is *not* okay for a const function to just return a different result. Following that, `is_aligned` and `is_aligned_to` have their const status revoked in this PR, since they do return actively wrong results at const time. In the future we can consider having a new intrinsic or so that can check whether a pointer is "guaranteed to be aligned", but the current implementation based on `align_offset` does not have the behavior we want. In fact `align_offset` itself behaves quite strangely in const, and that support needs a bunch of special hacks. That doesn't seem worth it. Instead, the users that can fall back to a different implementation should just use const_eval_select directly, and everything else should not be made const-callable. So this PR does exactly that, and entirely removes const support for align_offset. Closes some tracking issues by removing the associated features: Closes https://github.com/rust-lang/rust/issues/90962 Closes https://github.com/rust-lang/rust/issues/104203 Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-11-03Rollup merge of #132563 - frectonz:master, r=AmanieuJubilee-1/+9
Modify `NonZero` documentation to reference the underlying integer type This change updates the documentation for `NonZero` integer types to explicitly reference the underlying integer type each `NonZero` variant wraps, instead of using a general "integer" term. **Before** ![image](https://github.com/user-attachments/assets/b13bda82-007b-459c-8b22-e27d79005271) **After** ![image](https://github.com/user-attachments/assets/1d7fadc7-dce3-4b84-9b8f-d2bb81c05eb7)
2024-11-03Auto merge of #132479 - compiler-errors:fx-feat-yeet, r=fee1-deadbors-6/+6
Yeet the `effects` feature, move it onto `const_trait_impl` This PR merges the `effects` feature into the `const_trait_impl` feature. There's really no need to have two feature gates for one feature. After this PR, if `const_trait_impl` **is** enabled: * Users can use and define const traits * `HostEffect` const conditions will be enforced on the HIR * We re-check the predicates in MIR just to make sure that we don't "leak" anything during MIR lowering And if `const_trait_impl` **is not** enabled: * Users cannot use nor define const traits * `HostEffect` const conditions are not enforced on the HIR * We will raise a const validation error if we call a function that has any const conditions (i.e. const traits and functions with any `~const` in their where clasues) This should be the last step for us to be able to enable const traits in the standard library. We still need to re-constify `Drop` and `Destruct` and stuff for const traits to be particularly *useful* for some cases, but this is a good step :D r? fee1-dead cc `@rust-lang/project-const-traits`
2024-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-6/+6
2024-11-03Auto merge of #132542 - RalfJung:const_panic, r=tgross35bors-129/+142
add const_panic macro to make it easier to fall back to non-formatting panic in const Suggested by `@tgross35` r? `@tgross35`
2024-11-03remove const-support for align_offsetRalf Jung-931/+177
Operations like is_aligned would return actively wrong results at compile-time, i.e. calling it on the same pointer at compiletime and runtime could yield different results. That's no good. Instead of having hacks to make align_offset kind-of work in const-eval, just use const_eval_select in the few places where it makes sense, which also ensures those places are all aware they need to make sure the fallback behavior is consistent.
2024-11-03Modify `NonZero` documentation to reference the underlying integer typefrectonz-1/+9
This change updates the documentation for `NonZero` integer types to explicitly reference the underlying integer type each `NonZero` variant wraps, instead of using a general "integer" term.
2024-11-03Rollup merge of #132511 - RalfJung:const_arguments_as_str, r=dtolnayMatthias Krüger-5/+2
stabilize const_arguments_as_str FCP passed in the [tracking issue](https://github.com/rust-lang/rust/issues/103900#issuecomment-2397096659).
2024-11-03Rollup merge of #132503 - RalfJung:const-hash-map, r=AmanieuMatthias Krüger-10/+4
better test for const HashMap; remove const_hash leftovers The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (https://github.com/rust-lang/rust/issues/123197), so we also have a test that does not involve that type. The second commit removes the last remnants of https://github.com/rust-lang/rust/issues/104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`. Cc ``@rust-lang/libs-api`` ``@rust-lang/wg-const-eval`` Closes #104061 Related to https://github.com/rust-lang/rust/issues/102575
2024-11-03Rollup merge of #132499 - RalfJung:unicode_data.rs, r=tgross35Matthias Krüger-1/+1
unicode_data.rs: show command for generating file https://github.com/rust-lang/rust/pull/131647 made this an easily runnable tool, now we just have to mention that in the comment. :) Fixes https://github.com/rust-lang/rust/issues/131640.
2024-11-03Rollup merge of #131377 - rick-de-water:nonzero-exp, r=dtolnayMatthias Krüger-16/+41
Add LowerExp and UpperExp implementations to NonZero Adds `LowerExp` and `UpperExp` trait implementations to `NonZero`, as discussed in rust-lang/libs-team#458. I had to modify the macro to mark the new impls with a different rust version. Let me know if this is the right way to do it (first timer here!)
2024-11-03add const_panic macro to make it easier to fall back to non-formatting panic ↵Ralf Jung-129/+142
in const
2024-11-03stabilize const_arguments_as_strRalf Jung-5/+2
2024-11-03Auto merge of #132458 - RalfJung:rustc-const-unstable, r=Amanieubors-100/+0
get rid of a whole bunch of unnecessary rustc_const_unstable attributes In general, when a `const fn` is still unstable, it doesn't need a `#[rustc_const_unstable]` attribute. The only exception is functions that internally use things that can't be used in stable const fn yet. So this gets rid of a whole bunch of `#[rustc_const_unstable]` in libcore.
2024-11-02Add BorrowedBuf::into_filled{,_mut} methods to allow returning buffer with ↵Alex Saveau-0/+20
original lifetime
2024-11-02Rollup merge of #132482 - lukas-code:stab-attrs, r=NoratriebMatthias Krüger-3/+4
library: fix some stability annotations This PR updates some stability attributes to correctly reflect when some items actually got stabilized. Found while testing https://github.com/rust-lang/rust/pull/132481. ### `core::char` / `std::char` In https://github.com/rust-lang/rust/pull/26192, the `core::char` module got "stabilized" for 1.2.0, but the `core` crate itself was still unstable until 1.6.0. In https://github.com/rust-lang/rust/pull/49698, the `std::char` module was changed to a re-export of `core::char`, making `std::char` appear as "stable since 1.2.0", even though it was already stable in 1.0.0. By marking `core::char` as stable since 1.0.0, the docs will show correct versions for both `core::char` (since 1.6.0) and `std::char` (since 1.0.0). This is also consistent with the stabilities of similar re-exported modules like `core::mem`/`std::mem` for example. ### `{core,std}::array` and `{core,std}::array::TryFromSliceError` In https://github.com/rust-lang/rust/pull/58302, the `core::array::TryFromSliceError` type got stabilized for 1.34.0, together with `TryFrom`. At that point the `core::array` module was still unstable and a `std::array` re-export didn't exist, but `core::array::TryFromSliceError` could still be named due to https://github.com/rust-lang/rust/pull/95956 to existing yet. Then, `core::array` got stabilized and `std::array` got added, first targeting 1.36.0 in https://github.com/rust-lang/rust/pull/60657, but then getting backported for 1.35.0 in https://github.com/rust-lang/rust/pull/60838. This means that `core::array` and `std::array` actually got stabilized in 1.35.0 and `core::array::TryFromSliceError` was accessible through the unstable module in 1.34.0 -- mark them as such so that the docs display the correct versions.
2024-11-02remove const_hash feature leftoversRalf Jung-10/+4
2024-11-02make char::is_whitespace unstably constRalf Jung-3/+4
2024-11-02unicode_data.rs: show command for generating fileRalf Jung-1/+1
2024-11-02get rid of a whole bunch of unnecessary rustc_const_unstable attributesRalf Jung-100/+0
2024-11-02Rollup merge of #132398 - krtab:add_doc_link, r=NoratriebMatthias Krüger-5/+9
Add a couple of intra-doc links to str
2024-11-02fix some stability annotationsLukas Markeffsky-3/+4