about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2019-04-04Auto merge of #59695 - Centril:rollup-88qffc2, r=Centrilbors-2/+9
Rollup of 8 pull requests Successful merges: - #59470 (Document std::fs::File close behavior ignoring errors) - #59555 (update miri) - #59556 (update stdsimd) - #59596 (Forward formatter settings to bounds of `Range<T>` in `fmt::Debug` impl) - #59639 (Never return uninhabited values at all) - #59671 (Make some of lexer's API private) - #59685 (Add description for -Os and -Oz in rustc.1) - #59686 (Temporarily disable stack probing for gnux32.) Failed merges: r? @ghost
2019-04-04Rollup merge of #59470 - czipperz:document-fs-file-close, r=dtolnayMazdak Farrokhzad-2/+9
Document std::fs::File close behavior ignoring errors Resolves #52685
2019-04-04Auto merge of #59619 - alexcrichton:wasi-fs, r=fitzgenbors-304/+1189
wasi: Implement more of the standard library This commit fills out more of the `wasm32-unknown-wasi` target's standard library, notably the `std::fs` module and all of its internals. A few tweaks were made along the way to non-`fs` modules, but the last commit contains the bulk of the work which is to wire up all APIs to their equivalent on WASI targets instead of unconditionally returning "unsupported". After this some basic filesystem operations and such should all be working in WASI!
2019-04-03File: Add documentation about dropping to sync_allChris Gregory-1/+5
2019-04-03Support using LLVM's libunwind as the unwinder implementationPetr Hosek-0/+1
This avoids the dependency on host libraries such as libgcc_s which may be undesirable in some deployment environments where these aren't available.
2019-04-03wasi: Fill out `std::fs` module for WASIAlex Crichton-262/+1141
This commit fills out the `std::fs` module and implementation for WASI. Not all APIs are implemented, such as permissions-related ones and `canonicalize`, but all others APIs have been implemented and very lightly tested so far. We'll eventually want to run a more exhaustive test suite! For now the highlights of this commit are: * The `std::fs::File` type is now backed by `WasiFd`, a raw WASI file descriptor. * All APIs in `std::fs` (except permissions/canonicalize) have implementations for the WASI target. * A suite of unstable extension traits were added to `std::os::wasi::fs`. These traits expose the raw filesystem functionality of WASI, namely `*at` syscalls (opening a file relative to an already opened one, for example). Additionally metadata only available on wasi is exposed through these traits. Perhaps one of the most notable parts is the implementation of path-taking APIs. WASI actually has no fundamental API that just takes a path, but rather everything is relative to a previously opened file descriptor. To allow existing APIs to work (that only take a path) WASI has a few syscalls to learn about "pre opened" file descriptors by the runtime. We use these to build a map of existing directory names to file descriptors, and then when using a path we try to anchor it at an already-opened file. This support is very rudimentary though and is intended to be shared with C since it's likely to be so tricky. For now though the C library doesn't expose quite an API for us to use, so we implement it for now and will swap it out as soon as one is available.
2019-04-02Link to sync_allChris Gregory-1/+2
2019-04-01Document using `sync_all`Chris Gregory-4/+3
2019-04-01wasi: Implement `error_string` to get readable errorsAlex Crichton-2/+15
This routes the `error_string` API to `strerror` in libc which should have more human readable descriptions.
2019-04-01SGX target: convert a bunch of panics to abortsJethro Beekman-48/+61
2019-04-01wasi: Use raw syscalls for stdioAlex Crichton-14/+9
I've since learned that the mapping between libc fds and wasi fds are expected to be one-to-one, so we can use the raw syscalls for writing to stdout/stderr and reading from stdin! This should help ensure that we don't depend on a C library too unnecessarily.
2019-04-01wasi: Load arguments via syscallsAlex Crichton-26/+24
This commit switches the wasi target to loading CLI arguments via the syscalls provided by wasi rather than through the argc/argv passed to the main function. While serving the same purpose it's hoped that using syscalls will make us a bit more portable (less reliance from libstd on an external C library) as well as avoiding the need for a lock!
2019-03-31Rollup merge of #59587 - XAMPPRocky:master, r=CentrilMazdak Farrokhzad-1/+0
Remove #[doc(hidden)] from Error::type_id Nominating this for beta so that `Error::type_id` has documentation in time for release. cc @rust-lang/release @rust-lang/docs
2019-03-31Remove #[doc(hidden)] from Error::type_idAaron Power-1/+0
2019-03-31libstd: deny(elided_lifetimes_in_paths), fixes in redoxMazdak Farrokhzad-1/+1
2019-03-31libstd: deny(elided_lifetimes_in_paths), fixes in sgxMazdak Farrokhzad-19/+20
2019-03-31libstd: deny(elided_lifetimes_in_paths), fixes in wasiMazdak Farrokhzad-25/+25
2019-03-31libstd: deny(elided_lifetimes_in_paths), fixes in cloudabiMazdak Farrokhzad-3/+4
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-367/+372
2019-03-30Added a missing !.Christian-1/+1
2019-03-30Added an example that shows how the remainder function on floating point ↵Christian-3/+3
values is computed internally.
2019-03-30Rollup merge of #59532 - mbrubeck:docs, r=CentrilMazdak Farrokhzad-6/+19
In doc examples, don't ignore read/write results Calling `Read::read` or `Write::write` without checking the returned `usize` value is almost always an error. Example code in the documentation should demonstrate how to use the return value correctly. Otherwise, people might copy the example code thinking that it is okay to "fire and forget" these methods.
2019-03-30Rollup merge of #59528 - DevQps:improve-dbg-macro-docs, r=CentrilMazdak Farrokhzad-1/+7
Improve the dbg! macro docs # Description As stated has been discussed in #58383 the docs do not clearly state why it is useful to have the option to use `dbg!` in release builds as well. This PR should change that. closes #58383
2019-03-30Rollup merge of #59512 - euclio:stdio-locks, r=sfacklerMazdak Farrokhzad-0/+51
implement `AsRawFd` for stdio locks cc https://github.com/rust-lang/rfcs/issues/2074.
2019-03-29Add a new wasm32-unknown-wasi targetAlex Crichton-2/+1974
This commit adds a new wasm32-based target distributed through rustup, supported in the standard library, and implemented in the compiler. The `wasm32-unknown-wasi` target is intended to be a WebAssembly target which matches the [WASI proposal recently announced.][LINK]. In summary the WASI target is an effort to define a standard set of syscalls for WebAssembly modules, allowing WebAssembly modules to not only be portable across architectures but also be portable across environments implementing this standard set of system calls. The wasi target in libstd is still somewhat bare bones. This PR does not fill out the filesystem, networking, threads, etc. Instead it only provides the most basic of integration with the wasi syscalls, enabling features like: * `Instant::now` and `SystemTime::now` work * `env::args` is hooked up * `env::vars` will look up environment variables * `println!` will print to standard out * `process::{exit, abort}` should be hooked up appropriately None of these APIs can work natively on the `wasm32-unknown-unknown` target, but with the assumption of the WASI set of syscalls we're able to provide implementations of these syscalls that engines can implement. Currently the primary engine implementing wasi is [wasmtime], but more will surely emerge! In terms of future development of libstd, I think this is something we'll probably want to discuss. The purpose of the WASI target is to provide a standardized set of syscalls, but it's *also* to provide a standard C sysroot for compiling C/C++ programs. This means it's intended that functions like `read` and `write` are implemented for this target with a relatively standard definition and implementation. It's unclear, therefore, how we want to expose file descriptors and how we'll want to implement system primitives. For example should `std::fs::File` have a libc-based file descriptor underneath it? The raw wasi file descriptor? We'll see! Currently these details are all intentionally hidden and things we can change over time. A `WasiFd` sample struct was added to the standard library as part of this commit, but it's not currently used. It shows how all the wasi syscalls could be ergonomically bound in Rust, and they offer a possible implementation of primitives like `std::fs::File` if we bind wasi file descriptors exactly. Apart from the standard library, there's also the matter of how this target is integrated with respect to its C standard library. The reference sysroot, for example, provides managment of standard unix file descriptors and also standard APIs like `open` (as opposed to the relative `openat` inspiration for the wasi ssycalls). Currently the standard library relies on the C sysroot symbols for operations such as environment management, process exit, and `read`/`write` of stdio fds. We want these operations in Rust to be interoperable with C if they're used in the same process. Put another way, if Rust and C are linked into the same WebAssembly binary they should work together, but that requires that the same C standard library is used. We also, however, want the `wasm32-unknown-wasi` target to be usable-by-default with the Rust compiler without requiring a separate toolchain to get downloaded and configured. With that in mind, there's two modes of operation for the `wasm32-unknown-wasi` target: 1. By default the C standard library is statically provided inside of `liblibc.rlib` distributed as part of the sysroot. This means that you can `rustc foo.wasm --target wasm32-unknown-unknown` and you're good to go, a fully workable wasi binary pops out. This is incompatible with linking in C code, however, which may be compiled against a different sysroot than the Rust code was previously compiled against. In this mode the default of `rust-lld` is used to link binaries. 2. For linking with C code, the `-C target-feature=-crt-static` flag needs to be passed. This takes inspiration from the musl target for this flag, but the idea is that you're no longer using the provided static C runtime, but rather one will be provided externally. This flag is intended to also get coupled with an external `clang` compiler configured with its own sysroot. Therefore you'll typically use this flag with `-C linker=/path/to/clang-script-wrapper`. Using this mode the Rust code will continue to reference standard C symbols, but the definition will be pulled in by the linker configured. Alright so that's all the current state of this PR. I suspect we'll definitely want to discuss this before landing of course! This PR is coupled with libc changes as well which I'll be posting shortly. [LINK]: [wasmtime]:
2019-03-29In doc examples, don't ignore read/write resultsMatt Brubeck-6/+19
Calling `Read::read` or `Write::write` without checking the returned `usize` value is almost always an error. Example code in the documentation should demonstrate how to use the return value correctly. Otherwise, people might copy the example code thinking that it is okay to "fire and forget" these methods.
2019-03-29Update src/libstd/macros.rs Mazdak Farrokhzad-1/+0
Removed duplicate line. Co-Authored-By: DevQps <46896178+DevQps@users.noreply.github.com>
2019-03-29Update src/libstd/macros.rs Mazdak Farrokhzad-1/+2
Wrapped lines earlier such that it is more coherent with the rest of the text. Co-Authored-By: DevQps <46896178+DevQps@users.noreply.github.com>
2019-03-29Adjusted the indentation.Christian-2/+3
2019-03-29Edited the dbg! docs stating that dbg! works the same way in release builds.Christian-1/+6
2019-03-29implement `AsRawFd` for stdio locksAndy Russell-0/+51
2019-03-29Rollup merge of #59511 - jethrogb:jb/maybeinit-deprecated, r=CentrilMazdak Farrokhzad-1/+1
Fix missed fn rename in #59284 See https://github.com/rust-lang/rust/pull/59284#issuecomment-477822797
2019-03-29Rollup merge of #59503 - crlf0710:stablize_copysign, r=SimonSapinMazdak Farrokhzad-4/+2
Stablize {f32,f64}::copysign(). Stablization PR for #55169/#58046. Please check if i'm doing it correctly. Is 1.35.0 good to go?
2019-03-28Fix missed fn rename in #59284Jethro Beekman-1/+1
2019-03-29Stablize {f32,f64}::copysign().CrLF0710-4/+2
2019-03-28Use write_all instead of write in example codeMatt Brubeck-7/+7
2019-03-28Rollup merge of #59474 - czipperz:bufwriter-fix-link-capitalization, r=CentrilMazdak Farrokhzad-2/+2
Fix link capitalization in documentation of std::io::BufWriter.
2019-03-28Rollup merge of #59472 - czipperz:bufreader-document-drop-discards, r=CentrilMazdak Farrokhzad-0/+4
Document that `std::io::BufReader` discards contents on drop Resolves #55546
2019-03-28Rollup merge of #59456 - ↵Mazdak Farrokhzad-5/+12
czipperz:for-keyword-document-higher-ranked-trait-bounds, r=Centril Add documentation about `for` used as higher ranked trait bounds Resolves #55416
2019-03-28Rollup merge of #59448 - benesch:macro-doc, r=CentrilMazdak Farrokhzad-22/+24
Use consistent phrasing for all macro summaries None
2019-03-28Rollup merge of #58803 - haraldh:fs_copy_fix, r=alexcrichtonMazdak Farrokhzad-55/+74
fs::copy() unix: set file mode early A convenience method like fs::copy() should try to prevent pitfalls a normal user doesn't think about. In case of an empty umask, setting the file mode early prevents temporarily world readable or even writeable files, because the default mode is 0o666. In case the target is a named pipe or special device node, setting the file mode can lead to unwanted side effects, like setting permissons on `/dev/stdout` or for root setting permissions on `/dev/null`. copy_file_range() returns EINVAL, if the destination is a FIFO/pipe or a device like "/dev/null", so fallback to io::copy, too. Fixes: https://github.com/rust-lang/rust/issues/26933 Fixed: https://github.com/rust-lang/rust/issues/37885
2019-03-27Fix link capitalization in documentation of std::io::BufWriter.Chris Gregory-2/+2
2019-03-27Document that `std::io::BufReader` discards contents on dropChris Gregory-0/+4
Resolves #55546
2019-03-27Move link to rust book to next line to pass 100 column limitChris Gregory-1/+2
2019-03-27Rollup merge of #59460 - xfix:include-id-in-thread-debug, r=AmanieuJosh Stone-1/+4
Include id in Thread's Debug implementation Since Rust 1.19.0, `id` is a stable method, so there is no reason to not include it in Debug implementation.
2019-03-27Rollup merge of #59451 - TimDiekmann:patch-1, r=sfacklerJosh Stone-1/+1
Add `Default` to `std::alloc::System` `System` is a unit struct, thus, it can be constructed without any additional information. Therefore `Default` is a noop. However, in generic code, a `T: Default` may happen as in ```rust #[derive(Default)] struct Foo<A> { allocator: A } ``` Does this need a feature gate? Should I also add `PartialEq/Eq/PartialOrd/Ord/Hash`?
2019-03-27Rollup merge of #59284 - RalfJung:maybe-uninit, r=sfacklerJosh Stone-6/+6
adjust MaybeUninit API to discussions uninitialized -> uninit into_initialized -> assume_init read_initialized -> read set -> write
2019-03-27Document std::fs::File close behavior ignoring errorsChris Gregory-1/+4
2019-03-27Add higher-ranked trait bounds linkChris Gregory-0/+1
2019-03-27Clarify behavior of dbg macroNikhil Benesch-1/+2