about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2019-10-25forgot pushfq/popqfq: fixedRaoul Strackx-0/+2
2019-10-25cleaning up codeRaoul Strackx-9/+4
2019-10-25removed unnecessary pushRaoul Strackx-1/+0
2019-10-25Rollup merge of #65731 - fusion-engineering-forks:set-extension, r=dtolnayMazdak Farrokhzad-11/+15
Prevent unnecessary allocation in PathBuf::set_extension. It was allocating a new `OsString` that was immediately dropped after using it with `set_file_name`. Now it directly changes the extension in the original buffer, without touching the rest of the file name or allocating a temporary string.
2019-10-25Rollup merge of #65685 - oxalica:statx-eperm, r=alexcrichtonMazdak Farrokhzad-42/+55
Fix check of `statx` and handle EPERM Should fix #65662 https://github.com/rust-lang/rust/issues/65662#issuecomment-544593939 > I think a reasonable solution might be to do something like try to stat AT_CWD initially and if that fails with EPERM or ENOSYS we disable the syscall entirely, otherwise it's cached as always good to use. r? @alexcrichton
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-25Mention park guaranteePaul Dicker-0/+4
2019-10-25Merge branch 'master' into rusty-hermit, resolve conflictsStefan Lankes-19/+19
2019-10-25Rollup merge of #65742 - Centril:gate-pre-expansion-subset, r=davidtwcoMazdak Farrokhzad-1/+2
Pre-expansion gate most of the things This is a subset of https://github.com/rust-lang/rust/pull/64672. A crater run has already been done and this PR implements conclusions according to https://github.com/rust-lang/rust/pull/64672#issuecomment-542703363. r? @davidtwco cc @petrochenkov
2019-10-24Adding doc on keyword continueYves Dorfsman-2/+33
2019-10-24Always align Waiter to 4 bytesPaul Dicker-0/+1
2019-10-24Use more precise atomic orderingsPaul Dicker-12/+41
2019-10-24In Waiter use interior mutability for threadPaul Dicker-9/+19
2019-10-24Reduce the amount of comments in call_innerPaul Dicker-19/+6
2019-10-24Move thread parking to a seperate functionPaul Dicker-38/+42
2019-10-24Turn Finish into WaiterQueuePaul Dicker-23/+21
2019-10-24Update hashbrown to 0.6.2Alex Crichton-1/+1
Pulls in rust-lang/hashbrown#119 which should be a good improvement for compile times of hashmap-heavy crates.
2019-10-24pre-expansion gate decl_macroMazdak Farrokhzad-1/+2
2019-10-23Rollup merge of #65479 - SimonSapin:matches, r=alexcrichtonMazdak Farrokhzad-0/+2
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-23Rollup merge of #64178 - mati865:clippy, r=scottmcmMazdak Farrokhzad-14/+12
More Clippy fixes for alloc, core and std Continuation of https://github.com/rust-lang/rust/pull/63805
2019-10-23Prevent unnecessary allocation in PathBuf::set_extension.Mara Bos-11/+15
It was allocating a new OsString that was immediately dropped after using it with set_file_name. Now it directly changes the extension in the original buffer, without touching the rest of the file name or allocating a temporary string.
2019-10-23Don't mutate waiter nodesPaul Dicker-9/+9
2019-10-23Move the `matches!` macro to the preludeSimon Sapin-10/+2
2019-10-23Add `core::macros::matches!( $expr, $pat ) -> bool`Simon Sapin-1/+11
# 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.) Back then, the main concern was that this macro may not be quite universally-enough useful to belong in the prelude. # API Therefore, this PR adds the macro such that using it requires one of: ``` use core::macros::matches; use std::macros::matches; ``` Like arms of a `match` expression, the macro supports multiple patterns separated by `|` and optionally followed by `if` and a guard expression: ``` let foo = 'f'; assert!(matches!(foo, 'A'..='Z' | 'a'..='z')); let bar = Some(4); assert!(matches!(bar, Some(x) if x > 2)); ``` # 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.
2019-10-23Simplify loop conditions in RUNNING and add commentsPaul Dicker-17/+29
2019-10-23Rename state to state_and_queuePaul Dicker-28/+29
2019-10-23Rollup merge of #65617 - newpavlov:patch-2, r=alexcrichtonYuki Okushi-4/+4
Fix WASI sleep impl Closes #65607 @sunfishcode Is it fine to use 0 for the `identifier` field? What is this field used for?
2019-10-23Some tweaksoxalica-49/+44
2019-10-22Apply clippy::single_match suggestionMateusz Mikuła-3/+2
2019-10-22Apply clippy::while_let_on_iterator suggestionsMateusz Mikuła-2/+1
2019-10-22Apply clippy::needless_return suggestionsMateusz Mikuła-9/+9
2019-10-22Merge branch 'master' into rusty-hermitStefan Lankes-55/+111
2019-10-22rename Error::iter_chain() and remove Error::iter_sources()Harald Hoyer-80/+12
Rename * Error::iter_chain() -> Error::chain() * ErrorIter -> Chain Removed * Error::iter_sources() according to https://github.com/rust-lang/rust/issues/58520 Rationale: 1. Such iterators are helpful. They should better be stabilized sooner than later. 2. self should be included. It is easy to .skip(1) it. Not including self is harmful because it is harder to add self to the iterator than to remove it. 3. The chosen name should be telling and reflect the fact that self is included. `.chain()` was chosen because the iterator iterates over the chain of errors that is somehow included in self. 4. The resulting iterator is named `Chain` because the `error::Chain` is what we want to have.
2019-10-22Fix check of `statx`oxalica-16/+34
2019-10-21Rollup merge of #65663 - Amanieu:typo, r=varkorMazdak Farrokhzad-1/+1
Fix typo from #65214
2019-10-21Rollup merge of #62330 - SimonSapin:no-drop-in-union-fields, r=RalfJungMazdak Farrokhzad-9/+9
Change untagged_unions to not allow union fields with drop This is a rebase of #56440, massaged to solve merge conflicts and make the test suite pass. Change untagged_unions to not allow union fields with drop Union fields may now never have a type with attached destructor. This for example allows unions to use arbitrary field types only by wrapping them in `ManuallyDrop` (or similar). The stable rule remains, that union fields must be `Copy`. We use the new rule for the `untagged_union` feature. Tracking issue: https://github.com/rust-lang/rust/issues/55149
2019-10-21add aarch64 support for HermitCoreStefan Lankes-1/+1
2019-10-21fixed ac vulnerabilityRaoul Strackx-0/+10
2019-10-21Fix typo from #65214Amanieu d'Antras-1/+1
2019-10-21Rollup merge of #65544 - dorfsmay:doc_keyword_break, r=Dylan-DPCYuki Okushi-2/+65
Added doc on keyword break RE: #34601
2019-10-21Rollup merge of #65639 - adrianheine:patch-2, r=jonas-schievinkMazdak Farrokhzad-1/+1
Fix parameter name in documentation
2019-10-21Rollup merge of #65633 - Rantanen:doc-example-paths, r=CentrilMazdak Farrokhzad-7/+7
Remove leading :: from paths in doc examples Noted some pre-2018 path syntax in the doc examples, for example: https://doc.rust-lang.org/std/process/fn.exit.html ```rust fn main() { ::std::process::exit(match run_app() { Ok(_) => 0, ... ``` Couldn't find an existing issue on this (then again, "::" makes for an annoying thing to search for) so if there is already something fixing this and/or there's a reason to not fix it, just close this PR. (Also fixed indentation in the `process::exit()` docs)
2019-10-20Fix parameter name in documentationAdrian Heine né Lang-1/+1
2019-10-20Remove leading :: from paths in doc examplesMikko Rantanen-7/+7
2019-10-20Rollup merge of #65551 - sinkuu:cstring_spec, r=sfacklerMazdak Farrokhzad-1/+26
Avoid realloc in `CString::new` If `&[u8]` or `&str` is given, `CString::new` allocates a new `Vec` with the exact capacity, and then `CString::from_vec_unchecked` calls `.reserve_exact(1)` for nul byte. This PR avoids the reallocation by allocationg `len + 1` bytes beforehand. In microbenchmark this PR speeds up `CString::new(&[u8])` by 30%.
2019-10-20Merge branch 'master' into rusty-hermitStefan Lankes-158/+418
2019-10-20move interface to the unikernel in the crate hermit-abiStefan Lankes-113/+57
=> simplifies the maintenance of the interface
2019-10-20fix WASI sleep implArtyom Pavlov-4/+4
2019-10-20Auto merge of #65469 - mati865:libc, r=alexcrichtonbors-34/+2
Update libc to 0.2.64 Passed local tests. cc potentially interested people: @gnzlbg @tlively
2019-10-18reworded loop value sentenceYves Dorfsman-2/+3