about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-03-28style: Use `iter` for IntoIterator parameter namesKamal Marhubi-10/+10
This commit standardizes the codebase on `iter` for parameters with IntoIterator bounds. Previously about 40% of IntoIterator parameters were named `iterable`, with most of the rest being named `iter`. There was a single place where it was named `iterator`.
2016-03-28Rollup merge of #32507 - klingtnet:master, r=steveklabnikSteve Klabnik-2/+7
Fix missing console output in `Barrier` example 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. r? @steveklabnik
2016-03-28Implement BufRead for ChainTobias Müller-0/+21
2016-03-26Auto merge of #32510 - nodakai:libstd-sys-net-error-check, r=alexcrichtonbors-10/+11
libstd/sys/*/net: clean up API error checks. 1. Slightly improve `cvt_gai()` and `cvt()`. 2. Remove now redundant `cvt_r()`.
2016-03-27Extend linkchecker with anchor checkingmitaa-15/+15
This adds checks to ensure that: * link anchors refer to existing id's on the target page * id's are unique within an html document * page redirects are valid
2016-03-26Auto merge of #32325 - alexcrichton:panic-once, r=aturonbors-56/+363
std: Rewrite Once with poisoning This commit rewrites the `std::sync::Once` primitive with poisoning in mind in light of #31688. Currently a panic in the initialization closure will cause future initialization closures to run, but the purpose of a Once is usually to initialize some global state so it's highly likely that the global state is corrupt if a panic happened. The same strategy of a mutex is taken where a panic is propagated by default. A new API, `call_once_force`, was added to subvert panics like is available on Mutex as well (for when panicking is handled internally). Adding this support was a significant enough change to the implementation that it was just completely rewritten from scratch, primarily to avoid using a `StaticMutex` which needs to have `destroy()` called on it at some point (a pain to do). Closes #31688
2016-03-27libstd/sys/*/net: very minor clean up of cvt*() utility functions.NODA, Kai-10/+11
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-03-26std: Rewrite Once with poisoningAlex Crichton-56/+363
This commit rewrites the `std::sync::Once` primitive with poisoning in mind in light of #31688. Currently a panic in the initialization closure will cause future initialization closures to run, but the purpose of a Once is usually to initialize some global state so it's highly likely that the global state is corrupt if a panic happened. The same strategy of a mutex is taken where a panic is propagated by default. A new API, `call_once_force`, was added to subvert panics like is available on Mutex as well (for when panicking is handled internally). Adding this support was a significant enough change to the implementation that it was just completely rewritten from scratch, primarily to avoid using a `StaticMutex` which needs to have `destroy()` called on it at some point (a pain to do). Closes #31688
2016-03-26Rollup merge of #32387 - alexcrichton:ascii-test, r=aturonManish Goregaokar-0/+6
std: Add regression test for #32074 Just to make sure we don't accidentally break this in the future.
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-22Fixes test which are now run due to should_panicLukas Pustina-1/+5
Since I changed no_run to should_panic on some tests, the were run but two lacked an actual assertion. Further, I missed to check the return type on another test.
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-21Adjusts all rust doc test to use `expect` and `should_panic`Lukas Pustina-14/+13
- All Rust Doc tests execute the same command `/bin/cat file.txt` which `should_panic` on all platforms consistently, because either `/bin/cat` or `file.txt` do not exist.
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-19Fixes 2. stdout to stderr in rustdocLukas Pustina-1/+1
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