summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-05-02Auto merge of #24792 - alexcrichton:issue-24748, r=alexcrichtonbors-35/+6
Ensures that the same error type is propagated throughout. Unnecessary leakage of the internals is prevented through the usage of stability attributes. Closes #24748
2015-05-01std: Don't use a wrapper for the float error typeAlex Crichton-35/+6
Ensures that the same error type is propagated throughout. Unnecessary leakage of the internals is prevented through the usage of stability attributes. Closes #24748
2015-05-01Auto merge of #25006 - alexcrichton:unstable-indexing, r=aturonbors-6/+5
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791 [breaking-change]
2015-05-02Make `UnsafeCell`, `RefCell`, `Mutex`, and `RwLock` accept DSTsP1start-34/+63
This + DST coercions (#24619) would allow code like `Rc<RefCell<Box<Trait>>>` to be simplified to `Rc<RefCell<Trait>>`.
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-6/+5
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791
2015-05-01Rollup merge of #25021 - frewsxcv:an-utf, r=steveklabnikManish Goregaokar-5/+5
Even spelled out, one would say 'a Universal Character Set'
2015-05-01Rollup merge of #25020 - brson:current_dir, r=luqmanaManish Goregaokar-1/+1
2015-05-01Rollup merge of #25014 - frewsxcv:patch-20, r=alexcrichtonManish Goregaokar-1/+1
The variable doesn't need to be mutable.
2015-05-01Rollup merge of #24988 - semarie:unused-pid_t, r=alexcrichtonManish Goregaokar-3/+3
- unbreak the build under openbsd - while here, apply same modification to dragonfly, freebsd, ios (pid_t imported, but not used in raw.rs) r? @alexcrichton cc @wg @mneumann @vhbit
2015-05-01Rollup merge of #24983 - vhbit:ios-raw, r=sanxiynManish Goregaokar-1/+1
2015-04-30Replaces instanced of 'an UTF' with 'a UTF'Corey Farwell-5/+5
Even spelled out, one would say 'a Universal Character Set'
2015-04-30Add downcasting to std::error::ErrorAaron Turon-12/+134
This commit brings the `Error` trait in line with the [Error interoperation RFC](https://github.com/rust-lang/rfcs/pull/201) by adding downcasting, which has long been intended. This change means that for any `Error` trait objects that are `'static`, you can downcast to concrete error types. To make this work, it is necessary for `Error` to inherit from `Reflect` (which is currently used to mark concrete types as "permitted for reflection, aka downcasting"). This is a breaking change: it means that impls like ```rust impl<T> Error for MyErrorType<T> { ... } ``` must change to something like ```rust impl<T: Reflect> Error for MyErrorType<T> { ... } ``` except that `Reflect` is currently unstable (and should remain so for the time being). For now, code can instead bound by `Any`: ```rust impl<T: Any> Error for MyErrorType<T> { ... } ``` which *is* stable and has `Reflect` as a super trait. The downside is that this imposes a `'static` constraint, but that only constrains *when* `Error` is implemented -- it does not actually constrain the types that can implement `Error`. [breaking-change]
2015-04-30doc: current_dir returns a PathBuf, not a PathBrian Anderson-1/+1
2015-04-30std: Always check for EDEADLK in rwlocks on unixAlex Crichton-2/+24
Apparently implementations are allowed to return EDEADLK instead of blocking forever, in which case this can lead to unsafety in the `RwLock` primitive exposed by the standard library. A debug-build of the standard library would have caught this error (due to the debug assert), but we don't ship debug builds right now. This commit adds explicit checks for the EDEADLK error code and triggers a panic to ensure the call does not succeed. Closes #25012
2015-04-30std: Favor cfg! over #[cfg] in unix rwlocksAlex Crichton-10/+5
2015-04-30Remove unnecessary 'mut' qualifier on doc-comment varCorey Farwell-1/+1
The variable doesn't need to be mutable.
2015-04-30std: Destabilize io::BufStreamAlex Crichton-10/+18
As pointed out in #17136 the semantics of a `BufStream` aren't always what one expects, and it looks like other [languages like C#][c-sharp] implement a buffered stream with only one underlying buffer. For now this commit destabilizes the primitive in the `std::io` module to give us some more time in figuring out what to do with it. [c-sharp]: https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx [breaking-change]
2015-04-30remove denied unused import: pid_t in rawSébastien Marie-4/+4
- unbreak the build under openbsd - while here, apply same modification to dragonfly, freebsd, ios (pid_t imported, but not used in raw.rs)
2015-04-30Fixed iOS buildValerii Hiora-1/+1
2015-04-30Auto merge of #24960 - tynopex:patch-doc, r=alexcrichtonbors-13/+16
- Removed misleading comments about now-defunct CreatePipe - Actually use std::process::Child in it's example - Minor cleanups
2015-04-29Test fixes and rebase conflictsAlex Crichton-1/+0
2015-04-29rollup merge of #24921: tamird/bitflags-associated-constAlex Crichton-10/+10
Conflicts: src/librustc/lib.rs
2015-04-29rollup merge of #24873: alexcrichton/fix-windows-stdioAlex Crichton-177/+138
Conflicts: src/libstd/sys/windows/fs2.rs
2015-04-29rollup merge of #24961: nham/net_docs_cleanupAlex Crichton-39/+39
Changes made include adding missing punctuation, adding missing words, and converting uses of "Gets" to "Returns" in libstd/net/addr.rs to make it more consistent with the other documentation. Fixes #24925.
2015-04-29rollup merge of #24926: frewsxcv/patch-20Alex Crichton-1/+1
2015-04-29rollup merge of #24908: inrustwetrust/once_memory_orderingAlex Crichton-1/+5
`call_once` guarantees that there is a happens-before relationship between its closure and code following it via the sequentially consistent atomic store/loads of `self.cnt`.
2015-04-29rollup merge of #24904: steveklabnik/remove_std_net_warningAlex Crichton-4/+1
This is served by stability markers.
2015-04-29rollup merge of #24711: alexcrichton/fs2.1Alex Crichton-746/+2437
This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: https://github.com/rust-lang/rfcs/pull/1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`. Closes https://github.com/rust-lang/rust/issues/24796
2015-04-29Update process.rstynopex-8/+8
Make whitespace consistent
2015-04-29Improve libstd/net/addr.rs documentation.Nick Hamann-9/+9
This adds some missing punctuation and converts uses of "Gets" to "Returns". This sounds better to my ear, but more importantly is more consistent with the documentation from other files.
2015-04-29Add some missing punctuation in the libstd/net/tcp.rs docs.Nick Hamann-1/+1
2015-04-29Add some missing punctuation in the libstd/net/ip.rs docs.Nick Hamann-19/+19
2015-04-29std: Fixup docs for std::processtynopex-13/+16
2015-04-29Improve libstd/net/udp.rs documentation.Nick Hamann-10/+10
This adds some missing punctuation, adds a missing word, and corrects a bug in the description of `send_to`, which actually returns the number of bytes written on success. Fixes #24925.
2015-04-29FalloutTamir Duberstein-8/+9
2015-04-29`bitflags!` is no longer used in `std`Tamir Duberstein-2/+1
2015-04-29std: Fix inheriting standard handles on windowsAlex Crichton-177/+138
Currently if a standard I/O handle is set to inherited on Windows, no action is taken and the slot in the process information description is set to `INVALID_HANDLE_VALUE`. Due to our passing of `STARTF_USESTDHANDLES`, however, this means that the handle is actually set to nothing and if a child tries to print it will generate an error. This commit fixes this behavior by explicitly creating stdio handles to be placed in these slots by duplicating the current process's I/O handles. This is presumably what previously happened silently by using a file-descriptor-based implementation instead of a `HANDLE`-centric implementation. Along the way this cleans up a lot of code in `Process::spawn` for Windows by ensuring destructors are always run, using more RAII, and limiting the scope of `unsafe` wherever possible.
2015-04-28Fix punctuation placement in doc-commentCorey Farwell-1/+1
2015-04-28std: Implement fs::DirBuilderAlex Crichton-17/+103
This is the last remaining portion of #24796
2015-04-28Register new snapshotsTamir Duberstein-70/+2
2015-04-28Auto merge of #24777 - alexcrichton:musl, r=brsonbors-5/+17
These commits build on [some great work on reddit](http://www.reddit.com/r/rust/comments/33boew/weekend_experiment_link_rust_programs_against/) for adding MUSL support to the compiler. This goal of this PR is to enable a `--target x86_64-unknown-linux-musl` argument to the compiler to work A-OK. The outcome here is that there are 0 compile-time dependencies for a MUSL-targeting build *except for a linker*. Currently this also assumes that MUSL is being used for statically linked binaries so there is no support for dynamically linked binaries with MUSL. MUSL support largely just entailed munging around with the linker and where libs are located, and the major highlights are: * The entirety of `libc.a` is included in `liblibc.rlib` (statically included as an archive). * The entirety of `libunwind.a` is included in `libstd.rlib` (like with liblibc). * The target specification for MUSL passes a number of ... flavorful options! Each option is documented in the relevant commit. * The entire test suite currently passes with MUSL as a target, except for: * Dynamic linking tests are all ignored as it's not supported with MUSL * Stack overflow detection is not working MUSL yet (I'm not sure why) * There is a language change included in this PR to add a `target_env` `#[cfg]` directive. This is used to conditionally build code for only MUSL (or for linux distros not MUSL). I highly suspect that this will also be used by Windows to target MSVC instead of a MinGW-based toolchain. To build a compiler targeting MUSL you need to follow these steps: 1. Clone the current MUSL repo from `git://git.musl-libc.org/musl`. Build this as usual and install it. 2. Clone and build LLVM's [libcxxabi](http://libcxxabi.llvm.org/) library. Only the `libunwind.a` artifact is needed. I have tried using upstream libunwind's source repo but I have not gotten unwinding to work with it unfortunately. Move `libunwind.a` adjacent to MUSL's `libc.a` 3. Configure a Rust checkout with `--target=x86_64-unknown-linux-musl --musl-root=$MUSL_ROOT` where `MUSL_ROOT` is where you installed MUSL in step 1. I hope to improve building a copy of libunwind as it's still a little sketchy and difficult to do today, but other than that everything should "just work"! This PR is not intended to include 100% comprehensive support for MUSL, as future modifications will probably be necessary.
2015-04-28Clarify Once::call_once memory ordering guarantees in docsinrustwetrust-1/+5
2015-04-28remove stability note from std::netSteve Klabnik-4/+1
This is served by stability markers.
2015-04-27std: Expand the area of std::fsAlex Crichton-729/+2334
This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: https://github.com/rust-lang/rfcs/pull/1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`.
2015-04-27std: Don't assume thread::current() works on panicAlex Crichton-11/+12
Inspecting the current thread's info may not always work due to the TLS value having been destroyed (or is actively being destroyed). The code for printing a panic message assumed, however, that it could acquire the thread's name through this method. Instead this commit propagates the `Option` outwards to allow the `std::panicking` module to handle the case where the current thread isn't present. While it solves the immediate issue of #24313, there is still another underlying issue of panicking destructors in thread locals will abort the process. Closes #24313
2015-04-27std: Clean up some annotations in thread::localAlex Crichton-20/+4
Don't need so much manual #[doc(hidden)] and #[unstable] as much of it is inherited!
2015-04-27std: Don't assume dlopen() works on yourselfAlex Crichton-1/+4
Statically linked executables do not succeed (aka MUSL-based executables).
2015-04-27std: Prepare for linking to muslAlex Crichton-4/+13
This commit modifies the standard library and its dependencies to link correctly when built against MUSL. This primarily ensures that the right libraries are linked against and when they're linked against they're linked against statically.
2015-04-27Rollup merge of #24855 - richo:thread-doc, r=alexcrichtonSteve Klabnik-2/+1
2015-04-27Auto merge of #24820 - bradking:fix-windows-process-spawn-command-line, ↵bors-18/+21
r=alexcrichton Fix `make_command_line` for the case of backslashes at the end of an argument requiring quotes. We must encode the command and arguments such that `CommandLineToArgvW` recovers them in the spawned process. Simplify the logic by using a running count of backslashes as they are encountered instead of looking ahead for quotes following them. Extend `test_make_command_line` to additionally cover: * a leading quote in an argument that requires quotes, * a backslash before a quote in an argument that requires quotes, * a backslash at the end of an argument that requires quotes, and * a backslash at the end of an argument that does not require quotes.