summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2023-01-24Set version placeholders to 1.68Mark Rousskov-5/+5
2023-01-21Rollup merge of #106144 - tgross35:patch-1, r=Mark-SimulacrumMichael Goulet-0/+69
Improve the documentation of `black_box` There don't seem to be many great resources on how `black_box` should be used, so I added some information here
2023-01-20Rollup merge of #104672 - Voultapher:unify-sort-modules, r=thomccMichael Goulet-1/+521
Unify stable and unstable sort implementations in same core module This moves the stable sort implementation to the core::slice::sort module. By virtue of being in core it can't access `Vec`. The two `Vec` used by merge sort, `buf` and `runs`, are modelled as custom types that implement the very limited required `Vec` interface with the help of provided allocation and free functions. This is done to allow future re-use of functions and logic between stable and unstable sort. Such as `insert_head`. This is in preparation of #100856 and #104116. It only moves code, it *doesn't* change any of the sort related logic. This unlocks the ability to share `insert_head`, `insert_tail`, `swap_if_less` `merge` and more. Tagging ````@Mark-Simulacrum```` I hope this allows progress on #100856, by moving `merge_sort` here I hope future changes will be easier to review.
2023-01-20Rollup merge of #107067 - tmiasko:custom-mir-storage-statements, r=oli-obkMatthias Krüger-0/+2
Custom MIR: Support storage statements r? `@oli-obk` `@JakobDegen`
2023-01-19Custom MIR: Support storage statementsTomasz Miąsko-0/+2
2023-01-19Transform async ResumeTy in generator transformArpad Borsos-0/+5
- Eliminates all the `get_context` calls that async lowering created. - Replace all `Local` `ResumeTy` types with `&mut Context<'_>`. The `Local`s that have their types replaced are: - The `resume` argument itself. - The argument to `get_context`. - The yielded value of a `yield`. The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`. Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors. See <https://github.com/rust-lang/rust/issues/105501>. The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-18Rollup merge of #103702 - ↵Dylan DPC-48/+15
WaffleLapkin:lift-sized-bounds-from-pointer-methods-where-applicable, r=m-ou-se Lift `T: Sized` bounds from some `strict_provenance` pointer methods This PR removes requirement for `T` (pointee type) to be `Sized` to call `pointer::{addr, expose_addr, with_addr, map_addr}`. These functions don't use `T`'s size, so there is no reason for them to require this. Updated public API: cc ``@Gankra,`` #95228 r? libs-api
2023-01-18Rollup merge of #106997 - Sp00ph:introselect, r=scottmcmMatthias Krüger-0/+22
Add heapsort fallback in `select_nth_unstable` Addresses #102451 and #106933. `slice::select_nth_unstable` uses a quick select implementation based on the same pattern defeating quicksort algorithm that `slice::sort_unstable` uses. `slice::sort_unstable` uses a recursion limit and falls back to heapsort if there were too many bad pivot choices, to ensure O(n log n) worst case running time (known as introsort). However, `slice::select_nth_unstable` does not have such a fallback strategy, which leads to it having a worst case running time of O(n²) instead. #102451 links to a playground which generates pathological inputs that show this quadratic behavior. On my machine, a randomly generated slice of length `1 << 19` takes ~200µs to calculate its median, whereas a pathological input of the same length takes over 2.5s. This PR adds an iteration limit to `select_nth_unstable`, falling back to heapsort, which ensures an O(n log n) worst case running time (introselect). With this change, there was no noticable slowdown for the random input, but the same pathological input now takes only ~1.2ms. In the future it might be worth implementing something like Median of Medians or Fast Deterministic Selection instead, which guarantee O(n) running time for all possible inputs. I've left this as a `FIXME` for now and only implemented the heapsort fallback to minimize the needed code changes. I still think we should clarify in the `select_nth_unstable` docs that the worst case running time isn't currently O(n) (the original reason that #102451 was opened), but I think it's a lot better to be able to guarantee O(n log n) instead of O(n²) for the worst case.
2023-01-17Rollup merge of #106889 - scottmcm:windows-mut, r=cuviperMatthias Krüger-0/+16
Mention the lack of `windows_mut` in `windows` This is a common request, going back to at least 2015 (#23783), so mention in the docs that it can't be done and offer a workaround using <https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_slice_of_cells>. (See also URLO threads like <https://internals.rust-lang.org/t/a-windows-mut-method-on-slice/16941/10?u=scottmcm>.)
2023-01-17Add heapsort fallback in `select_nth_unstable`Markus Everling-0/+22
2023-01-16Constify `TypeId` ordering implsonestacked-1/+2
2023-01-15replace manual ptr arithmetic with ptr_subThe 8472-23/+7
2023-01-15Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviperMatthias Krüger-1/+1
doc: fix typo
2023-01-14Mention the lack of `windows_mut` in `windows`Scott McMurray-0/+16
2023-01-14doc: fix typoTrevor Spiteri-1/+1
2023-01-14Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPCMatthias Krüger-19/+19
Remove various double spaces in the libraries. I was just pretty bothered by this when reading the source for a function, and was suggested to check if this happened elsewhere.
2023-01-14Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcmMatthias Krüger-4/+19
libcore: make result of iter::from_generator Clone `@rustbot` label +A-generators
2023-01-14Fix some missed double spaces.André Vennberg-4/+4
2023-01-14Remove various double spaces in source comments.André Vennberg-15/+15
2023-01-14Rollup merge of #106762 - WaffleLapkin:atomicptr+as_mut_ptr, r=m-ou-seYuki Okushi-2/+38
Add `AtomicPtr::as_mut_ptr` See https://github.com/rust-lang/rust/issues/66893#issuecomment-720125447 r? thomcc
2023-01-14Rollup merge of #105172 - alexs-sh:issue-98861-fix-next, r=scottmcmYuki Okushi-0/+5
Added error documentation for write_fmt This continuation of work at rust-lang#98861
2023-01-14Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcmYuki Okushi-6/+7
reword Option::as_ref and Option::map examples The description for the examples of `Option::as_ref` and `Option::map` imply that the example is only doing type conversion, when it is actually finding the length of a string. Changes the wording to imply that some operation is being run on the value contained in the `Option` closes #104476
2023-01-13Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obkbors-10/+17
Const closures cc https://github.com/rust-lang/rust/issues/106003
2023-01-13Rollup merge of #106740 - petar-dambovaliev:float-iterator-hint, r=NilstriebYuki Okushi-0/+5
Adding a hint on iterator type errors Issue reference https://github.com/rust-lang/rust/issues/106728 - [x] add a case in the attribute - [x] add a test closes #106728
2023-01-12add note for float iteratorPetar Dambovaliev-0/+5
2023-01-12Make `// SAFETY` comment part of the doctest, and not surrounding codeMaybe Waffle-1/+1
2023-01-12Remove unused `mut` from a doctestMaybe Waffle-1/+1
2023-01-12Add `AtomicPtr::as_mut_ptr`Maybe Waffle-0/+36
2023-01-11Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, ↵Michael Goulet-1/+1
r=petrochenkov Stabilize f16c_target_feature Resolves https://github.com/rust-lang/stdarch/issues/1234 Library PR for stabilizing corresponding intrinsics: https://github.com/rust-lang/stdarch/pull/1366 See also #44839 tracking issue for target_feature
2023-01-11Rollup merge of #103800 - danielhenrymantilla:stabilize-pin-macro, r=dtolnayMichael Goulet-7/+3
Stabilize `::{core,std}::pin::pin!` As discussed [over here](https://github.com/rust-lang/rust/issues/93178#issuecomment-1295843548), it looks like a decent time to stabilize the `pin!` macro. ### Public API ```rust // in module `core::pin` /// API: `fn pin<T>($value: T) -> Pin<&'local mut T>` pub macro pin($value:expr $(,)?) { … } ``` - Tracking issue: #93178 (now all this needs is an FCP by the proper team?)
2023-01-11Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-seMichael Goulet-36/+75
doc: rewrite doc for signed int::{carrying_add,borrowing_sub} Reword the documentation for bigint helper methods, signed `int::{carrying_add,borrowing_sub}` (#85532). This change is a follow-up to #101889, which was for the unsigned methods.
2023-01-12test use in libcoreDeadbeef-10/+17
2023-01-11Stabilize `::{core,std}::pin::pin!`Daniel Henry-Mantilla-7/+3
2023-01-10Rollup merge of #105034 - HintringerFabian:improve_iterator_flatten_doc, ↵Yuki Okushi-0/+12
r=cuviper Add example for iterator_flatten Adds an Example to iterator_flatten Fixes #82687
2023-01-09Relocate changesFabian Hintringer-12/+12
2023-01-08Rollup merge of #104163 - H4x5:once-repeat-with-debug, r=dtolnayMichael Goulet-2/+22
Don't derive Debug for `OnceWith` & `RepeatWith` Closures don't impl Debug, so the derived impl is kinda useless. The behavior of not debug-printing closures is consistent with the rest of the iterator adapters/sources.
2023-01-07Improve the documentation of `black_box`Trevor Gross-0/+69
2023-01-07Rollup merge of #106564 - Folyd:feat-repeatn, r=scottmcmMatthias Krüger-1/+1
Change to immutable borrow when cloning element of RepeatN
2023-01-07Rollup merge of #104081 - joshlf:patch-6, r=dtolnayMatthias Krüger-0/+6
PhantomData layout guarantees
2023-01-07Don't derive Debug for `OnceWith` & `RepeatWith`Sky-2/+22
2023-01-07Change to immutable borrow when cloning element of RepeatNFolyd-1/+1
2023-01-06Remove HTML tags around warningGijs Burghoorn-6/+0
2023-01-05Better phrasing for hygiene of include macroGijs Burghoorn-4/+5
2023-01-04Tidy up whitespaceGijs Burghoorn-11/+11
2023-01-04Improve include macro documentationGijs Burghoorn-20/+44
2023-01-04Rollup merge of #106200 - compiler-errors:suggest-impl-trait, r=estebankMatthias Krüger-0/+1
Suggest `impl Fn*` and `impl Future` in `-> _` return suggestions Follow-up to #106172, only the last commit is relevant. Can rebase once that PR is landed for easier review. Suggests `impl Future` and `impl Fn{,Mut,Once}` in `-> _` return suggestions. r? `@estebank`
2023-01-03Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=AmanieuMichael Goulet-6/+17
default OOM handler: use non-unwinding panic, to match std handler The OOM handler in std will by default abort. This adjusts the default in liballoc to do the same, using the `can_unwind` flag on the panic info to indicate a non-unwinding panic. In practice this probably makes little difference since the liballoc default will only come into play in no-std situations where people write a custom panic handler, which most likely will not implement unwinding. But still, this seems more consistent. Cc `@rust-lang/wg-allocators,` https://github.com/rust-lang/rust/issues/66741
2023-01-03Suggest more impl Trait on `-> _`Michael Goulet-0/+1
2023-01-03Added error documentation for write_fmtAlexander Shirokov-0/+5
This continuation of work at rust-lang#98861
2023-01-03Auto merge of #95644 - WaffleLapkin:str_split_as_str_refactor_take2, r=Amanieubors-84/+104
`Split*::as_str` refactor I've made this patch almost a year ago, so the rename and the behavior change are in one commit, sorry 😅 This fixes #84974, as it's required to make other changes work. This PR - Renames `as_str` method of string `Split*` iterators to `remainder` (it seems like the `as_str` name was confusing to users) - Makes `remainder` return `Option<&str>`, to distinguish between "the iterator is exhausted" and "the tail is empty", this was [required on the tracking issue](https://github.com/rust-lang/rust/issues/77998#issuecomment-832696619) r? `@m-ou-se`