about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2020-06-08Auto merge of #72655 - jethrogb:sgx-lvi-hardening, r=petrochenkovbors-6/+16
Enable LVI hardening for x86_64-fortanix-unknown-sgx This implements mitigations for the Load Value Injection vulnerability (CVE-2020-0551) for the `x86_64-fortanix-unknown-sgx` target by enabling new LLVM passes. More information about LVI and mitigations may be found at https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection. This PR unconditionally enables the mitigations for `x86_64-fortanix-unknown-sgx` since there is no available hardware that doesn't require the mitigations. This may be reconsidered in the future. * [x] This depends on https://github.com/rust-lang/compiler-builtins/pull/359/
2020-06-08Rollup merge of #72963 - poliorcetics:cstring-from-raw, r=dtolnayRalf Jung-0/+11
Cstring `from_raw` and `into_raw` safety precisions Fixes #48525. Fixes #68456. This issue had two points: - The one about `from_raw` has been addressed (I hope). - The other one, about `into_raw`, has only been partially fixed. About `into_raw`: the idea was to: > steer users away from using the pattern of CString::{into_raw,from_raw} when interfacing with C APIs that may change the effective length of the string by writing interior NULs or erasing the final NUL I tried making a `Vec<c_char>` like suggested but my current solution feels very unsafe and *hacky* to me (most notably the type cast), I included it here to make it available for discussion: ```rust fn main() { use std::os::raw::c_char; let v = String::from("abc") .bytes() // From u8 to i8, // I feel like it will be a problem for values of u8 > 255 .map(|c| c as c_char) .collect::<Vec<_>>(); dbg!(v); } ```
2020-06-08Rollup merge of #72761 - poliorcetics:use-keyword-doc, r=Dylan-DPCRalf Jung-2/+54
Added the documentation for the 'use' keyword This is a partial fix of #34601. I heavily inspired myself from the Reference on the `use` keyword. I checked the links when compiling the documentation, they should be ok. I also added an example for the wildcard `*` in the case of types, because it's behaviour is not *import everything* like one might think at first.
2020-06-07Enable LVI hardening for x86_64-fortanix-unknown-sgxJethro Beekman-6/+16
2020-06-05Auto merge of #72957 - Mark-Simulacrum:bootstrap-bump, r=sfacklerbors-34/+8
Bump bootstrap compiler to 1.45 Pretty standard update.
2020-06-03Hexagon libstd: fix typo for c_ulonglongBrian Cain-1/+1
2020-06-03Added a warning to CString::into_raw tooAlexis Bourget-0/+5
2020-06-03Added the documentation about length to CString::from_rawAlexis Bourget-0/+6
2020-06-03Bump to 1.46Mark Rousskov-34/+8
2020-06-03Rollup merge of #72924 - JohnTitor:stabilize-buf-capacity, r=shepmasterDylan DPC-4/+2
Stabilize `std::io::Buf{Reader, Writer}::capacity` Closes #68833 FCP is done here: https://github.com/rust-lang/rust/issues/68833#issuecomment-637596083
2020-06-03Stabilize `std::io::Buf{Reader, Writer}::capacity`Yuki Okushi-4/+2
2020-06-01Add a warning about infinite reading in read_(until|line)Alexis Bourget-0/+8
2020-05-31Auto merge of #72813 - RalfJung:rollup-4ko6q8j, r=RalfJungbors-4/+3
Rollup of 5 pull requests Successful merges: - #72683 (from_u32_unchecked: check validity, and fix UB in Wtf8) - #72715 (Account for trailing comma when suggesting `where` clauses) - #72745 (generalize Borrow<[T]> for Interned<'tcx, List<T>>) - #72749 (Update stdarch submodule to latest head) - #72781 (Use `LocalDefId` instead of `NodeId` in `resolve_str_path_error`) Failed merges: r? @ghost
2020-05-31Rollup merge of #72683 - RalfJung:char-debug-check, r=Mark-SimulacrumRalf Jung-4/+3
from_u32_unchecked: check validity, and fix UB in Wtf8 Fixes https://github.com/rust-lang/rust/issues/72760
2020-05-31Auto merge of #72759 - alexcrichton:update-compiler-builtins, r=Mark-Simulacrumbors-1/+1
Update compiler-builtins Pulls in a fix for #72758, more details on the linked issue. [Crate changes included here][changes] [changes]: https://github.com/rust-lang/compiler-builtins/compare/0.1.28...0.1.31 Closes #72758
2020-05-30Remove the fn main() in code examplePoliorcetics-3/+1
2020-05-30Apply suggestions from code review Poliorcetics-2/+2
Fix suggestions from review. Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
2020-05-30encode_utf8_raw is not always valid UTF-8; clarify commentsRalf Jung-1/+1
2020-05-30also expose and use encode_utf16_raw for wtf8Ralf Jung-2/+1
2020-05-30wtf8: use encode_utf8_rawRalf Jung-2/+2
2020-05-30Rollup merge of #72162 - cuviper:extend_one, r=Mark-SimulacrumYuki Okushi-0/+65
Add Extend::{extend_one,extend_reserve} This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-29Remove an old comment from HashMap::extend_reserveJosh Stone-1/+0
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+66
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-29Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJungbors-80/+78
Rollup of 9 pull requests Successful merges: - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes) - #71095 (impl From<[T; N]> for Box<[T]>) - #71500 (Make pointer offset methods/intrinsics const) - #71804 (linker: Support `-static-pie` and `-static -shared`) - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn) - #72103 (borrowck `DefId` -> `LocalDefId`) - #72407 (Various minor improvements to Ipv6Addr::Display) - #72413 (impl Step for char (make Range*<char> iterable)) - #72439 (NVPTX support for new asm!) Failed merges: r? @ghost
2020-05-29Added the documentation for the 'use' keywordAlexis Bourget-2/+56
2020-05-29Update compiler-builtinsAlex Crichton-1/+1
Pulls in a fix for #72758, more details on the linked issue. [Crate changes included here][changes] [changes]: https://github.com/rust-lang/compiler-builtins/compare/0.1.28...0.1.31
2020-05-29Rollup merge of #72407 - Lucretiel:ipv6-display, r=Mark-SimulacrumRalf Jung-80/+78
Various minor improvements to Ipv6Addr::Display Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to #72399 and #72398. - Defer to `Ipv4Addr::fmt` when printing an Ipv4 address - Fast path: write directly to `f` without an intermediary buffer when there are no alignment options - Simplify finding the inner zeroes-span
2020-05-29Rollup merge of #72568 - golddranks:add_total_cmp_to_floats, r=sfacklerDylan DPC-0/+287
Implement total_cmp for f32, f64 # Overview * Implements method `total_cmp` on `f32` and `f64`. This method implements a float comparison that, unlike the standard `partial_cmp`, is total (defined on all values) in accordance to the IEEE 754 (rev 2008) §5.10 `totalOrder` predicate. * The method has an API similar to `cmp`: `pub fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering { ... }`. * Implements tests. * Has documentation. # Justification for the API * Total ordering for `f32` and `f64` has been discussed many time before: * https://internals.rust-lang.org/t/pre-pre-rfc-range-restricting-wrappers-for-floating-point-types/6701 * https://github.com/rust-lang/rfcs/issues/1249 * https://github.com/rust-lang/rust/pull/53938 * https://github.com/rust-lang/rust/issues/5585 * The lack of total ordering leads to frequent complaints, especially from people new to Rust. * This is an ergonomics issue that needs to be addressed. * However, the default behaviour of implementing only `PartialOrd` is intentional, as relaxing it might lead to correctness issues. * Most earlier implementations and discussions have been focusing on a wrapper type that implements trait `Ord`. Such a wrapper type is, however not easy to add because of the large API surface added. * As a minimal step that hopefully proves uncontroversial, we can implement a stand-alone method `total_cmp` on floating point types. * I expect adding such methods should be uncontroversial because... * Similar methods on `f32` and `f64` would be warranted even in case stdlib would provide a wrapper type that implements `Ord` some day. * It implements functionality that is standardised. (IEEE 754, 2008 rev. §5.10 Note, that the 2019 revision relaxes the ordering. The way we do ordering in this method conforms to the stricter 2008 standard.) * With stdlib APIs such as `slice::sort_by` and `slice::binary_search_by` that allow users to provide a custom ordering criterion, providing additional helper methods is a minimal way of adding ordering functionality. * Not also does it allow easily using aforementioned APIs, it also provides an easy and well-tested primitive for the users and library authors to implement an `Ord`-implementing wrapper, if needed.
2020-05-29Rollup merge of #72398 - Lucretiel:ip-socket-display, r=Mark-SimulacrumDylan DPC-3/+65
SocketAddr and friends now correctly pad its content Currently, `IpAddr` and friends correctly respect formatting parameters when printing via `Display`. This PR makes SocketAddr and friends do the same thing.
2020-05-29Rollup merge of #71633 - a1phyr:infallible_error, r=dtolnayYuki Okushi-1/+2
Impl Error for Infallible This PR only changes the place where `impl Error for Infallible` is documented, as one could think that it is not the case when reading https://doc.rust-lang.org/nightly/std/convert/enum.Infallible.html. Fixes #70842
2020-05-29Clarify comment message & MAX_LENGTH constNathan West-3/+7
2020-05-29Added fast-path, testsNathan West-20/+54
2020-05-29`SocketAddr(V4|V6)?`::Display now correctly pads its contentNathan West-3/+27
IpAddr and friends pad when displaying; SocketAddr now does this as well
2020-05-29Rollup merge of #72239 - hch12907:master, r=dtolnayDylan DPC-1/+106
Implement PartialOrd and Ord for SocketAddr* The implementation is mostly the same as the one found in `IpAddr` (other than adding comparison for ports, of course). Continues #53788 and #53863 Fixes #53710
2020-05-25Add total_cmp to f32 and f64, plus testsPyry Kontio-0/+287
2020-05-25Auto merge of #72472 - LeSeulArtichaut:sync-command, r=dtolnaybors-7/+11
Implement `Sync` for `process::Command on unix and vxworks Closes #72387. r? @cuviper
2020-05-24Fix testsHoe Hao Cheng-2/+2
2020-05-24Remove heterogeneous ordering for SocketAddrHoe Hao Cheng-55/+15
2020-05-24Fix typo in doc comment.Eitan Mosenkis-1/+1
call_one_force -> call_once_force
2020-05-23Correct small typo: 'not' -> 'note'Jake Goulding-2/+2
2020-05-22Rollup merge of #72459 - yoshuawuyts:into-future, r=nikomatsakisDylan DPC-1/+16
Add core::future::IntoFuture This patch reintroduces the `core::future::IntoFuture` trait. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering since that lead to performance regressions. By introducing the trait separately from the integration, the integration PR can be more narrowly scoped, and people can start trying out the `IntoFuture` trait today. Thanks heaps! cc/ @rust-lang/wg-async-foundations ## References - Original PR adding `IntoFuture` https://github.com/rust-lang/rust/pull/65244 - Open issue to re-land `IntoFuture` (assigned to me) https://github.com/rust-lang/rust/issues/67982 - Tracking issue for `IntoFuture` https://github.com/rust-lang/rust/issues/67644
2020-05-22Implement `Sync` for `process::Command on unix and vxworksLeSeulArtichaut-7/+11
2020-05-22Rollup merge of #72399 - Lucretiel:ipv4-display-fast, r=kennytmRalf Jung-9/+16
Add fast-path optimization for Ipv4Addr::fmt Don't use an intermediary buffer when writing an IPv4 address without any specific alignment options
2020-05-22Rollup merge of #72123 - jsgf:stabilize-arg0, r=sfacklerRalf Jung-2/+2
Stabilize process_set_argv0 feature for Unix This stabilizes process_set_argv0 targeting 1.45.0. It has been useful in practice and seems useful as-is. The equivalent feature could be implemented for Windows, but as far as I know nobody has. That can be done separately. Tracking issue: #66510
2020-05-22Add core::future::IntoFutureYoshua Wuyts-1/+16
This patch adds `core::future::IntoFuture`. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering. That integration should be done in a follow-up PR.
2020-05-21Enable ARM TME (Transactional Memory Extensions)Mahmut Bulut-0/+1
2020-05-20Various minor improvements to Ipv6Addr::DisplayNathan West-80/+78
- Defer to Ipv4Addr::fmt when printing an Ipv4 address - Fast path: write directly to f without an intermediary buffer when there are no alignment options - Simplify finding the inner zeroes-span
2020-05-20Add fast-path optimization for Ipv4Addr::fmtNathan West-9/+16
2020-05-19Auto merge of #71447 - cuviper:unsized_cow, r=dtolnaybors-0/+33
impl From<Cow> for Box, Rc, and Arc These forward `Borrowed`/`Owned` values to existing `From` impls. - `Box<T>` is a fundamental type, so it would be a breaking change to add a blanket impl. Therefore, `From<Cow>` is only implemented for `[T]`, `str`, `CStr`, `OsStr`, and `Path`. - For `Rc<T>` and `Arc<T>`, `From<Cow>` is implemented for everything that implements `From` the borrowed and owned types separately.
2020-05-18Auto merge of #72289 - RalfJung:abort_internal, r=Mark-Simulacrumbors-23/+29
abort_internal is safe `sys::abort_internal` is stably exposed as a safe function. Forward that assumption "inwards" to the `sys` module by making the function itself safe, too. This corresponds to what https://github.com/rust-lang/rust/pull/72204 did for the intrinsic. We should probably wait until that lands because some of the intrinsic calls in this PR might then need adjustments.