about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-11-05expand slice from_raw_part docsRalf Jung-18/+46
2019-11-05Rollup merge of #66038 - jdxcode:char-len, r=alexcrichtonPietro Albini-2/+2
doc(str): show example of chars().count() under len() the docs are great at explaining that .len() isn't like in other languages but stops short of explaining how to get the character length.
2019-11-05Rollup merge of #66019 - olegnn:fixed_std_iter_chain_docs, r=Mark-SimulacrumPietro Albini-1/+1
Improved std::iter::Chain documentation Replaces `strings two iterators` by `links two iterators` in `std::iter::Chain` documentation. I didn't find any meaning of `strings` which can be evaluated as `links` or `joins`. I don't think that `std::iter:Chain` works as a stringer or plays billiards. (https://www.lexico.com/en/definition/string).
2019-11-05Rollup merge of #65962 - kevincox:patch-1, r=sfacklerPietro Albini-5/+5
Fix logic in example. The example claims SuperiorThanZero and presumably Zero is not Superior than itself so it should not be allowed.
2019-11-05link from raw slice creation methods to safety requirementsRalf Jung-5/+14
2019-11-04Improve wording in the documentation of `Iterator::count()`.Artur Kovacs-4/+4
2019-11-04Fixed trailing whitespace.Artur Kovacs-1/+1
2019-11-04Minor style improvementsDaniel Henry-Mantilla-13/+7
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-11-04Fix documentation for `Iterator::count()`.Artur Kovacs-2/+3
2019-11-04more robust method checking through DefId and diagnostic_itemRalf Jung-0/+1
2019-11-02Auto merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikicbors-1/+21
Make <*const/mut T>::offset_from `const fn` This reenables offset_of cc @mjbshaw after https://github.com/rust-lang/rust/pull/63075 broke it
2019-11-02Rename SuperiorThanZero -> GreaterThanZeroKevin Cox-4/+4
2019-11-01doc(str): show example of chars().count() under len()Jeff Dickey-2/+2
the docs are great at explaining that .len() isn't like in other languages but stops short of explaining how to get the character length. r? @steveklabnik
2019-11-01Rollup merge of #66002 - lzutao:stablilize-float_to_from_bytes, r=SimonSapinTyler Mandry-24/+12
Stabilize float_to_from_bytes feature FCP completed in https://github.com/rust-lang/rust/issues/60446#issuecomment-548440175 Closes #60446
2019-11-01Rollup merge of #65960 - lzutao:doc-iter-example, r=CentrilTyler Mandry-21/+14
doc: reword iter module example and mention other methods
2019-11-01Rollup merge of #65902 - gilescope:issue62570, r=estebankTyler Mandry-2/+15
Make ItemContext available for better diagnositcs Fix #62570
2019-11-01Fixed std::iter::Chain documentationOleg Nosov-1/+1
2019-10-31Stabilize float_to_from_bytes featureLzu Tao-24/+12
2019-10-31Strengthen documentation discouraging implementing `Into` over `From`Ohad Ravid-9/+7
2019-10-31Change `Into` docs to refer only to older versions of rustOhad Ravid-6/+5
2019-10-30work around aggressive syntax feature gatingRalf Jung-0/+12
2019-10-30caller_location: use in core::panic!.Eduard-Mihai Burtescu-17/+15
2019-10-30doc: reword iter module example and mention other methodsLzu Tao-21/+14
2019-10-30Added a panic-on-uninhabited guard on get_ref and get_mutDaniel Henry-Mantilla-0/+2
2019-10-30Fix doctestsDaniel Henry-Mantilla-7/+19
2019-10-30Fix logic in example.Kevin Cox-1/+1
The example claims SuperiorThanZero and presumably Zero is not Superior than itself so it should not be allowed.
2019-10-30Make ItemContext available for better diagnositcs.Giles Cope-2/+15
2019-10-29Improved MaybeUninit::get_{ref,mut} documentationDaniel Henry-Mantilla-8/+151
2019-10-29doc: use new feature gate for c_void typeLzu Tao-1/+6
2019-10-28Rollup merge of #65877 - lzutao:iter-chain-once, r=CentrilMazdak Farrokhzad-3/+18
doc: introduce `once` in `iter::chain` document I find it hard to find which one to use with `chain` when I only need to chain one value. Also [`once`][1] talks about `chain`. [1]: https://doc.rust-lang.org/nightly/std/iter/fn.once.html
2019-10-28Rollup merge of #65664 - anp:panic-location, r=eddybMazdak Farrokhzad-11/+109
`std::panic::Location` is a lang_item, add `core::intrinsics::caller_location` (RFC 2091 3/N) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) @eddyb suggested doing this intrinsic implementation ahead of actually implementing the `#[track_caller]` attribute so that there's an easily tested intermediate step between adding the shim and wiring up the attribute.
2019-10-28Rollup merge of #64747 - ethanboxx:master, r=CentrilMazdak Farrokhzad-3/+1
Stabilize `Option::flatten` - PR: https://github.com/rust-lang/rust/pull/60256 - Tracking issue: https://github.com/rust-lang/rust/issues/60258 @elahn > I was trying to `flat_map()` and found `map().flatten()` does the trick. This has been on nightly for 4 months, can we stabilise it? @ethanboxx > @Centril Helped me get this merged. What is the stabilization process? @Centril > @ethanboxx I'd just file a PR to stabilize it and we'll ask T-libs to FCP. So here I am. I am was unsure what number to put in `since = "-"` so I copied what someone had done in a recent PR.
2019-10-28doc: introduce `once` in `iter::chain` documentLzu Tao-3/+18
2019-10-27Panicking infra uses &core::panic::Location.Adam Perry-11/+104
This allows us to remove `static_panic_msg` from the SSA<->LLVM boundary, along with its fat pointer representation for &str. Also changes the signature of PanicInfo::internal_contructor to avoid copying. Closes #65856.
2019-10-27Implement core::intrinsics::caller_location.Adam Perry-0/+5
Returns a `&core::panic::Location` corresponding to where it was called, also making `Location` a lang item.
2019-10-27Auto merge of #65519 - pnkfelix:issue-63438-trait-based-structural-match, ↵bors-2/+89
r=matthewjasper trait-based structural match implementation Moves from using a `#[structural_match]` attribute to using a marker trait (or pair of such traits, really) instead. Fix #63438. (This however does not remove the hacks that I believe were put into place to support the previous approach of injecting the attribute based on the presence of both derives... I have left that for follow-on work.)
2019-10-26Rollup merge of #65806 - fusion-engineering-forks:slice-ptr-range, r=CentrilYuki Okushi-1/+81
Add [T]::as_ptr_range() and [T]::as_mut_ptr_range(). Implementation of https://github.com/rust-lang/rfcs/pull/2791
2019-10-26Rollup merge of #65799 - ↵Yuki Okushi-11/+11
LukasKalbertodt:fill-array-value-iter-tracking-issue, r=Centril Fill tracking issue number for `array_value_iter` Thanks for [noticing](https://github.com/rust-lang/rust/pull/62959#discussion_r338930448)! r? @Centril
2019-10-25Fix slice::as_ptr_range doctest.Mara Bos-7/+10
2019-10-25Add {String,Vec}::into_raw_partsJake Goulding-0/+1
2019-10-25Explain why pointer::add in slice::as_ptr_range is safe.Mara Bos-0/+18
2019-10-25Migrate from `#[structural_match]` attribute a lang-item trait.Felix S. Klock II-2/+89
(Or more precisely, a pair of such traits: one for `derive(PartialEq)` and one for `derive(Eq)`.) ((The addition of the second marker trait, `StructuralEq`, is largely a hack to work-around `fn (&T)` not implementing `PartialEq` and `Eq`; see also issue rust-lang/rust#46989; otherwise I would just check if `Eq` is implemented.)) Note: this does not use trait fulfillment error-reporting machinery; it just uses the trait system to determine if the ADT was tagged or not. (Nonetheless, I have kept an `on_unimplemented` message on the new trait for structural_match check, even though it is currently not used.) Note also: this does *not* resolve the ICE from rust-lang/rust#65466, as noted in a comment added in this commit. Further work is necessary to resolve that and other problems with the structural match checking, especially to do so without breaking stable code (adapted from test fn-ptr-is-structurally-matchable.rs): ```rust fn r_sm_to(_: &SM) {} fn main() { const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to); let input: Wrap<fn(&SM)> = Wrap(r_sm_to); match Wrap(input) { Wrap(CFN6) => {} Wrap(_) => {} }; } ``` where we would hit a problem with the strategy of unconditionally checking for `PartialEq` because the type `for <'a> fn(&'a SM)` does not currently even *implement* `PartialEq`. ---- added review feedback: * use an or-pattern * eschew `return` when tail position will do. * don't need fresh_expansion; just add `structural_match` to appropriate `allow_internal_unstable` attributes. also fixed example in doc comment so that it actually compiles.
2019-10-25Add slice_ptr_range tracking issue number.Mara Bos-2/+2
2019-10-25Add [T]::as_ptr_range() and [T]::as_mut_ptr_range().Mara Bos-1/+60
See https://github.com/rust-lang/rfcs/pull/2791 for motivation.
2019-10-25Fill tracking issue number for `array_value_iter` and fix Rust versionLukas Kalbertodt-11/+11
2019-10-25RFC 2008: StabilizationDavid Wood-1/+1
This commit stabilizes RFC 2008 (#44109) by removing the feature gate. Signed-off-by: David Wood <david@davidtw.co>
2019-10-24Add unit tests for `array::IntoIter`Lukas Kalbertodt-1/+207
Many tests are based on tests by Josh Stone <cuviper@gmail.com>
2019-10-24Add `array::IntoIter` as a consuming/by-value array iteratorLukas Kalbertodt-0/+273
The iterator is implemented using const generics. It implements the traits `Iterator`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator` and `TrustedLen`. It also contains a public method `new` to create it from an array. `IntoIterator` was not implemented for arrays yet, as there are still some open questions regarding backwards compatibility. This commit only adds the iterator impl and does not yet offer a convenient way to obtain that iterator.
2019-10-23Rollup merge of #65479 - SimonSapin:matches, r=alexcrichtonMazdak Farrokhzad-0/+27
Add the `matches!( $expr, $pat ) -> bool` macro # Motivation This macro is: * General-purpose (not domain-specific) * Simple (the implementation is short) * Very popular [on crates.io](https://crates.io/crates/matches) (currently 37th in all-time downloads) * The two previous points combined make it number one in [left-pad index](https://twitter.com/bascule/status/1184523027888988160) score As such, I feel it is a good candidate for inclusion in the standard library. In fact I already felt that way five years ago: https://github.com/rust-lang/rust/pull/14685 (Although the proof of popularity was not as strong at the time.) # API <details> <del> Back then, the main concern was that this macro may not be quite universally-enough useful to belong in the prelude. Therefore, this PR adds the macro such that using it requires one of: ```rust use core::macros::matches; use std::macros::matches; ``` </del> </details> Like arms of a `match` expression, the macro supports multiple patterns separated by `|` and optionally followed by `if` and a guard expression: ```rust let foo = 'f'; assert!(matches!(foo, 'A'..='Z' | 'a'..='z')); let bar = Some(4); assert!(matches!(bar, Some(x) if x > 2)); ``` <details> <del> # Implementation constraints A combination of reasons make it tricky for a standard library macro not to be in the prelude. Currently, all public `macro_rules` macros in the standard library macros end up “in the prelude” of every crate not through `use std::prelude::v1::*;` like for other kinds of items, but through `#[macro_use]` on `extern crate std;`. (Both are injected by `src/libsyntax_ext/standard_library_imports.rs`.) `#[macro_use]` seems to import every macro that is available at the top-level of a crate, even if through a `pub use` re-export. Therefore, for `matches!` not to be in the prelude, we need it to be inside of a module rather than at the root of `core` or `std`. However, the only way to make a `macro_rules` macro public outside of the crate where it is defined appears to be `#[macro_export]`. This exports the macro at the root of the crate regardless of which module defines it. See [macro scoping](https://doc.rust-lang.org/reference/macros-by-example.html#scoping-exporting-and-importing) in the reference. Therefore, the macro needs to be defined in a crate that is not `core` or `std`. # Implementation This PR adds a new `matches_macro` crate as a private implementation detail of the standard library. This crate is `#![no_core]` so that libcore can depend on it. It contains a `macro_rules` definition with `#[macro_export]`. libcore and libstd each have a new public `macros` module that contains a `pub use` re-export of the macro. Both the module and the macro are unstable, for now. The existing private `macros` modules are renamed `prelude_macros`, though their respective source remains in `macros.rs` files. </del> </details>
2019-10-23Document guard expressions in `matches!`Simon Sapin-1/+4