about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-03-28Rollup merge of #83561 - m-ou-se:lock-debug, r=jackh726Yuki Okushi-8/+16
Improve Debug implementations of Mutex and RwLock. This improves the Debug implementations of Mutex and RwLock. They now show the poison flag and use debug_non_exhaustive. (See #67364.)
2021-03-28Rollup merge of #83560 - m-ou-se:io-chain-debug, r=sfacklerYuki Okushi-7/+1
Derive Debug for io::Chain instead of manually implementing it. This derives Debug for io::Chain instead of manually implementing it. The manual implementation has the same bounds, so I don't think there's any reason for a manual implementation. The names used in the derive implementation are even nicer (`first`/`second`) than the manual implementation (`t`/`u`), and include the `done_first` field too.
2021-03-28Rollup merge of #83559 - m-ou-se:rwlock-guard-debug-fix, r=jackh726Yuki Okushi-2/+2
Fix Debug implementation for RwLock{Read,Write}Guard. This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print `"<locked>"` unhelpfully. After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do. MutexGuard had this problem too: https://github.com/rust-lang/rust/issues/57702
2021-03-28Rollup merge of #83558 - m-ou-se:use-finish-non-exhaustive, r=jackh726Yuki Okushi-15/+21
Use DebugStruct::finish_non_exhaustive() in std. See https://github.com/rust-lang/rust/issues/67364
2021-03-28Rollup merge of #83462 - ijackson:exitstatus-message-wording, r=joshtriplettYuki Okushi-3/+3
ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix Proper Unix terminology is "exit status" (vs "wait status"). "exit code" is imprecise on Unix and therefore unclear. (As far as I can tell, "exit code" is correct terminology on Windows.) This new wording is unfortunately inconsistent with the identifier names in the Rust stdlib. It is the identifier names that are wrong, as discussed at length in eg https://doc.rust-lang.org/nightly/std/process/struct.ExitStatus.html https://doc.rust-lang.org/nightly/std/os/unix/process/trait.ExitStatusExt.html Unfortunately for API stability reasons it would be a lot of work, and a lot of disruption, to change the names in the stdlib (eg to rename `std::process::ExitStatus` to `std::process::ChildStatus` or something), but we should fix the message output. Many (probably most) readers of these messages about exit statuses will be users and system administrators, not programmers, who won't even know that Rust has this wrong terminology. So I think the right thing is to fix the documentation (as I have already done) and, now, the terminology in the implementation. This is a user-visible change to the behaviour of all Rust programs which run Unix subprocesses. Hopefully no-one is matching against the exit status string, except perhaps in tests.
2021-03-28Rollup merge of #79399 - pickfire:patch-3, r=JohnTitorYuki Okushi-3/+3
Use detailed and shorter fs error explaination Includes suggestion from `@the8472` https://github.com/rust-lang/rust/issues/79390#issuecomment-733263336
2021-03-27Use detailed and shorter fs error explainationIvan Tham-3/+3
Includes suggestion from the8472 https://github.com/rust-lang/rust/issues/79390#issuecomment-733263336 More detail error explanation in fs doc
2021-03-27Improve Debug implementations of Mutex and RwLock.Mara Bos-8/+16
They now show the poison flag and use debug_non_exhaustive.
2021-03-27Derive Debug for io::Chain instead of manually implementing it.Mara Bos-7/+1
The manual implementation has the same bounds, so I don't think there's any reason for a manual implementation. The names used in the derive implementation are even nicer (`first`/`second`) than the manual implementation (`t`/`u`), and include the `done_first` field too.
2021-03-27Fix Debug implementation for RwLock{Read,Write}Guard.Mara Bos-2/+2
This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print "<locked>" unhelpfully. After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do.
2021-03-27Use DebugStruct::finish_non_exhaustive() in std.Mara Bos-15/+21
2021-03-27Auto merge of #78618 - workingjubilee:ieee754-fmt, r=m-ou-sebors-3/+5
Add IEEE 754 compliant fmt/parse of -0, infinity, NaN This pull request improves the Rust float formatting/parsing libraries to comply with IEEE 754's formatting expectations around certain special values, namely signed zero, the infinities, and NaN. It also adds IEEE 754 compliance tests that, while less stringent in certain places than many of the existing flt2dec/dec2flt capability tests, are intended to serve as the beginning of a roadmap to future compliance with the standard. Some relevant documentation is also adjusted with clarifying remarks. This PR follows from discussion in https://github.com/rust-lang/rfcs/issues/1074, and closes #24623. The most controversial change here is likely to be that -0 is now printed as -0. Allow me to explain: While there appears to be community support for an opt-in toggle of printing floats as if they exist in the naively expected domain of numbers, i.e. not the extended reals (where floats live), IEEE 754-2019 is clear that a float converted to a string should be capable of being transformed into the original floating point bit-pattern when it satisfies certain conditions (namely, when it is an actual numeric value i.e. not a NaN and the original and destination float width are the same). -0 is given special attention here as a value that should have its sign preserved. In addition, the vast majority of other programming languages not only output `-0` but output `-0.0` here. While IEEE 754 offers a broad leeway in how to handle producing what it calls a "decimal character sequence", it is clear that the operations a language provides should be capable of round tripping, and it is confusing to advertise the f32 and f64 types as binary32 and binary64 yet have the most basic way of producing a string and then reading it back into a floating point number be non-conformant with the standard. Further, existing documentation suggested that e.g. -0 would be printed with -0 regardless of the presence of the `+` fmt character, but it prints "+0" instead if given such (which was what led to the opening of #24623). There are other parsing and formatting issues for floating point numbers which prevent Rust from complying with the standard, as well as other well-documented challenges on the arithmetic level, but I hope that this can be the beginning of motion towards solving those challenges.
2021-03-27Rollup merge of #83524 - faern:document-socketaddr-mem-layout, r=sfacklerYuki Okushi-2/+8
Document that the SocketAddr memory representation is not stable Intended to help out with #78802. Work has been put into finding and fixing code that assumes the memory layout of `SocketAddrV4` and `SocketAddrV6`. But it turns out there are cases where new code continues to make the same assumption ([example](https://github.com/spacejam/seaslug/commit/96927dc2b7b918860a79c4eb6336051e52c6137a#diff-917db3d8ca6f862ebf42726b23c72a12b35e584e497ebdb24e474348d7c6ffb6R610-R621)). The memory layout of a type in `std` is never part of the public API. Unless explicitly stated I guess. But since that is invalidly relied upon by a considerable amount of code for these particular types, it might make sense to explicitly document this. This can be temporary. Once #78802 lands it does not make sense to rely on the layout any longer, and this documentation can also be removed.
2021-03-26Document that the SocketAddr memory representation is not stableLinus Färnstrand-2/+8
2021-03-26Rollup merge of #83463 - ijackson:exitstatusext-doc-grammar, r=kennytmDylan DPC-2/+2
ExitStatusExt: Fix missing word in two docs messages Looks like I missed the lack of these "and"s.
2021-03-25Auto merge of #83387 - cuviper:min-llvm-10, r=nagisabors-7/+4
Update the minimum external LLVM to 10 r? `@nikic`
2021-03-25ExitStatusExt: Fix missing word in two docs messagesIan Jackson-2/+2
Looks like I missed the lack of these "and"s. Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-25ExitStatus: print "exit status: {}" rather than "exit code: {}"Ian Jackson-3/+3
Proper Unix terminology is "exit status" (vs "wait status"). "exit code" is imprecise on Unix and therefore unclear. (As far as I can tell, "exit code" is correct terminology on Windows.) This new wording is unfortunately inconsistent with the identifier names in the Rust stdlib. It is the identifier names that are wrong, as discussed at length in eg https://doc.rust-lang.org/nightly/std/process/struct.ExitStatus.html https://doc.rust-lang.org/nightly/std/os/unix/process/trait.ExitStatusExt.html Unfortunately for API stability reasons it would be a lot of work, and a lot of disruption, to change the names in the stdlib (eg to rename `std::process::ExitStatus` to `std::process::ChildStatus` or something), but we should fix the message output. Many (probably most) readers of these messages about exit statuses will be users and system administrators, not programmers, who won't even know that Rust has this wrong terminology. So I think the right thing is to fix the documentation (as I have already done) and, now, the terminology in the implementation. This is a user-visible change to the behaviour of all Rust programs which run Unix subprocesses. Hopefully no-one is matching against the exit status string, except perhaps in tests. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-24Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisaDylan DPC-189/+272
Add internal io::Error::new_const to avoid allocations. This makes it possible to have a io::Error containing a message with zero allocations, and uses that everywhere to avoid the *three* allocations involved in `io::Error::new(kind, "message")`. The function signature isn't perfect, because it needs a reference to the `&str`. So for now, this is just a `pub(crate)` function. Later, we'll be able to use `fn new_const<MSG: &'static str>(kind: ErrorKind)` to make that a bit better. (Then we'll also be able to use some ZST trickery if that would result in more efficient code.) See https://github.com/rust-lang/rust/issues/83352
2021-03-22Rephrase -0.0 docsJubilee Young-4/+4
2021-03-22Update signed fmt/-0f32 docsJubilee Young-3/+5
"semantic equivalence" is too strong a phrasing here, which is why actually explaining what kind of circumstances might produce a -0 was chosen instead.
2021-03-22Fix asm! from AT&T to Intel syntaxJosh Stone-1/+1
2021-03-22Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakisbors-1/+1
Stabilize or_patterns (RFC 2535, 2530, 2175) closes #54883 This PR stabilizes the or_patterns feature in Rust 1.53. This is blocked on the following (in order): - [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021 - [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705) - It looks like we will need to pursue some sort of edition-based transition for `:pat`. - [x] Nomination and discussion by T-lang - [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100). - [ ] An FCP on stabilization EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22Update the minimum external LLVM to 10Josh Stone-6/+3
2021-03-22Rollup merge of #82686 - CDirkx:unix-platform, r=m-ou-seDylan DPC-38/+40
Move `std::sys::unix::platform` to `std::sys::unix::ext` This moves the operating system dependent alias `platform` (`std::os::{linux, android, ...}`) from `std::sys::unix` to `std::sys::unix::ext` (a.k.a. `std::os::unix`), removing the need for compatibility code in `unix_ext` when documenting on another platform. This is also a step in making it possible to properly move `std::sys::unix::ext` to `std::os::unix`, as ideally `std::sys` should not depend on the rest of `std`.
2021-03-22Rollup merge of #80193 - zseri:stabilize-osstring-ascii, r=m-ou-seDylan DPC-12/+6
stabilize `feature(osstring_ascii)` This PR stabilizes `feature(osstring_ascii)`. Fixes #70516.
2021-03-21Fix typosMara Bos-2/+2
Co-authored-by: the8472 <the8472@users.noreply.github.com>
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-189/+230
2021-03-21Add test for io::Error::new_const.Mara Bos-0/+10
2021-03-21Add internal io::Error::new_const tot avoid allocations.Mara Bos-0/+26
2021-03-21Add test for io::Error's size.Mara Bos-0/+6
2021-03-21Bump osstring_ascii stabilization version to 1.53.0.Mara Bos-6/+6
2021-03-21Rollup merge of #83280 - starthal:fix-typo-keyword-docs, r=dtolnayDylan DPC-2/+2
Fix pluralization in keyword docs
2021-03-20Fix broken doc link referenceStephen Albert-Moore-2/+2
2021-03-19core/std/alloc: stabilize or_patternsmark-1/+1
2021-03-19Rollup merge of #83269 - bstrie:revertdep, r=m-ou-seDylan DPC-2/+3
Revert the second deprecation of collections::Bound Per the review at https://github.com/rust-lang/rust/pull/82122#discussion_r596448078 and the decision at https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/unavoidable.20breakage.20when.20deprecating.20an.20enum.3F , revert this small portion of #82122 for the time being. This doesn't affect the other components of that patch, i.e. `intrinsics::drop_in_place` is still deprecated-for-real, and uses of `collections::Bound` remain removed from the repo.
2021-03-19Rollup merge of #83215 - bstrie:dephaikuraw, r=joshtriplettDylan DPC-0/+7
Deprecate std::os::haiku::raw, which accidentally wasn't deprecated In early 2016, all `std::os::*::raw` modules [were deprecated](https://github.com/rust-lang/rust/commit/aa23c98450063992473d40d707273903f8a3937d) in accordance with [RFC 1415](https://github.com/rust-lang/rfcs/blob/master/text/1415-trim-std-os.md). However, at this same time support for Haiku was being added to libstd, landing shortly after the aforementioned commit, and due to some crossed wires a `std::os::haiku::raw` module was added and was not marked as deprecated. I have been in correspondence with the author of the Haiku patch, ````@nielx,```` who has confirmed that this was simply an oversight and that the definitions from the libc crate should be preferred instead.
2021-03-19Rollup merge of #82892 - jix:clarify-read-read, r=joshtriplettDylan DPC-2/+7
Clarify docs for Read::read's return value Right now the docs for `Read::read`'s return value are phrased in a way that makes it easy for the reader to assume that the return value is never larger than the passed buffer. This PR clarifies that this is a requirement for implementations of the trait, but that callers have to expect a buggy yet safe implementation failing to do so, especially if unchecked accesses to the buffer are done afterwards. I fell into this trap recently, and when I noticed, I looked at the docs again and had the feeling that I might not have been the first one to miss this. The same issue of trusting the return value of `read` was also present in std itself for about 2.5 years and only fixed recently, see #80895. I hope that clarifying the docs might help others to avoid this issue.
2021-03-19Rollup merge of #82500 - CDirkx:hermit-pipe, r=joshtriplettDylan DPC-38/+1
Reuse `std::sys::unsupported::pipe` on `hermit` Pipes are not supported on `hermit` and `hermit/pipe.rs` is identical to `unsupported/pipe.rs`. This PR reduces duplication between the two by doing the following on `hermit`: ```rust #[path = "../unsupported/pipe.rs"] pub mod pipe; ```
2021-03-18Clarify docs for Read::read's return valueJannis Harder-2/+7
2021-03-18Fix pluralization in keyword docsStephen Albert-Moore-3/+3
2021-03-18Revert the second deprecation of collections::Boundbstrie-2/+3
2021-03-18Rollup merge of #83223 - JohnTitor:display-err-from-mmap, r=joshtriplettDylan DPC-4/+6
Display error details when a `mmap` call fails Fixes #82388
2021-03-18Rollup merge of #82434 - jyn514:hash, r=JohnTitorDylan DPC-2/+4
Add more links between hash and btree collections - Link from `core::hash` to `HashMap` and `HashSet` - Link from HashMap and HashSet to the module-level documentation on when to use the collection - Link from several collections to Wikipedia articles on the general concept See also https://github.com/rust-lang/rust/pull/81989#issuecomment-783920840.
2021-03-17Auto merge of #82122 - bstrie:dep4real, r=dtolnaybors-2/+3
Deprecate `intrinsics::drop_in_place` and `collections::Bound`, which accidentally weren't deprecated Fixes #82080. I've taken the liberty of updating the `since` values to 1.52, since an unobservable deprecation isn't much of a deprecation (even the detailed release notes never bothered to mention these deprecations). As mentioned in the issue I'm *pretty* sure that using a type alias for `Bound` is semantically equivalent to the re-export; [the reference implies](https://doc.rust-lang.org/reference/items/type-aliases.html) that type aliases only observably differ from types when used on unit structs or tuple structs, whereas `Bound` is an enum.
2021-03-17Rollup merge of #82826 - pierwill:fix-IPv, r=JohnTitorYuki Okushi-16/+16
(std::net::parser): Fix capitalization of IP version names Also add some missing puctuation in doc and code comments.
2021-03-17Display error details when a `mmap` call failsYuki Okushi-4/+6
2021-03-16Deprecate std::os::haiku::rawbstrie-0/+7
2021-03-16Rollup merge of #83160 - m-ou-se:deprecate-rustc-serialize-derives, ↵Yuki Okushi-1/+1
r=petrochenkov Deprecate RustcEncodable and RustcDecodable. We can't remove the `RustcEncodable` and `RustcDecodable` derive macros from the prelude, but we can deprecate them.
2021-03-16Rollup merge of #81822 - Kixunil:path_try_exists, r=kennytmYuki Okushi-0/+30
Added `try_exists()` method to `std::path::Path` This method is similar to the existing `exists()` method, except it doesn't silently ignore the errors, leading to less error-prone code. This change intentionally does NOT touch the documentation of `exists()` nor recommend people to use this method while it's unstable. Such changes are reserved for stabilization to prevent confusing people. Apart from that it avoids conflicts with #80979. `@joshtriplett` requested this PR in [internals discussion](https://internals.rust-lang.org/t/the-api-of-path-exists-encourages-broken-code/13817/25?u=kixunil)