about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-03-26unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDsReyk Floeter-23/+34
This adds support for CMSG handling on macOS and fixes it on OpenBSD and other BSDs. When traversing the CMSG list, the previous code had an exception for Android where the next element after the last pointer could point to the first pointer instead of NULL. This is actually not specific to Android: the `libc::CMSG_NXTHDR` implementation for Linux and emscripten have a special case to return NULL when the length of the previous element is zero; most other implementations simply return the previous element plus a zero offset in this case. This MR additionally adds `SocketAncillary::is_empty` because clippy is right that it should be added.
2021-03-26Document that the SocketAddr memory representation is not stableLinus Färnstrand-2/+8
2021-03-26Use iter::zip in library/Josh Stone-2/+3
2021-03-26Cache `GetProcessHeap`Christiaan Dirkx-16/+54
2021-03-26Apply suggestions from code reviewCDirkx-2/+4
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2021-03-26Rework `std::sys::windows::alloc`Christiaan Dirkx-32/+173
Add documentation to the system functions and `SAFETY` comments. Refactored helper functions, fixing the correctness of `get_header`.
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-24comment posCount Count-1/+1
2021-03-24assert!() instead of panic!() for expected invariantCount Count-32/+30
2021-03-24rename fn write_valid_utf8() to write_valid_utf8_to_console()Count Count-4/+4
2021-03-24correct commentCount Count-1/+1
2021-03-24use io::Error::new_const() everywhereCount Count-6/+6
2021-03-24fixCount Count-1/+1
2021-03-24Reject byte if it cannot start a valid UTF-8 sequence.Count Count-1/+2
2021-03-24fix c&p errorCount Count-1/+1
2021-03-24Export utf8_char_width() publicly in core::std behind the "str_internals" ↵Count Count-12/+1
feature gate and use it in sys::windows::stdio instead of reimplementing it there.
2021-03-24fix fmtCount Count-2/+2
2021-03-24fix incomplete UTF-8 writes in Windows console stdioCount Count-14/+102
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-21Bump stable version of bufreader_seek_relative.Mara Bos-1/+1
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.