about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-01-06Rollup merge of #118781 - RalfJung:core-panic-feature, r=the8472Matthias Krüger-23/+23
merge core_panic feature into panic_internals I don't know why those are two separate features, but it does not seem intentional. This merge is useful because with https://github.com/rust-lang/rust/pull/118123, panic_internals is recognized as an internal feature, but core_panic is not -- but core_panic definitely should be internal.
2024-01-06Add assume into `NonZeroIntX::get`AngelicosPhosphoros-4/+18
LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments. Related to https://github.com/rust-lang/rust/issues/119422 Related to https://github.com/llvm/llvm-project/issues/76628 Related to https://github.com/rust-lang/rust/issues/49572
2024-01-06document rounding behavior of rint/nearbyint for tiesRalf Jung-6/+12
2024-01-06Fix typo in docs for slice::split_once, slice::rsplit_onceConnor Lane Smith-2/+2
2024-01-05Rollup merge of #119216 - weiznich:use_diagnostic_namespace_in_stdlib, ↵Michael Goulet-30/+31
r=compiler-errors Use diagnostic namespace in stdlib This required a minor fix to have the diagnostics shown in third party crates when the `diagnostic_namespace` feature is not enabled. See https://github.com/rust-lang/rust/pull/119216/commits/5d63f5d8d1a72167c1d5242b2e1ed5b7259fd526 for details. I've opted for having a single PR for both changes as it's really not that much code. If it is required it should be easy to split up the change into several PR's. r? `@compiler-errors`
2024-01-05Remove feature not required by `Ipv6Addr::to_cononical` doctestEthan Brierley-1/+0
The feature does not seem to be required by this doctest.
2024-01-05library: Add `allow(unused_assignments)` to custom MIR doctestVadim Petrochenkov-0/+1
The lint is not yet reported due to span issues, but will be reported later.
2024-01-05Rollup merge of #119583 - AngelicosPhosphoros:const_assume, r=RalfJungMichael Goulet-3/+1
Make `intrinsics::assume` const stable Closes https://github.com/rust-lang/rust/issues/76972 Blocks https://github.com/rust-lang/rust/pull/119452 Approved in https://github.com/rust-lang/rust/pull/119452#issuecomment-1875741678 r? `@RalfJung`
2024-01-05Fix #119551: Rewrite Iterator::position default impl, storing the ↵martha-6/+13
accumulating value outside of the fold in an attempt to improve code generation Squashed with: Add inheriting overflow checks back
2024-01-05Replace some usage of `#[rustc_on_unimplemented]` withGeorg Semmler-30/+31
`#[diagnostic::on_unimplemented]` This commit replaces those `#[rustc_on_unimplemented]` attributes with their equivalent `#[diagnostic::on_unimplemented]` where this is supported (So no filter or any extended option)
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-30/+30
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-05Fix a typo in core::ops::Deref's docLaura Demkowicz-Duffy-1/+1
2024-01-04Fixed ambiguity in hint.rsMing, Bai-1/+1
Needle and haystack are actually not the same, they remain constant.
2024-01-04Make `intrinsics::assume` const stableAngelicosPhosphoros-3/+1
Closes https://github.com/rust-lang/rust/issues/76972 Blocks https://github.com/rust-lang/rust/pull/119452 Approved in https://github.com/rust-lang/rust/pull/119452#issuecomment-1875741678
2024-01-04Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31Matthias Krüger-0/+10
Make offset_of field parsing use metavariable which handles any spacing As discussed at and around comments https://github.com/rust-lang/rust/issues/106655#issuecomment-1793485081 and https://github.com/rust-lang/rust/issues/106655#issuecomment-1793774183, the current arguments to offset_of do not accept all the whitespace combinations: `0. 1.1.1` and `0.1.1. 1` are currently treated specially in `tests/ui/offset-of/offset-of-tuple-nested.rs`. They also do not allow [forwarding individual fields as in](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=444cdf0ec02b99e8fd5fd8d8ecb312ca) ```rust macro_rules! off { ($a:expr) => { offset_of!(m::S, 0. $a) } } ``` This PR replaces the macro arguments with `($Container:ty, $($fields:expr)+ $(,)?)` which does allow any arrangement of whitespace that I could come up with and the forwarding of fields example above. This also allows for array indexing in the future, which I think is the last future extension to the syntax suggested in the offset_of RFC. Tracking issue for offset_of: #106655 ``@rustbot`` label F-offset_of ``@est31``
2024-01-04Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errorsMatthias Krüger-12/+45
custom mir: make it clear what the return block is Custom MIR recently got support for specifying the "unwind action", so now there's two things coming after the actual call part of `Call` terminators. That's not very self-explaining so I propose we change the syntax to imitate keyword arguments: ``` Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue()) ``` Also fix some outdated docs and add some docs to `Call` and `Drop`.
2024-01-02Make offset_of field parsing use metavariable which handles any spacingGeorge Bateman-0/+10
2024-01-02Adjust library tests for unused_tuple_struct_fields -> dead_codeJake Goulding-30/+30
2023-12-31Clarify ambiguity in select_nth_unstable docsBrian Romanowski-7/+7
2023-12-31Initial implementation of `str::from_raw_parts[_mut]`Sky-1/+42
2023-12-30Rollup merge of #119424 - ojeda:send-sync, r=est31Matthias Krüger-1/+3
Primitive docs: fix confusing `Send` in `&T`'s list The two lists in this document describe what traits are implemented on references when their underlying `T` also implements them. However, while it is true that `T: Send + Sync` implies `&T: Send` (which is what the sentence is trying to explain), it is confusing to have `Send` in the list because `T: Send` is not needed for that. In particular, the "also require" part may be interpreted as "both `T: Send` and `T: Sync` are required". Instead, move `Send` back to where it was before commit 7a477869b72e ("Makes docs for references a little less confusing"), i.e. to the `&mut` list (where no extra nota is needed, i.e. it fits naturally) and move the `Sync` definition/note to the bottom as something independent.
2023-12-29Primitive docs: fix confusing `Send` in `&T`'s listMiguel Ojeda-1/+3
The two lists in this document describe what traits are implemented on references when their underlying `T` also implements them. However, while it is true that `T: Send + Sync` implies `&T: Send` (which is what the sentence is trying to explain), it is confusing to have `Send` in the list because `T: Send` is not needed for that. In particular, the "also require" part may be interpreted as "both `T: Send` and `T: Sync` are required". Instead, move `Send` back to where it was before commit 7a477869b72e ("Makes docs for references a little less confusing"), i.e. to the `&mut` list (where no extra nota is needed, i.e. it fits naturally) and move the `Sync` definition/note to the bottom as something independent. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-12-28fix typoEmil Gardström-1/+1
2023-12-26custom mir: better type-checkingRalf Jung-7/+9
2023-12-26custom mir: make it clear what the return block isRalf Jung-9/+40
2023-12-26explain what crates should do when adding comparison with foreign typesRalf Jung-0/+38
2023-12-26PartialOrd: transitivity and duality are required only if the corresponding ↵Ralf Jung-6/+10
impls exist
2023-12-26PartialEq: handle longer transitive chainsRalf Jung-2/+4
2023-12-26Auto merge of #119133 - scottmcm:assert-unchecked, r=thomccbors-1/+49
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in https://github.com/rust-lang/libs-team/issues/315#issuecomment-1863159430 I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/119131
2023-12-25select AsyncFn traits during overloaded call opMichael Goulet-0/+3
2023-12-25We do not need impl_trait_in_assoc_tyMichael Goulet-7/+6
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-2/+1
2023-12-22Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnayMichael Goulet-1/+45
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-183/+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/+44
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-174/+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-1/+36
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