about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-12-29std: Return Result from RWLock/Mutex methodsAlex Crichton-319/+551
All of the current std::sync primitives have poisoning enable which means that when a task fails inside of a write-access lock then all future attempts to acquire the lock will fail. This strategy ensures that stale data whose invariants are possibly not upheld are never viewed by other tasks to help propagate unexpected panics (bugs in a program) among tasks. Currently there is no way to test whether a mutex or rwlock is poisoned. One method would be to duplicate all the methods with a sister foo_catch function, for example. This pattern is, however, against our [error guidelines][errors]. As a result, this commit exposes the fact that a task has failed internally through the return value of a `Result`. [errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants All methods now return a `LockResult<T>` or a `TryLockResult<T>` which communicates whether the lock was poisoned or not. In a `LockResult`, both the `Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in order to allow access to the data if poisoning is not desired. This also means that the lock is *always* held upon returning from `.lock()`. A new type, `PoisonError`, was added with one method `into_guard` which can consume the assertion that a lock is poisoned to gain access to the underlying data. This is a breaking change because the signatures of these methods have changed, often incompatible ways. One major difference is that the `wait` methods on a condition variable now consume the guard and return it in as a `LockResult` to indicate whether the lock was poisoned while waiting. Most code can be updated by calling `.unwrap()` on the return value of `.lock()`. [breaking-change]
2014-12-29std: Stabilize the prelude moduleAlex Crichton-801/+975
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
2014-12-29Fallout from globs/re-export/shadowing changeNick Cameron-19/+28
2014-12-29Fallout from glob shadowingNick Cameron-47/+46
2014-12-28Added `get_address_name`, an interface to `getnameinfo`Murarth-2/+49
2014-12-28src/libstd/thread_local/scoped.rs: fixes scoped_thread_local! macroarturo-2/+16
was missing a ;
2014-12-28Rename TaskRng to ThreadRngSimonas Kazlauskas-47/+47
Since runtime is removed, rust has no tasks anymore and everything is moving from being task-* to thread-*. Let’s rename TaskRng as well! * Rename TaskRng to ThreadRng * Rename task_rng to thread_rng [breaking-change]
2014-12-28auto merge of #20136 : eddyb/rust/format-args, r=alexcrichtonbors-37/+304
We have the technology: no longer do you need to write closures to use `format_args!`. This is a `[breaking-change]`, as it forces you to clean up old hacks - if you had code like this: ```rust format_args!(fmt::format, "{} {} {}", a, b, c) format_args!(|args| { w.write_fmt(args) }, "{} {} {}", x, y, z) ``` change it to this: ```rust fmt::format(format_args!("{} {} {}", a, b, c)) w.write_fmt(format_args!("{} {} {}", x, y, z)) ``` To allow them to be called with `format_args!(...)` directly, several functions were modified to take `fmt::Arguments` by value instead of by reference. Also, `fmt::Arguments` derives `Copy` now in order to preserve all usecases that were previously possible.
2014-12-27Update docstring for bitflags macro to cover all generated methodsNicholas Bishop-0/+4
The methods `from_bits` and `from_bits_truncate` were missing from the list of generated methods. Didn't see a useful way to abbreviate, so added with the same docstrings used in the macro definition.
2014-12-27Fallout of changing format_args!(f, args) to f(format_args!(args)).Eduard Burtescu-37/+304
2014-12-27auto merge of #19916 : SimonSapin/rust/ascii-reform, r=sfacklerbors-585/+128
Implements [RFC 486](https://github.com/rust-lang/rfcs/pull/486). Fixes #19908. * Rename `to_ascii_{lower,upper}` to `to_ascii_{lower,upper}case`, per #14401 * Remove the `Ascii` type and associated traits: `AsciiCast`, `OwnedAsciiCast`, `AsciiStr`, `IntoBytes`, and `IntoString`. * As a replacement, add `.is_ascii()` to `AsciiExt`, and implement `AsciiExt` for `u8` and `char`. [breaking-change]
2014-12-27auto merge of #20119 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakisbors-65/+249
More work on opt-in built in traits. `Send` and `Sync` are not opt-in, `OwnedPtr` renamed to `UniquePtr` and the `Send` and `Sync` traits are now unsafe. NOTE: This likely needs to be rebased on top of the yet-to-land snapshot. r? @nikomatsakis cc #13231
2014-12-27Make trait's impls consistent for unix/windowsFlavio Percoco-0/+5
2014-12-27Implement Sync/Send for windows' UnixStreamFlavio Percoco-0/+6
2014-12-27Rebasing changesNick Cameron-4/+7
2014-12-26Implement Sync/Send for windows TCP typesFlavio Percoco-0/+12
2014-12-26s/task/thread/gSteve Klabnik-96/+96
A part of #20038
2014-12-27Fix falloutNick Cameron-14/+11
2014-12-26Derive Clone, PartialEq, and Eq for std::io::{FileAccess, FileMode}Ivan Petkov-2/+2
* Both enums already derived `Copy`, but storing them in any struct/container would prevent implementing `Clone` for said struct/container even though they should be clonable. * Also add PartialEq and Eq for good measure.
2014-12-26Implement RaceBox for StdinReaderFlavio Percoco-16/+43
2014-12-26Make Barrier and Condvar Sync/SendFlavio Percoco-12/+36
2014-12-26Relax `Arc` bounds don't require Sync+SendFlavio Percoco-25/+25
Besides the above making sense, it'll also allow us to make `RacyCell` private and use UnsafeCell instead.
2014-12-26Rename `UniquePtr` to `Unique`Flavio Percoco-4/+4
Mostly following the convention in RFC 356
2014-12-26Implement `Sync` for some windows sys typesFlavio Percoco-0/+8
2014-12-26Move RacyCell to `std::comm`Flavio Percoco-8/+36
RacyCell is not exactly what we'd like as a final implementation for this. Therefore, we're moving it under `std::comm` and also making it private.
2014-12-26Make Send and Sync traits unsafeFlavio Percoco-36/+54
2014-12-26Rename `OwnedPtr` to `UniquePtr`Flavio Percoco-4/+4
2014-12-26Require types to opt-in SyncFlavio Percoco-45/+101
2014-12-25Map EEXIST to PathAlreadyExists error, closes #20226Florian Hahn-0/+17
2014-12-25Prepared most `StrExt` pattern using methods for stabilizationMarvin Löbel-2/+2
Made iterator-returning methods return newtypes Adjusted some docs to be forwards compatible with a generic pattern API
2014-12-25Fix typo in std::thread commentsAdolfo Ochagavía-1/+1
2014-12-25std::ascii: Use u8 methods rather than the maps directly.Simon Sapin-16/+14
2014-12-25Remove Ascii, AsciiCast, OwnedAsciiCast, AsciiStr, IntoBytes, IntoString.Simon Sapin-539/+84
As a replacement, add is_ascii() to AsciiExt, and implement AsciiExt for u8 and char. [breaking-change]
2014-12-25Parse fully-qualified associated types in generics without whitespaceP1start-6/+6
This breaks code that looks like this: let x = foo as bar << 13; Change such code to look like this: let x = (foo as bar) << 13; Closes #17362. [breaking-change]
2014-12-25auto merge of #20024 : mneumann/rust/dragonfly-fixes3, r=alexcrichtonbors-1/+11
2014-12-24Fix backtrace demanglingSteven Fackler-4/+4
Closes #20209
2014-12-24Rename remaining hashmap and hashtable iterators to match namingChase Southwood-11/+11
conventions. This is a [breaking-change].
2014-12-25hashmap: Fix the example using derived Hash + Eqbluss-10/+18
The example derived Hash + Eq on a type that was used as *values* for a hashmap.. for the example to make sense, we have to use a custom *key* type. Write a slightly more involved example, still using Vikings, but this time as key. I preferred using String over &str here, since that's the typical usage and we might want to lead users down that path.
2014-12-24auto merge of #20117 : lfairy/rust/rename-include-bin, r=alexcrichtonbors-2/+6
According to [RFC 344][], methods that return `&[u8]` should have names ending in `bytes`. Though `include_bin!` is a macro not a method, it seems reasonable to follow the convention anyway. We keep the old name around for now, but trigger a deprecation warning when it is used. [RFC 344]: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md [breaking-change]
2014-12-24Rename to_ascii_{lower,upper} to to_ascii_{lower,upper}case, per #14401Simon Sapin-37/+37
[breaking-change]
2014-12-23Rename and namespace `FPCategory`Tobias Bucher-21/+23
Rename `FPCategory` to `FpCategory` and `Fp* to `*` in order to adhere to the naming convention This is a [breaking-change]. Existing code like this: ``` use std::num::{FPCategory, FPNaN}; ``` should be adjusted to this: ``` use std::num::FpCategory as Fp ``` In the following code you can use the constants `Fp::Nan`, `Fp::Normal`, etc.
2014-12-23Rename include_bin! to include_bytes!Chris Wong-2/+6
According to [RFC 344][], methods that return `&[u8]` should have names ending in `bytes`. Though `include_bin!` is a macro not a method, it seems reasonable to follow the convention anyway. We keep the old name around for now, but trigger a deprecation warning when it is used. [RFC 344]: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md [breaking-change]
2014-12-23Fix some spelling errors.Huon Wilson-11/+11
2014-12-22Test fixes and rebase conflictsAlex Crichton-3/+7
2014-12-22rollup merge of #19891: nikomatsakis/unique-fn-types-3Alex Crichton-6/+43
Conflicts: src/libcore/str.rs src/librustc_trans/trans/closure.rs src/librustc_typeck/collect.rs src/libstd/path/posix.rs src/libstd/path/windows.rs
2014-12-22rollup merge of #20056: MrFloya/iter_renameAlex Crichton-20/+20
Conflicts: src/libcollections/bit.rs src/libcore/str.rs
2014-12-22rollup merge of #20125: csouth3/hashset-bitopsAlex Crichton-4/+115
Now that #19448 has landed in a snapshot, we can add proper by-value operator overloads for `HashSet`. The behavior of these operator overloads is consistent with rust-lang/rfcs#235.
2014-12-22Insert coercions to fn pointer types required for the new typesNiko Matsakis-4/+15
post-unboxed-closure-conversion. This requires a fair amount of annoying coercions because all the `map` etc types are defined generically over the `F`, so the automatic coercions don't propagate; this is compounded by the need to use `let` and not `as` due to stage0. That said, this pattern is to a large extent temporary and unusual.
2014-12-22Fix fallout from changes. In cases where stage0 compiler is needed, weNiko Matsakis-4/+34
cannot use an `as` expression to coerce, so I used a one-off function instead (this is a no-op in stage0, but in stage1+ it triggers coercion from the fn pointer to the fn item type).
2014-12-22Added missing renames:Florian Wilkens-20/+20
libcollections: AbsEntries -> AbsIter, Entries -> Iter, MoveEntries -> IntoIter, MutEntries -> IterMut DifferenceItems -> Difference, SymDifferenceItems -> SymmetricDifference, IntersectionItems -> Intersection, UnionItems -> Union libstd/hash/{table, map}: Entries -> Iter, MoveItems -> IntoIter, MutEntries -> IterMut Also a [breaking-change].