summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2022-10-29poll_fn and Unpin: fix pinningRalf Jung-4/+7
2022-10-08EscapeAscii is not an ExactSizeIteratorMichael Goulet-2/+0
(cherry picked from commit 8abcd4d23538aa1e4c1164bca2c96ce0d7eb57ed)
2022-09-19replace stabilization placeholdersPietro Albini-5/+5
2022-09-17Auto merge of #101784 - reitermarkus:const-memchr, r=thomccbors-25/+23
Simplify `const` `memchr`. Extracted from https://github.com/rust-lang/rust/pull/101607. Removes the need for `const_eval_select`.
2022-09-16Rollup merge of #101802 - chriss0612:const_fn_trait_ref_impls, r=fee1-deadDylan DPC-10/+15
Constify impl Fn* &(mut) Fn* Tracking Issue: [101803](https://github.com/rust-lang/rust/issues/101803) Feature gate: `#![feature(const_fn_trait_ref_impls)]` This feature allows using references to Fn* Items as Fn* Items themself in a const context.
2022-09-14Constify `PartialEq` for Ordering.raldone01-1/+14
2022-09-14Added Tracking Issue number.onestacked-5/+5
2022-09-14Constify impl Fn* &(mut) Fn*onestacked-10/+15
2022-09-14Simplify `const` `memchr`.Markus Reiter-25/+23
2022-09-13Rollup merge of #101754 - NaokiM03:rename-log-to-ilog, r=Dylan-DPCMatthias Krüger-1/+1
Fix doc of log function Hi. I found a forgotten documentation correction in the following pull request. https://github.com/rust-lang/rust/pull/100332 See also: https://github.com/rust-lang/rust/issues/70887
2022-09-13Fix doc of log functionNaokiM03-1/+1
2022-09-12Fix typo in concat_bytes documentationJay3332-1/+1
This fixes the typo `&[u8, _]` -> `&[u8; _]`
2022-09-12Rollup merge of #100291 - WaffleLapkin:cstr_const_methods, r=oli-obkGuillaume Gomez-12/+37
constify some `CStr` methods This PR marks the following public APIs as `const`: ```rust impl CStr { // feature(const_cstr_from_bytes) pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError>; pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError>; // feature(const_cstr_to_bytes) pub const fn to_bytes(&self) -> &[u8]; pub const fn to_bytes_with_nul(&self) -> &[u8]; pub const fn to_str(&self) -> Result<&str, str::Utf8Error>; } ``` r? ```@oli-obk``` (use of `const_eval_select` :P ) cc ```@mina86``` (you've asked for this <3 )
2022-09-12constify `CStr` methodsMaybe Waffle-12/+37
2022-09-12Rollup merge of #101671 - LingMan:ieee_754, r=Dylan-DPCDylan DPC-19/+19
Fix naming format of IEEE 754 standard Currently the documentation of f64::min refers to "IEEE-754 2008" while the documentation of f64::minimum refers to "IEEE 754-2019". Note that one has the format IEEE,hyphen,number,space,year while the other is IEEE,space,number,hyphen,year. The official IEEE site [1] uses the later format and it is also the one most commonly used throughout the codebase. Update all comments and - more importantly - documentation to consistently use the official format. [1] https://standards.ieee.org/ieee/754/4211/
2022-09-12Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726Dylan DPC-7/+2
Remove manual <[u8]>::escape_ascii `@rustbot` label: +C-cleanup
2022-09-12Auto merge of #100251 - compiler-errors:tuple-trait-2, r=jackh726bors-0/+9
Implement `std::marker::Tuple` Split out from #99943 (https://github.com/rust-lang/rust/pull/99943#pullrequestreview-1064459183). Implements part of rust-lang/compiler-team#537 r? `@jackh726`
2022-09-11Fix naming format of IEEE 754 standardLingMan-19/+19
Currently the documentation of f64::min refers to "IEEE-754 2008" while the documentation of f64::minimum refers to "IEEE 754-2019". Note that one has the format IEEE,hyphen,number,space,year while the other is IEEE,space,number,hyphen,year. The official IEEE site [1] uses the later format and it is also the one most commonly used throughout the codebase. Update all comments and - more importantly - documentation to consistently use the official format. [1] https://standards.ieee.org/ieee/754/4211/
2022-09-10Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-deadbors-60/+69
The `<*const T>::guaranteed_*` methods now return an option for the unknown case cc https://github.com/rust-lang/rust/issues/53020#issuecomment-1236932443 I chose `0` for "not equal" and `1` for "equal" and left `2` for the unknown case so backends can just forward to raw pointer equality and it works ✨ r? `@fee1-dead` or `@lcnr` cc `@rust-lang/wg-const-eval`
2022-09-09The `<*const T>::guaranteed_*` methods now return an option for the unknown caseOli Scherer-60/+69
2022-09-09Rollup merge of #101529 - mousetail:patch-2, r=thomccGuillaume Gomez-1/+2
Fix the example code and doctest for Formatter::sign_plus The provided example to the `sign_plus` method on `fmt` was broken, it displays the `-` sign twice for negative numbers. This pull request should fix the issue by `.abs()` ing the number so that the negative sign appears only once. It is just one possible solution to the issue, not sure if it's the best. However, this one will behave as expected when combined with fill and alignment operators.
2022-09-09Rollup merge of #101495 - bjorn3:pause-no-sse2, r=Mark-SimulacrumGuillaume Gomez-11/+8
Compile spin_loop_hint as pause on x86 even without sse2 enabled The x86 `pause` instruction was introduced with sse2, but because it is encoded as `rep nop`, it works just fine on cpu's without sse2 support. It just doesn't do anything.
2022-09-09Rollup merge of #101556 - compiler-errors:tweak-generator-print, r=jackh726Matthias Krüger-1/+1
Tweak future opaque ty pretty printing 1. The `Return` type of a generator doesn't need to be a lang item just for diagnostic printing of types 2. We shouldn't suppress the `Output = Ty` of a opaque future if the type is a int or float var.
2022-09-09Auto merge of #93873 - Stovent:big-ints, r=m-ou-sebors-0/+78
Reimplement `carrying_add` and `borrowing_sub` for signed integers. As per the discussion in #85532, this PR reimplements `carrying_add` and `borrowing_sub` for signed integers. It also adds unit tests for both unsigned and signed integers, emphasing on the behaviours of the methods.
2022-09-08Generator return doesn't need to be a lang itemMichael Goulet-1/+1
2022-09-07TypoMaurits van Riezen-1/+1
2022-09-07Add doctestMaurits van Riezen-0/+1
2022-09-07This example was brokenMaurits van Riezen-1/+1
The provided example to the `sign_plus` method on `fmt` is broken, it displays the `-` sign twice for negative numbers.
2022-09-06Compile spin_loop_hint as pause on x86 even without sse2 enabledbjorn3-11/+8
The x86 `pause` instruction was introduced with sse2, but because it is encoded as `rep nop`, it works just fine on cpu's without sse2 support. It just doesn't do anything.
2022-09-06Auto merge of #100733 - scottmcm:inline-from-from-identity, r=m-ou-sebors-0/+1
Inline `<T as From<T>>::from` I noticed (in https://github.com/rust-lang/rust/pull/100693#issuecomment-1218520141) that the MIR for <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=67097e0494363ee27421a4e3bdfaf513> has inlined most stuff ``` scope 5 (inlined <Result<i32, u32> as Try>::branch) ``` ``` scope 8 (inlined <Result<i32, u32> as Try>::from_output) ``` But yet the do-nothing `from` call was still there: ``` _17 = <u32 as From<u32>>::from(move _18) -> bb9; ``` So let's give this a try and see what perf has to say.
2022-09-06Rollup merge of #101412 - WaffleLapkin:improve_std_ptr_code_leftovers, ↵Dylan DPC-13/+13
r=scottmcm Some more cleanup in `core` - remove some integer casts from slice iter (proposed in https://github.com/rust-lang/rust/pull/100819#discussion_r951113196) - replace `as usize` casts with `usize::from` in slice sort (proposed in https://github.com/rust-lang/rust/pull/100822#discussion_r950768698) r? `@scottmcm`
2022-09-06Rollup merge of #101287 - Adam-Gleave:doc_bool_then_some, r=scottmcmDylan DPC-0/+6
Document eager evaluation of `bool::then_some` argument I encountered this earlier today and thought maybe `bool::then_some` could use a little addition to the documentation. It's pretty obvious with familiarity and from looking at the implementation, but the argument for `then_some` is eagerly evaluated, which means if you do the following (as I did), you can have a problem: ```rust // Oops! let _ = something .has_another_thing() .then_some(something.another_thing_or_panic()); ``` A note, similar to other methods with eagerly-evaluated arguments and a lazy alternative (`Option::or`, for example), could help point this out to people who forget (like me)!
2022-09-05Auto merge of #100759 - fee1-dead-contrib:const_eval_select_real_intrinsic, ↵bors-97/+153
r=oli-obk,RalfJung Make `const_eval_select` a real intrinsic This fixes issues where `track_caller` functions do not have nice panic messages anymore when there is a call to the function, and uses the MIR system to replace the call instead of dispatching via lang items. Fixes #100696.
2022-09-04Rollup merge of #101401 - mx00s:expand-const, r=fee1-deadMatthias Krüger-17/+43
Make `char::is_lowercase` and `char::is_uppercase` const Implements #101400.
2022-09-04replace `as usize` casts with `usize::from` in slice sortMaybe Waffle-4/+4
2022-09-04remove some integer casts from slice iterMaybe Waffle-9/+9
2022-09-04Address feedback from PR #101401Sage Mitchell-8/+12
2022-09-04Make `char::is_lowercase` and `char::is_uppercase` constSage Mitchell-17/+39
Implements #101400.
2022-09-04Auto merge of #101296 - compiler-errors:head-span-for-enclosing-scope, r=oli-obkbors-2/+82
Use head span for `rustc_on_unimplemented`'s `enclosing_scope` attr This may make #101281 slightly easier to understand
2022-09-04Add `inline(always)` to rt functionsDeadbeef-0/+4
2022-09-04Add `inline(always)` to function generated by macroDeadbeef-0/+1
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-97/+148
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-12/+78
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in #92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](https://github.com/rust-lang/compiler-team/issues/411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - https://github.com/rust-lang/compiler-team/issues/411 - https://github.com/rust-lang/rust/issues/99571
2022-09-04Address nits, rename enclosing_scope => parent_labelMichael Goulet-2/+82
2022-09-03Rollup merge of #99736 - ↵Dylan DPC-1/+1
lopopolo:lopopolo/gh-80996-partial-stabilization-bounds-as-ref, r=dtolnay Partially stabilize `bound_as_ref` by stabilizing `Bound::as_ref` Stabilizing `Bound::as_ref` will simplify the implementation for `RangeBounds<usize>` for custom range types: ```rust impl RangeBounds<usize> for Region { fn start_bound(&self) -> Bound<&usize> { // TODO: Use `self.start.as_ref()` when upstream `std` stabilizes: // https://github.com/rust-lang/rust/issues/80996 match self.start { Bound::Included(ref bound) => Bound::Included(bound), Bound::Excluded(ref bound) => Bound::Excluded(bound), Bound::Unbounded => Bound::Unbounded, } } fn end_bound(&self) -> Bound<&usize> { // TODO: Use `self.end.as_ref()` when upstream `std` stabilizes: // https://github.com/rust-lang/rust/issues/80996 match self.end { Bound::Included(ref bound) => Bound::Included(bound), Bound::Excluded(ref bound) => Bound::Excluded(bound), Bound::Unbounded => Bound::Unbounded, } } } ``` See: - #80996 - https://github.com/rust-lang/rust/issues/80996#issuecomment-1194575470 cc `@yaahc` who suggested partial stabilization.
2022-09-02Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahcGuillaume Gomez-6/+233
Add additional methods to the Demand type This adds on to the original tracking issue #96024 r? `````@yaahc`````
2022-09-01Rollup merge of #101190 - yjhn:patch-1, r=Mark-SimulacrumMatthias Krüger-12/+12
Make docs formulation more consistent for NonZero{int} Use third person, as it is used for other `std` documentation.
2022-09-01Remove trailing whitespaceAdam-Gleave-4/+4
2022-09-01Document eager evaluation of `bool::then_some` argumentAdam-Gleave-0/+6
2022-09-01Auto merge of #100707 - dzvon:fix-typo, r=davidtwcobors-14/+14
Fix a bunch of typo This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos