about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2020-06-11Added the note to Metadata tooAlexis Bourget-0/+6
2020-06-11Add documentation to point to `!is_dir` instead of `is_file`Alexis Bourget-0/+6
2020-06-11Fix the link in the TryFrom implAlexis Bourget-1/+1
2020-06-11Add a TryFrom<Vec<u8>> impl that mirror from_vec_with_nulAlexis Bourget-0/+14
2020-06-10Migrate to numeric associated constsLzu Tao-211/+185
2020-06-09Remove a lot of unecessary/duplicated commentsAlexis Bourget-11/+3
2020-06-09Move to unstable, linking the issueAlexis Bourget-2/+2
2020-06-09Mark tests whcih don't work under riscv emulationTom Eccles-2/+3
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-08Add methods to go from a nul-terminated Vec<u8> to a CString, checked and ↵Alexis Bourget-3/+77
unchecked. Doc tests have been written and the documentation on the error type updated too.
2020-06-08Simply use drop instead of std::mem::dropPoliorcetics-2/+2
Co-authored-by: LeSeulArtichaut <leseulartichaut@gmail.com>
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-07Improved the example to work with mutable data, providing a reason for the ↵Alexis Bourget-4/+6
mutex holding it
2020-06-07Added an example where explicitly dropping a lock is necessary/a good idea.Alexis Bourget-0/+61
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-05impl ToSocketAddrs for (String, u16)Yoshua Wuyts-0/+8
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-28Added io forwarding methods to the stdio structsNathan West-0/+83
2020-05-26Add a fast path for `std::thread::panicking`.Eduardo Sánchez Muñoz-14/+51
This is done by adding a global atomic variable (non-TLS) that counts how many threads are panicking. In order to check if the current thread is panicking, this variable is read and, if it is zero, no thread (including the one where `panicking` is being called) is panicking and `panicking` can return `false` immediately without needing to access TLS. If the global counter is not zero, the local counter is accessed from TLS to check if the current thread is panicking.
2020-05-25Add total_cmp to f32 and f64, plus testsPyry Kontio-0/+287