summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-03-26Fix missing console output in `Barrier` exampleAndreas Linz-2/+7
The `println!` calls in the previous version were never shown (at least not in the playpen) because the main thread is finished before all the spawned child threads were synchronized. This commit adds a join for each thread handle to wait in the main thread until all child threads are finished.
2016-03-26Fixup #32476Manish Goregaokar-0/+1
2016-03-26Rollup merge of #32476 - diwic:63-null-thread-name, r=alexcrichtonManish Goregaokar-20/+30
Fix unsound behaviour with null characters in thread names (issue #32475) Previously, the thread name (&str) was converted to a CString in the new thread, but outside unwind::try, causing a panic to continue into FFI. This patch changes that behaviour, so that the panic instead happens in the parent thread (where panic infrastructure is properly set up), not the new thread. This could potentially be a breaking change for architectures who don't support thread names.
2016-03-26Rollup merge of #32448 - sfackler:time-augmented-assignment, r=alexcrichtonManish Goregaokar-2/+58
Add augmented assignment operator impls for time types r? @alexcrichton
2016-03-26Rollup merge of #32257 - alexcrichton:fix-status-stdin, r=aturonManish Goregaokar-1/+1
std: Fix inheriting stdin on status() This regression was accidentally introduced in #31618, and it's just flipping a boolean! Closes #32254
2016-03-26Rollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, ↵Manish Goregaokar-6/+8
r=pnkfelix Restrict constants in patterns This implements [RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md). The primary change is to limit the types of constants used in patterns to those that *derive* `Eq` (note that implementing `Eq` is not sufficient). This has two main effects: 1. Floating point constants are linted, and will eventually be disallowed. This is because floating point constants do not implement `Eq` but only `PartialEq`. This check replaces the existing special case code that aimed to detect the use of `NaN`. 2. Structs and enums must derive `Eq` to be usable within a match. This is a [breaking-change]: if you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement `Eq`. Something like the following: ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*): ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`): ```rust match foo { c if c == SOME_CONST => ... } ``` Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details. cc https://github.com/rust-lang/rust/issues/31434 r? @pnkfelix
2016-03-25Auto merge of #32407 - alexcrichton:netbsd-gcc-s-link, r=aturonbors-1/+3
std: Link to gcc_s on NetBSD Currently the nightlies we're producing fail when linking some C code into a Rust application with the error message: libgcc_s.so.1: error adding symbols: DSO missing from command line By linking `gcc_s` instead of `gcc` this error goes away. I haven't tested this on NetBSD itself, but should help get the Linux cross-compile image moreso up and working!
2016-03-25fallout in existing testsNiko Matsakis-6/+8
2016-03-25Fix unsound behaviour with null characters in thread names (issue #32475)David Henningsson-20/+30
Previously, the thread name (&str) was converted to a CString in the new thread, but outside unwind::try, causing a panic to continue into FFI. This patch changes that behaviour, so that the panic instead happens in the parent thread (where panic infrastructure is properly set up), not the new thread. This could potentially be a breaking change for architectures who don't support thread names. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-03-24Rollup merge of #32452 - GuillaumeGomez:patch-5, r=steveklabnikSteve Klabnik-0/+50
Add code examples for libstd/time Fixes #29379. r? @steveklabnik
2016-03-24Rollup merge of #32276 - brson:doc, r=alexcrichtonSteve Klabnik-2/+2
doc: Stdin is not writable
2016-03-23doc: Stdin is locked for reads, not writesBrian Anderson-2/+2
2016-03-23Auto merge of #32454 - eddyb:rollup, r=eddybbors-9/+37
Rollup of 11 pull requests - Successful merges: #32404, #32420, #32423, #32425, #32429, #32430, #32431, #32434, #32437, #32441, #32443 - Failed merges:
2016-03-23Rollup merge of #32441 - tshepang:doc-primitive, r=steveklabnikEduard-Mihai Burtescu-3/+3
doc: small char improvements
2016-03-23Rollup merge of #32429 - alexcrichton:scope-id-hton, r=aturonEduard-Mihai Burtescu-6/+6
std: Store flowinfo/scope_id in host byte order Apparently these aren't supposed to be stored in network byte order, so doing so ends up causing failures when it would otherwise succeed when stored in the host byte order. Closes #32424
2016-03-23Rollup merge of #32404 - WiSaGaN:feature/osstring-implement-default, r=aturonEduard-Mihai Burtescu-0/+28
Implement Default trait for OsString/OsStr Fixes #32385
2016-03-23Auto merge of #32390 - japaric:untry, r=pnkfelixbors-356/+357
convert 99.9% of `try!`s to `?`s The first commit is an automated conversion using the [untry] tool and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [untry]: https://github.com/japaric/untry cc @rust-lang/lang @alexcrichton @brson
2016-03-23Add code examples for libstd/timeGuillaume Gomez-0/+50
2016-03-22Add augmented assignment operator impls for time typesSteven Fackler-2/+58
2016-03-22Auto merge of #32058 - pczarn:hashmap-initial-refactoring, r=apasel422bors-224/+250
Basic refactoring of HashMap
2016-03-22fix alignmentJorge Aparicio-21/+21
2016-03-22std: undo conversion of user defined try!sJorge Aparicio-11/+11
2016-03-22sprinkle feature gates here and thereJorge Aparicio-0/+1
2016-03-22try! -> ?Jorge Aparicio-347/+347
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-22std: Change `encode_utf{8,16}` to return iteratorsAlex Crichton-19/+12
Currently these have non-traditional APIs which take a buffer and report how much was filled in, but they're not necessarily ergonomic to use. Returning an iterator which *also* exposes an underlying slice shouldn't result in any performance loss as it's just a lazy version of the same implementation, and it's also much more ergonomic! cc #27784
2016-03-22std: Store flowinfo/scope_id in host byte orderAlex Crichton-6/+6
Apparently these aren't supposed to be stored in network byte order, so doing so ends up causing failures when it would otherwise succeed when stored in the host byte order. Closes #32424
2016-03-22f clarification, docsPiotr Czarnecki-2/+10
2016-03-22f Put and DerefMutPiotr Czarnecki-14/+26
2016-03-22doc: small char improvementsTshepang Lekhonkhobe-3/+3
2016-03-22Fix Default for OsString/OsStrWangshan Lu-3/+3
2016-03-21f dead codePiotr Czarnecki-10/+0
2016-03-21std: Link to gcc_s on NetBSDAlex Crichton-1/+3
Currently the nightlies we're producing fail when linking some C code into a Rust application with the error message: libgcc_s.so.1: error adding symbols: DSO missing from command line By linking `gcc_s` instead of `gcc` this error goes away. I haven't tested this on NetBSD itself, but should help get the Linux cross-compile image moreso up and working!
2016-03-22Implement Default for OsStrWangshan Lu-0/+14
2016-03-22Implement Default for OsStringWangshan Lu-0/+14
2016-03-20std: Add regression test for #32074Alex Crichton-0/+6
Just to make sure we don't accidentally break this in the future.
2016-03-20Add unix socket support to the standard librarySteven Fackler-55/+1141
2016-03-19Auto merge of #32314 - alexcrichton:ascii-fun, r=aturonbors-102/+0
std: Revert addition of `into_ascii_*` methods The addition of these methods in #31335 required adding impls of the trait for the `String` and `Vec<T>` types. This unfortunately caused a regression (#32074) in type inference for using these methods which the libs team has decided to not push forward with. These methods were stabilized in #32020 which was intended to get backported to beta, but the backport hasn't happened just yet. This commit reverts both the addition and stabilization of these methods. One proposed method of handling this, in #32076, was to move the methods to an extra trait to avoid conflicts with type inference. After some discussion, however, the libs team concluded that we probably want to reevaluate what we're doing here, so discussion will continue on the tracking issue, #27809. Closes #32074
2016-03-19Rollup merge of #32329 - sfackler:assert-recover-safe-pub, r=aturonEduard-Mihai Burtescu-3/+7
Make AssertRecoverSafe's field public It's basically the very definition of a newtype, so we might as well make things easy on people and let them construct and access it directly. r? @aturon
2016-03-18Auto merge of #32050 - achanda:from-slice-v4, r=alexcrichtonbors-0/+12
Add an impl for From trait Converts a u8 slice to a Ipv4Addr More discussion on this here: https://github.com/rust-lang/rfcs/pull/1498#issuecomment-191921655
2016-03-19Add functions to convert IPv6 addresses from and to octetsTobias Bucher-21/+43
See also #32313.
2016-03-18Fix tidySteven Fackler-2/+4
2016-03-18Auto merge of #32282 - sfackler:panic-hook, r=alexcrichtonbors-33/+45
Adjustments to the panic hook API Rename `set_handler` and `take_handler` to `set_hook` and `take_hook` since we're not actually "handling" (i.e. fixing) anything. Also alter `set_hook` to take a `Box<Fn(&PanicInfo) + 'static + Sync + Send>` rather than a parameterized closure since there's otherwise no easy way to re-register a hook that came from `take_hook`. cc #30449 r? @aturon
2016-03-18Add a since to deprecationsSteven Fackler-2/+2
2016-03-18Auto merge of #32080 - eddyb:transcendent, r=nikomatsakisbors-0/+3
Refactor call & function handling in trans, enable MIR bootstrap. Non-Rust and Rust ABIs were combined into a common codepath, which means: * The ugly `__rust_abi` "clown shoes" shim for C->Rust FFI is gone, fixes #10116. * Methods, *including virtual ones* support non-Rust ABIs, closes #30235. * Non-Rust ABIs also pass fat pointers in two arguments; the result should be identical. * Zero-sized types are never passed as arguments; again, behavior shouldn't change. Additionally, MIR support for calling intrinsics (through old trans) was implemented. Alongside assorted fixes, it enabled MIR to launch :rocket: and do a *complete* bootstrap. To try it yourself, `./configure --enable-orbit` *or* `make RUSTFLAGS="-Z orbit"`.
2016-03-18Auto merge of #32248 - dstu:master, r=alexcrichtonbors-0/+49
Expose the key of Entry variants for HashMap and BTreeMap. This PR addresses [issue 1541](https://github.com/rust-lang/rfcs/issues/1541) by exposing the key of `HashMap` and `BTreeMap` entry variants. Basic tests are provided.
2016-03-17Auto merge of #32207 - achanda:ipv6-doc, r=alexcrichtonbors-19/+29
Add is_documentation for IPv6 This function returns true if the given IPv6 is reserved for documentation. Also, reject this block in the is_global check
2016-03-17Make AssertRecoverSafe's field publicSteven Fackler-3/+5
It's basically the very definition of a newtype, so we might as well make things easy on people and let them construct and access it directly.
2016-03-17fixup Cleaner Recover::replacePiotr Czarnecki-11/+15
2016-03-17Add #[rustc_no_mir] to make tests pass with -Z orbit.Eduard Burtescu-0/+3
2016-03-17std: Revert addition of `into_ascii_*` methodsAlex Crichton-102/+0
The addition of these methods in #31335 required adding impls of the trait for the `String` and `Vec<T>` types. This unfortunately caused a regression (#32074) in type inference for using these methods which the libs team has decided to not push forward with. These methods were stabilized in #32020 which was intended to get backported to beta, but the backport hasn't happened just yet. This commit reverts both the addition and stabilization of these methods. One proposed method of handling this, in #32076, was to move the methods to an extra trait to avoid conflicts with type inference. After some discussion, however, the libs team concluded that we probably want to reevaluate what we're doing here, so discussion will continue on the tracking issue, #27809.