about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-04-21Use it in the library, and `InstSimplify` it away in the easy placesScott McMurray-8/+25
2024-04-21Add an intrinsic that lowers to AggregateKind::RawPtrScott McMurray-0/+26
2024-04-21Rollup merge of #124184 - gurry:124152-suggest-unsigned-abs-in-abs-doc, ↵Guillaume Gomez-1/+2
r=jhpratt Suggest using `unsigned_abs` in `abs` documentation Fixes #124152
2024-04-20Auto merge of #124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxubors-2/+6
Rollup of 10 pull requests Successful merges: - #123379 (Print note with closure signature on type mismatch) - #123967 (static_mut_refs: use raw pointers to remove the remaining FIXME) - #123976 (Use fake libc in core test) - #123986 (lint-docs: Add redirects for renamed lints.) - #124053 (coverage: Branch coverage tests for lazy boolean operators) - #124071 (Add llvm-bitcode-linker to build manifest) - #124103 (Improve std::fs::Metadata Debug representation) - #124132 (llvm RustWrapper: explain OpBundlesIndirect argument type) - #124191 (Give a name to each distinct manipulation of pretty-printer FixupContext) - #124196 (mir-opt tests: rename unit-test -> test-mir-pass) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-20Rollup merge of #123976 - ChrisDenton:no-libc-in-std-doc-tests, ↵许杰友 Jieyou Xu (Joe)-2/+6
r=Mark-Simulacrum Use fake libc in core test The war on libc continues. Some platforms may not need to link to the libc crate (and it's possible some may not even have a libc), therefore we shouldn't require it for tests. This creates dummy `malloc` and `free` implementations for use in the pointer docs, but, keeps the public documentation looking the same as before.
2024-04-20Auto merge of #122013 - Swatinem:unicode-gen-fastpath, r=scottmcmbors-1/+5
Add a lower bound check to `unicode-table-generator` output This adds a dedicated check for the lower bound (if it is outside of ASCII range) to the output of the `unicode-table-generator` tool. This generalized the ASCII-only fast-path, but only for the `Grapheme_Extend` property for now, as that is the only one with a lower bound outside of ASCII.
2024-04-20Add a lower bound check to `unicode-table-generator` outputArpad Borsos-1/+5
This adds a dedicated check for the lower bound (if it is outside of ASCII range) to the output of the `unicode-table-generator` tool. This generalized the ASCII-only fast-path, but only for the `Grapheme_Extend` property for now, as that is the only one with a lower bound outside of ASCII.
2024-04-20Suggest using `unsigned_abs` in `abs` documentationGurinder Singh-1/+2
2024-04-20Auto merge of #124114 - scottmcm:better-checked, r=workingjubileebors-10/+47
Make `checked` ops emit *unchecked* LLVM operations where feasible For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write the checked methods in such a way that we stop emitting wrapping versions of them. For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither ```rust a.checked_sub(b).unwrap() ``` nor ```rust a.checked_sub(b).unwrap_unchecked() ``` actually optimizes to `sub nuw`. After this PR they do. cc #103299
2024-04-18Rollup merge of #123406 - krtab:fix_remainder_iterchunk, r=scottmcmJubilee-1/+14
Force exhaustion in iter::ArrayChunks::into_remainder Closes: #123333
2024-04-18Make `checked` ops emit *unchecked* LLVM operations where feasibleScott McMurray-10/+47
For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write then checked methods in such a way that we stop emitting wrapping versions of them. For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither ```rust a.checked_sub(b).unwrap() ``` nor ```rust a.checked_sub(b).unwrap_unchecked() ``` actually optimizes to `sub nuw`. After this PR they do.
2024-04-18Auto merge of #123144 - dpaoliello:arm64eclib, ↵bors-1/+1
r=GuillaumeGomez,ChrisDenton,wesleywiser Add support for Arm64EC to the Standard Library Adds the final pieces so that the standard library can be built for arm64ec-pc-windows-msvc (initially added in #119199) * Bumps `windows-sys` to 0.56.0, which adds support for Arm64EC. * Correctly set the `isEC` parameter for LLVM's `writeArchive` function. * Add `#![feature(asm_experimental_arch)]` to library crates where Arm64EC inline assembly is used, as it is currently unstable.
2024-04-18fix: make `str::from_raw_parts_mut` mutardi-1/+1
2024-04-17Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnayMatthias Krüger-5/+41
Document overrides of `clone_from()` in core/std As mentioned in https://github.com/rust-lang/rust/pull/96979#discussion_r1379502413 Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source". I reused some of the wording over and over for similar impls, but I'm not sure that the wording is actually *good*. Would appreciate feedback about that. Also, now some of these seem to provide pretty specific guarantees about behavior (e.g. will reuse the exact same allocation iff the len is the same), but I was basing it off of the docs for [`Box::clone_from`](https://doc.rust-lang.org/1.75.0/std/boxed/struct.Box.html#method.clone_from-1) - I'm not sure if providing those strong guarantees is actually good or not.
2024-04-17Address commentsNoa-1/+1
2024-04-16Rollup merge of #123859 - krtab:uneeded_clone, r=cuviperGuillaume Gomez-8/+8
Remove uneeded clones now that TrustedStep implies Copy This is a follow up to 11fa1764ee4819aa674ca861c5e9a8fafd7a59e6 (from #112083)
2024-04-16Add simple async drop glue generationzetanumbers-0/+288
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Remove uneeded clones now that TrustedStep implies CopyArthur Carcano-8/+8
This is a follow up to 11fa1764ee4819aa674ca861c5e9a8fafd7a59e6
2024-04-16Change intrinsic types to use `u32` instead of `T` to match stable reexportsMaybe Waffle-7/+79
2024-04-15Add support for Arm64EC to the Standard LibraryDaniel Paoliello-1/+1
2024-04-15Use fake libc in core testChris Denton-2/+6
2024-04-15Remove bound checks from `BorrowedBuf` and `BorrowedCursor` methodsBenoît du Garreau-6/+18
2024-04-14Rollup merge of #123915 - shenawy29:patch-1, r=NilstriebGuillaume Gomez-6/+6
improve documentation slightly regarding some pointer methods
2024-04-14Auto merge of #122268 - ChrisDenton:no-libc, r=Mark-Simulacrumbors-0/+11
Link MSVC default lib in core ## The Problem On Windows MSVC, Rust invokes the linker directly. This means only the objects and libraries Rust explicitly passes to the linker are used. In short, this is equivalent to passing `-nodefaultlibs`, `-nostartfiles`, etc for gnu compilers. To compensate for this [the libc crate links to the necessary libraries](https://github.com/rust-lang/libc/blob/a0f5b4b21391252fe38b2df9310dc65e37b07d9f/src/windows/mod.rs#L258-L261). The libc crate is then linked from std, thus when you use std you get the defaults back.or integrate with C/C++. However, this has a few problems: - For `no_std`, users are left to manually pass the default lib to the linker - Whereas `std` has the opposite problem, using [`/nodefaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/nodefaultlib-ignore-libraries?view=msvc-170) doesn't work as expected because Rust treats them as normal libs. This is a particular problem when you want to use e.g. the debug CRT libraries in their place or integrate with C/C++.. ## The solution This PR fixes this in two ways: - moves linking the default lib into `core` - passes the lib to the linker using [`/defaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/defaultlib-specify-default-library?view=msvc-170). This allows users to override it in the normal way (i.e. with [`/nodefaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/nodefaultlib-ignore-libraries?view=msvc-170)). This is more or less equivalent to what the MSVC C compiler does. You can see what this looks like in my second commit, which I'll reproduce here for convenience: ```rust // In library/core #[cfg(all(windows, target_env = "msvc"))] #[link( name = "/defaultlib:msvcrt", modifiers = "+verbatim", cfg(not(target_feature = "crt-static")) )] #[link(name = "/defaultlib:libcmt", modifiers = "+verbatim", cfg(target_feature = "crt-static"))] extern "C" {} ``` ## Alternatives - Add the above to `unwind` and `std` but not `core` - The status quo - Some other kind of compiler magic maybe This bares some discussion so I've t-libs nominated it.
2024-04-14improve documentation slightly regarding some pointer methodsMohamed El-Shenawy-6/+6
2024-04-14Move msvc libs to coreChris Denton-0/+11
2024-04-14Rollup merge of #123875 - Ghamza-Jd:master, r=joboetMatthias Krüger-6/+6
Doc: replace x with y for hexa-decimal fmt I found it a bit unintuitive to know which is variable and which is the format string in `format!("{x:x}")`, so I switched it to `y`.
2024-04-14Auto merge of #107462 - WaffleLapkin:from_iterator_for_tuple, r=dtolnaybors-0/+33
Implement `FromIterator` for `(impl Default + Extend, impl Default + Extend)` Similarly to how https://github.com/rust-lang/rust/pull/85835 implemented `Extend` for `(impl Extend, impl Extend)`: ```rust impl<A, B, AE, BE> FromIterator<(AE, BE)> for (A, B) where A: Default + Extend<AE>, B: Default + Extend<BE>, { ... } ```
2024-04-14Auto merge of #123819 - joboet:fmt_usize_marker, r=Mark-Simulacrumbors-45/+49
Get rid of `USIZE_MARKER` in formatting infrastructure An alternative to #123780. The `USIZE_MARKER` function used to differentiate between placeholder and count arguments is never called anyway, so we can just replace the function-pointer-comparison hack with an `enum` and an `unreachable_unchecked`, hopefully without causing a regression. CC `@RalfJung`
2024-04-13doc note that f16 and f128 hardware support is limitedultrabear-0/+6
2024-04-13Rollup merge of #123868 - eduardosm:stabilize-slice_ptr_len, r=jhprattJacob Pratt-19/+16
Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull Stabilized API: ```rust impl<T> *mut [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> *const [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> NonNull<[T]> { pub const fn is_empty(self) -> bool; } ``` FCP completed in tracking issue: https://github.com/rust-lang/rust/issues/71146
2024-04-13chore: replace x with y for hexa-decimal fmtHamza Jadid-6/+6
2024-04-12Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnullEduardo Sánchez Muñoz-19/+16
2024-04-12Rollup merge of #123833 - dpaoliello:stdarch, r=AmanieuMatthias Krüger-0/+1
Update stdarch submodule `asm_experimental_arch` is required in `core` as we're now using unstable inline assembly when building Arm64EC. Brings in the fix for <https://github.com/rust-lang/stdarch/issues/1555> (cc `@tslnc04).` r? `@Amanieu`
2024-04-12Auto merge of #123846 - matthiaskrgr:rollup-85y28av, r=matthiaskrgrbors-3/+3
Rollup of 3 pull requests Successful merges: - #123796 (Remove unused cargo-platform dependency from tidy) - #123830 (Remove `From` impls for unstable types that break inference) - #123842 (fix typo in pin.rs) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-12Rollup merge of #123842 - ShockYoungCHN:master, r=scottmcmMatthias Krüger-1/+1
fix typo in pin.rs correct "implemts" to "implements".
2024-04-12Rollup merge of #123830 - tgross35:f16-f128-from-inference-fix, r=NilstriebMatthias Krüger-2/+2
Remove `From` impls for unstable types that break inference Adding additional `From` implementations that fit `f32::from(<unaffixed float>)` broke inference. Remove these for now. I added a test to make sure this doesn't quietly change in the future, even though the behavior is not technically guaranteed https://github.com/rust-lang/rust/issues/123824#issuecomment-2050628184 Fixes: <https://github.com/rust-lang/rust/issues/123824>
2024-04-12Auto merge of #123783 - tgross35:f16-f128-debug-impl, r=Amanieubors-0/+224
Add a `Debug` impl and some basic functions to `f16` and `f128` `compiler_builtins` uses some convenience functions like `is_nan` and `is_sign_positive`. Add these, as well as a temporary implementation for `Debug` that prints the bit representation.
2024-04-12core: get rid of `USIZE_MARKER`joboet-45/+49
2024-04-12fix pin.rs typoYuanzhuo Yang-1/+1
correct "implemts" to "implements"
2024-04-11Update stdarch submoduleDaniel Paoliello-0/+1
2024-04-11Remove `From` impls for unstable types that break inferenceTrevor Gross-2/+2
Adding additional `From` implementations that fit `f32::from(<unaffixed float>)` broke inference. Remove these for now. Fixes: <https://github.com/rust-lang/rust/issues/123824>
2024-04-11Auto merge of #123823 - matthiaskrgr:rollup-8zdtggx, r=matthiaskrgrbors-4/+5
Rollup of 8 pull requests Successful merges: - #122882 (Avoid a panic in `set_output_capture` in the default panic handler) - #123523 (Account for trait/impl difference when suggesting changing argument from ref to mut ref) - #123744 (Silence `unused_imports` for redundant imports) - #123784 (Replace `document.write` with `document.head.insertAdjacent`) - #123798 (Avoid invalid socket address in length calculation) - #123804 (Stop using `HirId` for fn-like parents since closures are not `OwnerNode`s) - #123806 (Panic on overflow in `BorrowedCursor::advance`) - #123820 (Add my former address to .mailmap) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-11Rollup merge of #123806 - joboet:advanced_overflow, r=AmanieuMatthias Krüger-2/+3
Panic on overflow in `BorrowedCursor::advance` Passing `usize::MAX` to `advance` clearly isn't correct, but the current assertion fails to detect this when overflow checks are disabled. This isn't unsound, but should probably be fixed regardless.
2024-04-11Add a `Debug` impl and some basic functions to `f16` and `f128`Trevor Gross-0/+224
`compiler_builtins` uses some convenience functions like `is_nan` and `is_sign_positive`. Add these, as well as a temporary implementation for `Debug` that prints the bit representation.
2024-04-11core: panic on overflow in `BorrowedCursor`joboet-2/+3
2024-04-11Avoid invalid socket address in length calculationTobias Nießen-2/+2
2024-04-11Correct broken link in core::pin docTomoki Nakagawa-5/+5
2024-04-11Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnayLeón Orell Valerian Liehr-3/+1
Stabilize `cstr_count_bytes` Newly stable API: ```rust impl CStr { pub fn count_bytes(&self) -> usize; } ``` Const stabilization has not yet been decided, so that will continue to be gated under <https://github.com/rust-lang/rust/issues/113219>. FCP finished at https://github.com/rust-lang/rust/issues/114441#issuecomment-2016942573. Fixes: <https://github.com/rust-lang/rust/issues/114441>
2024-04-10Add primitive documentation for `f16` and `f128`Trevor Gross-0/+30