about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2021-02-25Add {core,std}::prelude::{rust_2015,rust_2018,rust_2021}.Mara Bos-0/+35
rust_2015 and rust_2018 are just re-exports of v1. rust_2021 is a module that for now just re-exports everything from v1, such that we can add more things later.
2021-02-24Reuse `std::sys::unsupported::pipe` on `hermit`Christiaan Dirkx-38/+1
2021-02-24x.py fmtDan Gohman-3/+3
2021-02-24Mention "wasi" in the comment about "main modules".Dan Gohman-1/+1
2021-02-24Make the main `wasi` module `cfg(not(doc))`.Dan Gohman-2/+4
2021-02-24Use `super::` to refer to WASI-specific names.Dan Gohman-7/+7
This ensures that these names resolve to the right place even when building the WASI support on other platforms for generating the documentation.
2021-02-24Cast `libc::STDIN_FILENO` to `RawFd`.Dan Gohman-6/+6
WASI's `RawFd` is a `u32`, while `libc` uses `c_int`.
2021-02-24Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`Christiaan Dirkx-10/+21
The following methods are made unstable const under the `const_socketaddr` feature: `SocketAddr` - `ip` - `port` - `is_ipv4` - `is_ipv6` `SocketAddrV4` - `ip` - `port` `SocketAddrV6` - `ip` - `port` - `flowinfo` - `scope_id`
2021-02-24Bump minimum libc version to 0.2.85 for std.Maarten de Vries-1/+1
2021-02-24Use libc::accept4 on Android instead of raw syscall.Maarten de Vries-7/+1
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-8/+14
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-23Update outdated comment in unix Command.Eric Huss-17/+7
2021-02-23Use #[doc = include_str!()] in stdLeSeulArtichaut-3/+2
2021-02-23Enable API documentation for `std::os::wasi`.Dan Gohman-19/+79
This adds API documentation support for `std::os::wasi` modeled after how `std::os::unix` works, so that WASI can be documented [here] along with the other platforms. [here]: https://doc.rust-lang.org/stable/std/os/index.html Two changes of particular interest: - This changes the `AsRawFd` for `io::Stdin` for WASI to return `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and similar for `Stdout` and `Stderr`), which matches how the `unix` version works. `STDIN_FILENO` etc. may not always be explicitly reserved at the WASI level, but as long as we have Rust's `std` and `libc`, I think it's reasonable to guarantee that we'll always use `libc::STDIN_FILENO` for stdin. - This duplicates the `osstr2str` utility function, rather than trying to share it across all the configurations that need it.
2021-02-23Auto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrumbors-17/+2
Update the bootstrap compiler This updates the bootstrap compiler, notably leaving out a change to enable semicolon in macro expressions lint, because stdarch still depends on the old behavior.
2021-02-23Add more links between hash and btree collectionsJoshua Nelson-2/+4
- 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
2021-02-23Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwcoDylan DPC-0/+4
add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature. Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-23Rollup merge of #81984 - sunfishcode:wasi-link, r=alexcrichtonDylan DPC-6/+2
Make WASI's `hard_link` behavior match other platforms. Following #78026, `std::fs::hard_link` on most platforms does not follow symlinks. Change the WASI implementation to also not follow symlinks. r? ```@alexcrichton```
2021-02-23ExitStatus: Improve documentation re wait status vs exit statusIan Jackson-9/+30
The use of `ExitStatus` as the Rust type name for a Unix *wait status*, not an *exit status*, is very confusing, but sadly probably too late to change. This area is confusing enough in Unix already (and many programmers are already confuxed). We can at least document it. I chose *not* to mention the way shells like to exit with signal numbers, thus turning signal numbers into exit statuses. This is only relevant for Rust programs using `std::process` if they run shells. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-23process::unix: Test wait status formattingIan Jackson-0/+26
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-22Add a `size()` function to WASI's `MetadataExt`.Dan Gohman-0/+5
WASI's `filestat` type includes a size field, so expose it in `MetadataExt` via a `size()` function, similar to the corresponding Unix function.
2021-02-22fix io::copy specialization when writer was opened with O_APPENDThe8472-8/+10
2021-02-22add test for failing io::copy specializationThe8472-0/+18
2021-02-22Avoid `cfg_if` in `std::os`Jonas Schievink-27/+27
2021-02-22process::unix: Handle other wait statuses in ExitStatus as DisplayIan Jackson-2/+11
Currently, on Nightly, this panics: ``` use std::process::ExitStatus; use std::os::unix::process::ExitStatusExt; fn main() { let st = ExitStatus::from_raw(0x007f); println!("st = {}", st); } ``` This is because the impl of Display assumes that if .code() is None, .signal() must be Some. That was a false assumption, although it was true with buggy code before 5b1316f78152a9c066b357ea9addf803d48e114a unix ExitStatus: Do not treat WIFSTOPPED as WIFSIGNALED This is not likely to have affected many people in practice, because `Command` will never produce such a wait status (`ExitStatus`). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-22Add impl `Error` for `Arc`Richard Dodd-0/+22
2021-02-22Add missing "see its documentation for more" stdioIvan Tham-2/+2
StdoutLock and StderrLock does not have example, it would be better to leave "see its documentation for more" like iter docs.
2021-02-22Rollup merge of #82228 - ijackson:nonzero-cint, r=KodrAusYuki Okushi-54/+57
Provide NonZero_c_* integers I'm pretty sure I am going want this for #73125 and it seems like an omission that would be in any case good to remedy. <strike>Because the raw C types are in `std`, not `core`, to achieve this we must export the relevant macros from `core` so that `std` can use them. That's done with a new `num_internals` perma-unstable feature. The macros need to take more parameters for the module to get the types from and feature attributes to use. I have eyeballed the docs output for core, to check that my changes to these macros have made no difference to the core docs output.</strike>
2021-02-21update tracking issue for raw_os_nonzeroAshley Mannix-1/+1
2021-02-20Update the bootstrap compilerJoshua Nelson-17/+2
Note this does not change `core::derive` since it was merged after the beta bump.
2021-02-20Rollup merge of #82244 - pickfire:patch-6, r=dtolnayGuillaume Gomez-2/+2
Keep consistency in example for Stdin StdinLock Stdin uses handle whereas StdinLock uses stdin_lock, changed it to handle.
2021-02-19x.py fmtDan Gohman-6/+1
2021-02-19Rollup merge of #81873 - mark-i-m:unlock, r=m-ou-seDylan DPC-0/+20
Add Mutex::unlock Tracking issue: https://github.com/rust-lang/rust/issues/81872 Discussion: https://github.com/rust-lang/rust/pull/79434#issuecomment-757135874 r? `@m-ou-se`
2021-02-18add Mutex::unlockmark-0/+20
2021-02-18Stabilize `unsafe_op_in_unsafe_fn` lintLeSeulArtichaut-1/+1
2021-02-18Auto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitorbors-4/+4
Rollup of 8 pull requests Successful merges: - #82055 (Add diagnostics for specific cases for const/type mismatch err) - #82155 (Use !Sync std::lazy::OnceCell in usefulness checking) - #82202 (add specs for riscv32/riscv64 musl targets) - #82203 (Move some tests to more reasonable directories - 4) - #82211 (make `suggest_setup` help messages better) - #82212 (Remove redundant rustc_data_structures path component) - #82240 (remove useless ?s (clippy::needless_question_marks)) - #82243 (Add more intra-doc links to std::io) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-18Rollup merge of #82243 - pickfire:patch-5, r=jyn514Yuki Okushi-4/+4
Add more intra-doc links to std::io
2021-02-18Auto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obkbors-0/+1
Implement RFC 2580: Pointer metadata & VTable RFC: https://github.com/rust-lang/rfcs/pull/2580 ~~Before merging this PR:~~ * [x] Wait for the end of the RFC’s [FCP to merge](https://github.com/rust-lang/rfcs/pull/2580#issuecomment-759145278). * [x] Open a tracking issue: https://github.com/rust-lang/rust/issues/81513 * [x] Update `#[unstable]` attributes in the PR with the tracking issue number ---- This PR extends the language with a new lang item for the `Pointee` trait which is special-cased in trait resolution to implement it for all types. Even in generic contexts, parameters can be assumed to implement it without a corresponding bound. For this I mostly imitated what the compiler was already doing for the `DiscriminantKind` trait. I’m very unfamiliar with compiler internals, so careful review is appreciated. This PR also extends the standard library with new unstable APIs in `core::ptr` and `std::ptr`: ```rust pub trait Pointee { /// One of `()`, `usize`, or `DynMetadata<dyn SomeTrait>` type Metadata: Copy + Send + Sync + Ord + Hash + Unpin; } pub trait Thin = Pointee<Metadata = ()>; pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {} pub const fn from_raw_parts<T: ?Sized>(*const (), <T as Pointee>::Metadata) -> *const T {} pub const fn from_raw_parts_mut<T: ?Sized>(*mut (),<T as Pointee>::Metadata) -> *mut T {} impl<T: ?Sized> NonNull<T> { pub const fn from_raw_parts(NonNull<()>, <T as Pointee>::Metadata) -> NonNull<T> {} /// Convenience for `(ptr.cast(), metadata(ptr))` pub const fn to_raw_parts(self) -> (NonNull<()>, <T as Pointee>::Metadata) {} } impl<T: ?Sized> *const T { pub const fn to_raw_parts(self) -> (*const (), <T as Pointee>::Metadata) {} } impl<T: ?Sized> *mut T { pub const fn to_raw_parts(self) -> (*mut (), <T as Pointee>::Metadata) {} } /// `<dyn SomeTrait as Pointee>::Metadata == DynMetadata<dyn SomeTrait>` pub struct DynMetadata<Dyn: ?Sized> { // Private pointer to vtable } impl<Dyn: ?Sized> DynMetadata<Dyn> { pub fn size_of(self) -> usize {} pub fn align_of(self) -> usize {} pub fn layout(self) -> crate::alloc::Layout {} } unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {} unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Debug for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {} impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {} impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Hash for DynMetadata<Dyn> {} ``` API differences from the RFC, in areas noted as unresolved questions in the RFC: * Module-level functions instead of associated `from_raw_parts` functions on `*const T` and `*mut T`, following the precedent of `null`, `slice_from_raw_parts`, etc. * Added `to_raw_parts`
2021-02-18Keep consistency in example for Stdin StdinLockIvan Tham-2/+2
Stdin uses handle whereas StdinLock uses stdin_lock, changed it to handle.
2021-02-18Add missing link from stdio docIvan Tham-4/+4
2021-02-17Rollup merge of #77728 - lygstate:master, r=AmanieuDylan DPC-10/+49
Expose force_quotes on Windows. On Windows, the arg quotes and not quotes have different effect for the program it called, if the program called are msys2/cygwin program. Refer to https://github.com/msys2/MSYS2-packages/issues/2176 This also solve the issues comes from https://internals.rust-lang.org/t/std-process-on-windows-is-escaping-raw-literals-which-causes-problems-with-chaining-commands/8163 Tracking issue: https://github.com/rust-lang/rust/issues/82227
2021-02-17Provide NonZero_c_* integersIan Jackson-18/+48
I'm pretty sure I am going want this for #73125 and it seems like an omission that would be in any case good to remedy. It's a shame we don't have competent token pasting and case mangling for use in macro_rules!. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-17std::src::os::raw: Refactor, introducing macro type_alias!Ian Jackson-54/+27
This file contained a lot of repetitive code. This was about to get considerably worse, with introduction of a slew of new aliases. No functional change. I've eyeballed the docs and they don't seem to have changed either. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-17Expose force_quotes on Windows.Yonggang Luo-10/+49
Quotes the arg and not quotes the arg have different effect on Windows when the program called are msys2/cygwin program. Refer to https://github.com/msys2/MSYS2-packages/issues/2176 Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2021-02-16Optimize FromIterator<OsString> to reuse the first allocationRyan Lopopolo-4/+11
2021-02-16Add caveat to Path::display() about lossinessManish Goregaokar-2/+6
2021-02-16a few more diagnostic itemsAndrea Nall-0/+2
2021-02-15requested/proposed changesAndrea Nall-2/+2
2021-02-15Rollup merge of #82120 - sfackler:arguments-as-str, r=dtolnayJonas Schievink-1/+0
Stabilize Arguments::as_str Closes #74442
2021-02-15Rollup merge of #82119 - m-ou-se:typo, r=dtolnayJonas Schievink-1/+1
Fix typo in link to CreateSymbolicLinkW documentation.