about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2019-11-02Auto merge of #65429 - Timmmm:withoptions, r=Mark-Simulacrumbors-2/+35
Add File::with_options This provides a more fluent API to create files with options, and also avoids the need to import OpenOptions. This implements @aldanor's [suggestion](https://github.com/rust-lang/rfcs/pull/2615#issuecomment-448591304) which was popular.
2019-11-01Rollup merge of #66005 - Wind-River:master_base, r=alexcrichtonTyler Mandry-1828/+60
vxWorks: remove code related unix socket r? @alexcrichton
2019-11-01Rollup merge of #65112 - jack-t:type-parens-lint, r=varkorTyler Mandry-3/+3
Add lint and tests for unnecessary parens around types This is my first contribution to the Rust project, so I apologize if I'm not doing things the right way. The PR fixes #64169. It adds a lint and tests for unnecessary parentheses around types. I've run `tidy` and `rustfmt` — I'm not totally sure it worked right, though — and I've tried to follow the instructions linked in the readme. I tried to think through all the variants of `ast::TyKind` to find exceptions to this lint, and I could only find the one mentioned in the original issue, which concerns types with `dyn`. I'm not a Rust expert, thought, so I may well be missing something. There's also a problem with getting this to build. The new lint catches several things in the, e.g., `core`. Because `x.py` seems to build with an equivalent of `-Werror`, what would have been warnings cause the build to break. I got it to build and the tests to pass with `--warnings warn` on my `x.py build` and `x.py test` commands.
2019-10-29vxWorks: remove all code related to UNIX socket as it is not supported by ↵BaoshanPang-1828/+60
vxWorks
2019-10-29Add lint for unnecessary parens around typesjack-t-3/+3
2019-10-29doc: use new feature gate for c_void typeLzu Tao-1/+1
2019-10-27Panicking infra uses &core::panic::Location.Adam Perry-8/+4
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-26Auto merge of #65167 - hermitcore:rusty-hermit, r=alexcrichtonbors-431/+2262
Redesign the interface to the unikernel HermitCore We are developing the unikernel HermitCore, where the kernel is written in Rust and is already part of the Rust Standard Library. The interface between the standard library and the kernel based on a small C library. With this pull request, we remove completely the dependency to C and use lld as linker. Currently, the kernel will be linked to the application as static library, which is published at https://github.com/hermitcore/libhermit-rs. We don’t longer support the C interface to the kernel. Consequently, we remove this part from the Rust Standard Library.
2019-10-26Rollup merge of #65791 - dorfsmay:doc_keyword_continue, r=Mark-SimulacrumMazdak Farrokhzad-2/+33
Adding doc on keyword continue Partial solution of issue #34601.
2019-10-26Rollup merge of #65810 - raoulstrackx:ac_mitigation, r=nagisaYuki Okushi-1/+7
SGX: Clear additional flag on enclave entry An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state. The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.
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-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-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-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-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-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
2019-10-18remove stray changeStefan Lankes-1/+2