about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2023-07-22Auto merge of #113746 - clarfonthey:ip_bits, r=thomccbors-52/+119
Add BITS, from_bits, to_bits to IP addresses ACP: rust-lang/libs-team#235 Tracking issue: #113744
2023-07-22Rollup merge of #113898 - ajtribick:encode_utf16_size_hint, r=cuviperMatthias Krüger-5/+16
Fix size_hint for EncodeUtf16 More realistic upper and lower bounds, and handle the case where the iterator is located within a surrogate pair. Resolves #113897
2023-07-22Rollup merge of #113252 - tgross35:const-cstr-from-ptr-tracking-issue, ↵Matthias Krüger-1/+1
r=ChrisDenton Update the tracking issue for `const_cstr_from_ptr` Tracking issue #101719 was for `const_cstr_methods`, #113219 is a new issue specific for `const_cstr_from_ptr`. (I believe #101719 could also be closed) ```@rustbot``` label +T-libs-api +A-docs
2023-07-22Rollup merge of #112490 - Alexendoo:c-char-cfg-all, r=cuviperMatthias Krüger-5/+0
Remove `#[cfg(all())]` workarounds from `c_char` Casts to type aliases are now ignored by Clippy https://github.com/rust-lang/rust-clippy/pull/8596 Closes https://github.com/rust-lang/rust-clippy/issues/8093
2023-07-21Clarify logic on bytes:code units ratioAndrew Tribick-2/+4
2023-07-21Auto merge of #105571 - kadiwa4:remove_atomic_init_consts, r=Amanieubors-50/+35
remove the unstable `core::sync::atomic::ATOMIC_*_INIT` constants Tracking issue: #99069 It would be weird to ever stabilise these as they are already deprecated.
2023-07-20Fix size_hint for EncodeUtf16Andrew Tribick-5/+14
2023-07-20Get `!nonnull` metadata consistently in slice iterators, without needing ↵Scott McMurray-79/+116
`assume`s
2023-07-18Link methods in From implsltdk-0/+4
2023-07-18remove the unstable `core::sync::atomic::ATOMIC_*_INIT` constantsKaDiWa-50/+35
2023-07-17Rollup merge of #113762 - alexpovel:master, r=NilstriebMatthias Krüger-1/+1
Fix typo Typo in a docstring, noticed [here](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or).
2023-07-17Rollup merge of #113750 - nipzu:italicize-sort-complexity, r=workingjubileeMatthias Krüger-1/+1
Add missing italicization to `sort_unstable_by_key` complexity Other methods like `sort_by_key` already had `m` italicized.
2023-07-16Fix typoAlex Povel-1/+1
2023-07-16Fix sort_unstable_by_key italicizationnipzu-1/+1
2023-07-15Add BITS, from_bits, to_bits to IP addressesltdk-52/+115
2023-07-16collect.rs: remove "Basic usage" text where not usefulTshepang Mbambo-6/+0
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+4
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-46/+10
2023-07-12Replace version placeholder to 1.72Mark Rousskov-4/+4
2023-07-11Auto merge of #113175 - bryangarza:safe-transmute-rustc-coinductive, ↵bors-0/+1
r=compiler-errors Enable coinduction support for Safe Transmute This patch adds the `#[rustc_coinductive]` annotation to `BikeshedIntrinsicFrom`, so that it's possible to compute transmutability for recursive types. ## Motivation Safe Transmute currently already supports references (#110662). However, if a type is implemented recursively, it leads to an infinite loop when we try to check if transmutation is safe. A couple simple examples that one might want to write, that are currently not possible to check transmutability for: ```rs #[repr(C)] struct A(&'static B); #[repr(C)] struct B(&'static A); ``` ```rs #[repr(C)] enum IList<'a> { Nil, Cons(isize, &'a IList<'a>) } #[repr(C)] enum UList<'a> { Nil, Cons(usize, &'a UList<'a>) } ``` Previously, `@jswrenn` was considering writing a co-inductive solver from scratch, just for the `rustc_tranmsute` crate. Later on as I started working on Safe Transmute myself, I came across the `#[rustc_coinductive]` annotation, which is currently only being used for the `Sized` trait. Leveraging this trait actually solved the problem entirely, and it saves a lot of duplicate work that would have had to happen in `rustc_transmute`.
2023-07-11Auto merge of #111717 - Urgau:uplift_fn_null_check, r=oli-obkbors-0/+2
Uplift `clippy::fn_null_check` lint This PR aims at uplifting the `clippy::fn_null_check` lint into rustc. ## `incorrect_fn_null_checks` (warn-by-default) The `incorrect_fn_null_checks` lint checks for expression that checks if a function pointer is null. ### Example ```rust let fn_ptr: fn() = /* somehow obtained nullable function pointer */ if (fn_ptr as *const ()).is_null() { /* ... */ } ``` ### Explanation Function pointers are assumed to be non-null, checking for their nullity is incorrect. ----- Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 `@rustbot` label: +I-lang-nominated r? compiler
2023-07-09Updated lines doc to include trailing carriage return notevallentin-3/+8
2023-07-09Rollup merge of #113469 - JohnTitor:rm-default-free-fn, r=AmanieuMatthias Krüger-45/+0
Remove `default_free_fn` feature Closes #73014 r? ``@Amanieu``
2023-07-08Rollup merge of #113064 - marcospb19:add-note-in-vec-swap-docs, ↵Matthias Krüger-0/+2
r=Mark-Simulacrum std: edit [T]::swap docs Add a note about what happens when index arguments are equal.
2023-07-08Remove `default_free_fn` featureYuki Okushi-45/+0
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-07-05Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd.Havard Eidnes-1/+6
2023-07-03Add diagnostic items for `<*mut _>::is_null` and `<*const _>::is_null`Urgau-0/+2
2023-07-01Update the tracking issue for `const_cstr_from_ptr`Trevor Gross-1/+1
Tracking issue #101719 was for `const_cstr_methods`, #113219 is a new issue specific for `const_cstr_from_ptr`.
2023-07-01Auto merge of #113194 - lu-zero:intrinsics-inline, r=thomccbors-3/+3
Mark wrapped intrinsics as inline(always) This should mitigate having the inliner decide not to inline when the architecture is lacking an implementation of TargetTransformInfo::areInlineCompatible aware of the target features (e.g. PowerPC as today). See https://github.com/rust-lang/stdarch/pull/1443#issuecomment-1613788080
2023-07-01Rollup merge of #113072 - tshepang:patch-1, r=cuviperMatthias Krüger-40/+0
str docs: remove "Basic usage" text where not useful Not "useful" in that there is only one example given
2023-06-30Mark wrapped intrinsics as inline(always)Luca Barbato-3/+3
This should mitigate having the inliner decide not to inline when the architecture is lacking an implementation of TargetTransformInfo::areInlineCompatible aware of the target features (e.g. PowerPC as today).
2023-06-30Rollup merge of #107624 - tgross35:const-cstr-methods, r=dtolnayMatthias Krüger-8/+10
Stabilize `const_cstr_methods` This PR seeks to stabilize `const_cstr_methods`. Fixes most of #101719 ## New const stable API ```rust impl CStr { // depends: memchr pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError> {...} // depends: const_slice_index pub const fn to_bytes(&self) -> &[u8] {} // depends: pointer casts pub const fn to_bytes_with_nul(&self) -> &[u8] {} // depends: str::from_utf8 pub const fn to_str(&self) -> Result<&str, str::Utf8Error> {} } ``` I don't think any of these methods will have any issue when `CStr` becomes a thin pointer as long as `memchr` is const (which also allows for const `strlen`) . ## Notes - `from_bytes_until_nul` relies on `const_slice_index`, which relies on `const_trait_impls`, and generally this should be avoided. After talking with Oli, it should be OK in this case because we could replace the ranges with pointer tricks if needed (worst case being those feature gates disappear). https://github.com/rust-lang/rust/pull/107624#discussion_r1101468480 - Making `from_ptr` const is deferred because it depends on `const_eval_select`. I have moved this under the new flag `const_cstr_from_ptr` https://github.com/rust-lang/rust/pull/107624#discussion_r1101555239 cc ``@oli-obk`` I think you're the const expert ``@rustbot`` modify labels: +T-libs-api +needs-fcp
2023-06-29Enable co-induction support for Safe TransmuteBryan Garza-0/+1
This patch adds the `#[rustc_coinductive]` annotation to `BikeshedIntrinsicFrom`, so that it's possible to compute transmutability for recursive types.
2023-06-29Rollup merge of #113054 - ↵Matthias Krüger-30/+60
Rageking8:make-`rustc_on_unimplemented`-std-agnostic, r=WaffleLapkin Make `rustc_on_unimplemented` std-agnostic See #112923 r? `@WaffleLapkin`
2023-06-29Rollup merge of #112670 - petrochenkov:typriv, r=eholkMatthias Krüger-6/+6
privacy: Type privacy lints fixes and cleanups See individual commits. Follow up to https://github.com/rust-lang/rust/pull/111801.
2023-06-29optimize Cstr/EscapeAscii displayThe 8472-1/+67
old: ascii::bench_ascii_escape_display_mixed 17.97µs/iter +/- 204.00ns ascii::bench_ascii_escape_display_no_escape 545.00ns/iter +/- 6.00ns new: ascii::bench_ascii_escape_display_mixed 4.99µs/iter +/- 56.00ns ascii::bench_ascii_escape_display_no_escape 91.00ns/iter +/- 1.00ns
2023-06-27std: edit [T]::swap docsJoão M. Bezerra-0/+2
Add a note telling that no elements change when arguments are equal
2023-06-27Change the wording in `std::fmt::Write::write_str`Tobias Bucher-2/+2
Refer to the error instead of expanding its name.
2023-06-27Make `rustc_on_unimplemented` std-agnosticRageking8-30/+60
2023-06-26str docs: remove "Basic usage" text where not usefulTshepang Mbambo-40/+0
Not "useful" in that there is only one example given
2023-06-26Auto merge of #113024 - Jerrody:master, r=thomccbors-1/+1
`Default`: Always inline primitive data types.
2023-06-26Auto merge of #111850 - the8472:external-step-by, r=scottmcmbors-36/+375
Specialize `StepBy<Range<{integer}>>` OLD iter::bench_range_step_by_fold_u16 700.00ns/iter +/- 10.00ns iter::bench_range_step_by_fold_usize 519.00ns/iter +/- 6.00ns iter::bench_range_step_by_loop_u32 555.00ns/iter +/- 7.00ns iter::bench_range_step_by_sum_reducible 37.00ns/iter +/- 0.00ns NEW iter::bench_range_step_by_fold_u16 49.00ns/iter +/- 0.00ns iter::bench_range_step_by_fold_usize 194.00ns/iter +/- 1.00ns iter::bench_range_step_by_loop_u32 98.00ns/iter +/- 0.00ns iter::bench_range_step_by_sum_reducible 1.00ns/iter +/- 0.00ns NEW + `-Ctarget-cpu=x86-64-v3` iter::bench_range_step_by_fold_u16 22.00ns/iter +/- 0.00ns iter::bench_range_step_by_fold_usize 80.00ns/iter +/- 1.00ns iter::bench_range_step_by_loop_u32 41.00ns/iter +/- 0.00ns iter::bench_range_step_by_sum_reducible 1.00ns/iter +/- 0.00ns I have only optimized for walltime of those methods, I haven't tested whether it eliminates bounds checks when indexing into slices via things like `(0..slice.len()).step_by(16)`.
2023-06-25Mark the StepBy specialization as unsafeThe 8472-8/+8
2023-06-25StepBy<Range<{int <= usize}>> can be TrustedLenThe 8472-1/+7
2023-06-25doccomments for StepBy specializationsThe 8472-0/+41
2023-06-25Always inline primitive data types.George-1/+1
2023-06-23Rollup merge of #112704 - RalfJung:dont-wrap-slices, r=ChrisDentonMatthias Krüger-10/+14
slice::from_raw_parts: mention no-wrap-around condition Cc https://github.com/rust-lang/rust/issues/83996. This probably needs to be mentioned in more places, so I am not closing that issue, but this here should help at least.
2023-06-23add inline annotation to concrete implsThe 8472-0/+7
otherwise they wouldn't be eligible for cross-crate inlining
2023-06-23Specialize StepBy<Range<{integer}>>The 8472-36/+321
For ranges < usize we determine the number of items StepBy would yield and then store that in the range.end instead of the actual end. This significantly simplifies calculation of the loop induction variable especially in cases where StepBy::step (an usize) could overflow the Range's item type
2023-06-21Finish up preliminary tvos support in libstdThom Chiovoloni-7/+16