summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2020-06-13Revert heterogeneous SocketAddr PartialEq implsDavid Tolnay-40/+0
These lead to inference regressions (mostly in tests) in code that looks like: let socket = std::net::SocketAddrV4::new(std::net::Ipv4Addr::new(127, 0, 0, 1), 8080); assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); That compiles as of stable 1.44.0 but fails in beta with: error[E0284]: type annotations needed --> src/main.rs:3:41 | 3 | assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); | ^^^^^ cannot infer type for type parameter `F` declared on the associated function `parse` | = note: cannot satisfy `<_ as std::str::FromStr>::Err == _` help: consider specifying the type argument in the method call | 3 | assert_eq!(socket, "127.0.0.1:8080".parse::<F>().unwrap()); |
2020-06-13Add test for comparing SocketAddr with inferred right-hand sideDavid Tolnay-0/+5
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-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-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.
2020-05-18Rollup merge of #72307 - hermitcore:condvar, r=Mark-SimulacrumRalf Jung-4/+2
use the new interface to initialize conditional variables HermitCore introduce a new interface to intialize conditional variables. Consequently, minor changes are required to support this interface.
2020-05-18minor changes to pass the format checkStefan Lankes-3/+1
2020-05-17use new interface to initialize CondvarStefan Lankes-5/+5
HermitCore introduce a new interface to intialize conditional variables. Consequently, minor changes are required to support this interface.
2020-05-17abort_internal is safeRalf Jung-23/+29
2020-05-17Auto merge of #72204 - RalfJung:abort, r=Mark-Simulacrumbors-4/+20
make abort intrinsic safe, and correct its documentation Turns out `std::process::abort` is not the same as the intrinsic, the comment was just wrong. Quoting from the unix implementation: ``` // On Unix-like platforms, libc::abort will unregister signal handlers // including the SIGABRT handler, preventing the abort from being blocked, and // fclose streams, with the side effect of flushing them so libc buffered // output will be printed. Additionally the shell will generally print a more // understandable error message like "Abort trap" rather than "Illegal // instruction" that intrinsics::abort would cause, as intrinsics::abort is // implemented as an illegal instruction. ```
2020-05-17make abort intrinsic safe, and correct its documentationRalf Jung-4/+20
2020-05-16Implement PartialOrd and Ord for SocketAddr*Hoe Hao Cheng-1/+146
2020-05-16Rollup merge of #72230 - SOF3:patch-1, r=kennytmDylan DPC-2/+2
Updated documentation of Prefix::VerbatimDisk PrefixComponent with Prefix::VerbatimDisk does not contain the trailing slash. The documentation here is also inconsistent with the documentation on other variants that reflect the `PrefixComponent::as_os_str()` return value.
2020-05-16Rollup merge of #71677 - Mark-Simulacrum:hasher-docs, r=AmanieuDylan DPC-0/+20
Add explicit references to the BuildHasher trait Fixes #71652
2020-05-16Rollup merge of #71662 - glandium:osstring_from_str, r=sfacklerDylan DPC-0/+10
Implement FromStr for OsString
2020-05-15Updated documentation of Prefix::VerbatimDiskSOFe-2/+2
PrefixComponent with Prefix::VerbatimDisk does not contain the trailing slash. The documentation here is also inconsistent with the documentation on other variants that reflect the `PrefixComponent::as_os_str()` return value.
2020-05-12Stabilize process_set_argv0 feature for UnixJeremy Fitzhardinge-2/+2
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-12Warn against thread::sleep in async fnKornel-0/+4