about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2023-12-25Add AsyncFn family of traitsMichael Goulet-0/+110
2023-12-25Documented unsafe blockslch361-4/+12
2023-12-25Removed redundant bounds checking at Split's next and next_mut methodslch361-4/+4
2023-12-24Stabilize ip_in_core featureLinus Färnstrand-1/+1
2023-12-22Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnayMichael Goulet-1/+24
Add `IntoAsyncIterator` This introduces the `IntoAsyncIterator` trait and uses it in the desugaring of the unstable `for await` loop syntax. This is mostly added for symmetry with `Iterator` and `IntoIterator`. r? `@compiler-errors` cc `@rust-lang/libs-api,` `@rust-lang/wg-async`
2023-12-23Auto merge of #119211 - rust-lang:pa-master-1.77, r=Mark-Simulacrumbors-182/+30
Bump stage0 to 1.76 beta r? `@Mark-Simulacrum`
2023-12-22Use `IntoAsyncIterator` in `for await` loop desugaringEric Holk-0/+1
2023-12-22Add IntoAsyncIteratorEric Holk-1/+23
2023-12-22Auto merge of #118847 - eholk:for-await, r=compiler-errorsbors-0/+1
Add support for `for await` loops This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library. Given a loop like: ```rust for await i in iter { ... } ``` this is desugared to something like: ```rust let mut iter = iter.into_async_iter(); while let Some(i) = loop { match core::pin::Pin::new(&mut iter).poll_next(cx) { Poll::Ready(i) => break i, Poll::Pending => yield, } } { ... } ``` This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this. I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue. r? `@compiler-errors`
2023-12-22update cfg(bootstrap)sPietro Albini-173/+21
2023-12-22update version placeholdersPietro Albini-9/+9
2023-12-20Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcmbors-2/+0
do not allow ABI mismatches inside repr(C) types In https://github.com/rust-lang/rust/pull/115476 we allowed ABI mismatches inside `repr(C)` types. This wasn't really discussed much; I added it because from how I understand calling conventions, this should actually be safe in practice. However I entirely forgot to actually allow this in Miri, and in the mean time I have learned that too much ABI compatibility can be a problem for CFI (it can reject fewer calls so that gives an attacker more room to play with). So I propose we take back that part about ABI compatibility in `repr(C)`. It is anyway something that C and C++ do not allow, as far as I understand. In the future we might want to introduce a class of ABI compatibilities where we say "this is a bug and it may lead to aborting the process, but it won't lead to arbitrary misbehavior -- worst case it'll just transmute the arguments from the caller type to the callee type". That would give CFI leeway to reject such calls without introducing the risk of arbitrary UB. (The UB can still happen if the transmute leads to bad results, of course, but it wouldn't be due to ABI weirdness.) #115476 hasn't reached beta yet so if we land this before Dec 22nd we can just pretend this all never happened. ;) Otherwise we should do a beta backport (of the docs change at least). Cc `@rust-lang/opsem` `@rust-lang/types`
2023-12-19Add `hint::assert_unchecked`Scott McMurray-1/+49
2023-12-19Docs: Use non-SeqCst in module example of atomicsAngelicosPhosphoros-4/+9
I done this for this reasons: 1. The example now shows that there is more Orderings than just SeqCst. 2. People who would copy from example would now have more suitable orderings for the job. 3. SeqCst is both much harder to reason about and not needed in most situations. IMHO, we should encourage people to think and use memory orderings that is suitable to task instead of blindly defaulting to SeqCst.
2023-12-19Desugar for await loopsEric Holk-0/+1
2023-12-18Disable new intrinsics for bootstrapCaleb Zulawski-0/+2
2023-12-18Add Ipv6Addr::is_ipv4_mappedChristiaan Dirkx-0/+25
This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes: * Resolving merge conflicts (obviously) * Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate) * Added the must_use and rustc_const_unstable attributes the original didn't have I think it's a reasonably useful method. [1] https://github.com/rust-lang/rust/pull/86490
2023-12-17Add new intrinsicsCaleb Zulawski-0/+39
2023-12-17Further explain semanticsCaleb Zulawski-2/+13
2023-12-17Apply suggestions from code reviewCaleb Zulawski-2/+3
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17Improve simd_bitmask documentation and other minor fixesCaleb Zulawski-8/+15
2023-12-17State type requirements firstCaleb Zulawski-61/+62
2023-12-17Clarify UB and improve grammarCaleb Zulawski-4/+4
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17Add core::intrinsics::simdCaleb Zulawski-0/+413
2023-12-17do not allow ABI mismatches inside repr(C) typesRalf Jung-2/+0
2023-12-15Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-SimulacrumJubilee-0/+82
Add ASCII whitespace trimming functions to `&str` - Add `trim_ascii_start`, `trim_ascii_end`, and `trim_ascii` functions to `&str` for trimming ASCII whitespace - Add `#[inline]` to `[u8]` `trim_ascii` functions These functions are feature-gated by `#![feature(byte_slice_trim_ascii)]` #94035
2023-12-15Rollup merge of #118998 - jstasiak:improve-doc, r=workingjubileeJubilee-1/+1
Link to is_benchmark from the Ipv6Addr::is_global documentation All other relevant is_* methods are mentioned in the list of addresses here, is_benchmarking has been the only one missing.
2023-12-15Rollup merge of #118956 - danielhuang:patch-2, r=workingjubileeJubilee-2/+2
Make CStr documentation consistent ("nul" instead of "null") "nul" is used in method names and appears more often in the documentation than "null", so make all instances "nul" to keep it consistent.
2023-12-15Add link to is_benchmark from the Ipv6Addr::is_global documentationJakub Stasiak-1/+1
All other relevant is_* methods are mentioned in the list of addresses here, is_benchmarking has been the only one missing.
2023-12-15Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnayMatthias Krüger-21/+18
Stabilize `type_name_of_val` Make the following API stable: ```rust // in core::any pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str ``` This is a convenience method to get the type name of a value, as opposed to `type_name` that takes a type as a generic. Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue https://github.com/rust-lang/rust/issues/97156. Wording was also changed to direct most of the details to `type_name` so we don't have as much duplicated documentation. Fixes tracking issue #66359. There were two main concerns in the tracking issue: 1. Naming: `type_name_of` and `type_name_of_val` seem like the only mentioned options. Differences in opinion here come from `std::mem::{size_of, align_of, size_of_val, align_of_val}`. This PR leaves the name as `type_name_of_val`, but I can change if desired since it is pretty verbose. 2. What this displays for `&dyn`: I don't think that having `type_name_of_val` function resolve those is worth the headache it would be, see https://github.com/rust-lang/rust/issues/66359#issuecomment-1718480774 for some workarounds. I also amended the docs wording to leave it open-ended, in case we have means to change that behavior in the future. ``@rustbot`` label -T-libs +T-libs-api +needs-fcp r? libs-api
2023-12-15Stabilize `ptr::{from_ref, from_mut}`Maybe Waffle-2/+5
2023-12-15Use assert_unsafe_precondition for char::from_u32_uncheckedChris Denton-1/+8
Co-Authored-By: joboet <jonasboettiger@icloud.com>
2023-12-14Update c_str.rsDaniel Huang-2/+2
2023-12-13Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkovbors-0/+143
[`RFC 3086`] Attempt to try to resolve blocking concerns Implements what is described at https://github.com/rust-lang/rust/issues/83527#issuecomment-1744822345 to hopefully make some progress. It is unknown if such approach is or isn't desired due to the lack of further feedback, as such, it is probably best to nominate this PR to the official entities. `@rustbot` labels +I-compiler-nominated
2023-12-12Rollup merge of #118873 - lukas-code:fix_waker_getter_tracking_issue_number, ↵Jubilee-3/+3
r=workingjubilee fix `waker_getters` tracking issue number The feature currently links to the closed issue https://github.com/rust-lang/rust/issues/87021. Make it link to the tracking issue https://github.com/rust-lang/rust/issues/96992 instead.
2023-12-12Rollup merge of #118858 - mu001999:dead_code/clean, r=cuviperJubilee-3/+3
Remove dead codes in core Detected by #118257
2023-12-12Add ASCII whitespace trimming functions to `&str`okaneco-0/+82
Add `trim_ascii_start`, `trim_ascii_end`, and `trim_ascii` functions to `&str` for trimming ASCII whitespace under the `byte_slice_trim_ascii` feature gate. Add `inline` to `[u8]` `trim_ascii` functions
2023-12-12fix `waker_getters` tracking issue numberLukas Markeffsky-3/+3
2023-12-12Remove dead codes in corer01and-3/+3
2023-12-11Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwcobors-0/+16
Add lint against ambiguous wide pointer comparisons This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang. ## `ambiguous_wide_pointer_comparisons` *warn-by-default* The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands. ### Example ```rust let ab = (A, B); let a = &ab.0 as *const dyn T; let b = &ab.1 as *const dyn T; let _ = a == b; ``` ### Explanation The comparison includes metadata which may not be expected. ------- This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one. ~~One thing: is the current naming right? `invalid` seems a bit too much.~~ Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, ↵bors-0/+12
r=compiler-errors Restore `const PartialEq` And thus fixes a number of tests. There is a bug that still needs to be fixed, so WIP for now. r? `@compiler-errors`
2023-12-11Auto merge of #118032 - RalfJung:char-u32, r=Mark-Simulacrumbors-4/+5
guarantee that char and u32 are ABI-compatible In https://github.com/rust-lang/rust/pull/116894 we added a guarantee that `char` has the same alignment as `u32`, but there is still one axis where these types could differ: function call ABI. So let's nail that down as well: in a function signature, `char` and `u32` are completely equivalent. This is a new stable guarantee, so it will need t-lang approval.
2023-12-10Restore `const PartialEq`Deadbeef-0/+12
2023-12-10remove redundant importssurechen-35/+20
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09merge core_panic feature into panic_internalsRalf Jung-23/+23
2023-12-08Implement `async gen` blocksMichael Goulet-0/+25
2023-12-08Rollup merge of #118505 - CLEckhardt:update_ip_addr_bits_docs, r=cuviperMatthias Krüger-4/+48
Elaborate on ip_addr bit conversion endianness Adds explanation of how endianness is handled when converting `Ipv4Addr` and `Ipv6Addr` to and from bits. This is intended to unblock stabilization of the affected methods. Addresses #113744
2023-12-07Introduce explanation about fields being used in orderingLudwig Neste-2/+4
2023-12-07Elaborate on ip_addr bit conversion endiannessChris Eckhardt-4/+48
Adds explanation of how endianness is handled when converting `Ipv4Addr` and `Ipv6Addr` to and from bits. Addresses #113744
2023-12-06Allow ambiguous_wide_pointer_comparisons lint for std methodsUrgau-0/+14