summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-04-24std: Add timeouts to unix connect/acceptAlex Crichton-2/+93
This adds support for connecting to a unix socket with a timeout (a named pipe on windows), and accepting a connection with a timeout. The goal is to bring unix pipes/named sockets back in line with TCP support for timeouts. Similarly to the TCP sockets, all methods are marked #[experimental] due to uncertainty about the type of the timeout argument. This internally involved a good bit of refactoring to share as much code as possible between TCP servers and pipe servers, but the core implementation did not change drastically as part of this commit. cc #13523
2014-04-24auto merge of #13720 : aturon/rust/walk_dir-perf, r=alexcrichtonbors-2/+29
The `walk_dir` iterator was simulating a queue using a vector (in particular, using `shift`), leading to O(n^2) performance. Since the order was not well-specified (see issue #13411), the simplest fix is to use the vector as a stack (and thus yield a depth-first traversal). This patch does exactly that, and adds a test checking for depth-first behavior. Note that the underlying `readdir` function does not specify any particular order, nor does the system call it uses. Closes #13411.
2014-04-24fix O(n^2) perf bug for std::io::fs::walk_dirAaron Turon-2/+29
The `walk_dir` iterator was simulating a queue using a vector (in particular, using `shift`), leading to O(n^2) performance. Since the order was not well-specified (see issue #13411), the simplest fix is to use the vector as a stack (and thus yield a depth-first traversal). This patch does exactly that. It leaves the order as originally specified -- "some top-down order" -- and adds a test to ensure a top-down traversal. Note that the underlying `readdir` function does not specify any particular order, nor does the system call it uses. Closes #13411.
2014-04-24Update libuvAlex Crichton-2/+2
This update brings a few months of changes, but primarily a fix for the following situation. When creating a handle to stdin, libuv used to set the stdin handle to nonblocking mode. This would end up affect this stdin handle across all processes that shared it, which mean that stdin become nonblocking for everyone using the same stdin. On linux, this also affected *stdout* because stdin/stdout roughly point at the same thing. This problem became apparent when running the test suite manually on a local computer. The stdtest suite (running with libgreen) would set stdout to nonblocking mode (as described above), and then the next test suite would always fail for a printing failure (because stdout was returning EAGAIN). This has been fixed upstream, joyent/libuv@342e8c, and this update pulls in this fix. This also brings us in line with a recently upstreamed libuv patch. Closes #13336 Closes #13355
2014-04-24auto merge of #13710 : aturon/rust/float-constants, r=brsonbors-75/+94
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrect, even when the values were correct. Closes #13297. Closes #11537.
2014-04-23auto merge of #13675 : sfackler/rust/taskbuilder-new, r=alexcrichtonbors-34/+27
The constructor for `TaskBuilder` is being changed to an associated function called `new` for consistency with the rest of the standard library. Closes #13666 [breaking-change]
2014-04-23Move task::task() to TaskBuilder::new()Steven Fackler-34/+27
The constructor for `TaskBuilder` is being changed to an associated function called `new` for consistency with the rest of the standard library. Closes #13666 [breaking-change]
2014-04-23auto merge of #13688 : alexcrichton/rust/accept-timeout, r=brsonbors-1/+86
This adds experimental support for timeouts when accepting sockets through `TcpAcceptor::accept`. This does not add a separate `accept_timeout` function, but rather it adds a `set_timeout` function instead. This second function is intended to be used as a hard deadline after which all accepts will never block and fail immediately. This idea was derived from Go's SetDeadline() methods. We do not currently have a robust time abstraction in the standard library, so I opted to have the argument be a relative time in millseconds into the future. I believe a more appropriate argument type is an absolute time, but this concept does not exist yet (this is also why the function is marked #[experimental]). The native support is built on select(), similarly to connect_timeout(), and the green support is based on channel select and a timer. cc #13523
2014-04-23std: Add support for an accept() timeoutAlex Crichton-1/+86
This adds experimental support for timeouts when accepting sockets through `TcpAcceptor::accept`. This does not add a separate `accept_timeout` function, but rather it adds a `set_timeout` function instead. This second function is intended to be used as a hard deadline after which all accepts will never block and fail immediately. This idea was derived from Go's SetDeadline() methods. We do not currently have a robust time abstraction in the standard library, so I opted to have the argument be a relative time in millseconds into the future. I believe a more appropriate argument type is an absolute time, but this concept does not exist yet (this is also why the function is marked #[experimental]). The native support is built on select(), similarly to connect_timeout(), and the green support is based on channel select and a timer. cc #13523
2014-04-23Register new snapshotsAlex Crichton-2/+0
These are the first successful snapshots after the LLVM upgrade, built with LLVM that requires C++11
2014-04-23auto merge of #13705 : edwardw/rust/rcboxptr-doc, r=alexcrichtonbors-1/+1
It is for internal use only and should not appear in docs.
2014-04-23fix std::f32 and std::f64 constantsAaron Turon-75/+94
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrent, even when the values were correct. Closes #13297. Closes #11537.
2014-04-23auto merge of #13686 : alexcrichton/rust/issue-12224, r=nikomatsakisbors-95/+109
This alters the borrow checker's requirements on invoking closures from requiring an immutable borrow to requiring a unique immutable borrow. This means that it is illegal to invoke a closure through a `&` pointer because there is no guarantee that is not aliased. This does not mean that a closure is required to be in a mutable location, but rather a location which can be proven to be unique (often through a mutable pointer). For example, the following code is unsound and is no longer allowed: type Fn<'a> = ||:'a; fn call(f: |Fn|) { f(|| { f(|| {}) }); } fn main() { call(|a| { a(); }); } There is no replacement for this pattern. For all closures which are stored in structures, it was previously allowed to invoke the closure through `&self` but it now requires invocation through `&mut self`. The standard library has a good number of violations of this new rule, but the fixes will be separated into multiple breaking change commits. Closes #12224
2014-04-23Fix other bugs with new closure borrowingAlex Crichton-22/+23
This fixes various issues throughout the standard distribution and tests.
2014-04-23std: Change Finally to take `&mut self`Alex Crichton-6/+6
As with the previous commits, the Finally trait is primarily implemented for closures, so the trait was modified from `&self` to `&mut self`. This will require that any closure variable invoked with `finally` to be stored in a mutable slot. [breaking-change]
2014-04-23std: Change CharEq to take `&mut self`Alex Crichton-50/+60
This is similar to the previous commits to allow invocation of a closure through a `&mut self` pointer because `&self` is disallowed. One of the primary implementors of the CharEq trait is a closure type, which would not work if the method continued to have `&self`. In addition to changing mutability of the `matches` method, this modifies the following methods from &CharEq to take a type which implements CharEq by value. * trim_chars * trim_left_chars * trim_right_chars Where these methods were previously invoked via s.trim_chars(&'a') it would now be invoked through s.trim_chars('a') [breaking-change]
2014-04-23std: Change RandomAccessIterator to use `&mut self`Alex Crichton-17/+20
Many iterators go through a closure when dealing with the `idx` method, which are invalid after the previous change (closures cannot be invoked through a `&` pointer). This commit alters the `fn idx` method on the RandomAccessIterator to take `&mut self` rather than `&self`. [breaking-change]
2014-04-23Hide trait rc::RcBoxPtr from docsEdward Wang-1/+1
It is for internal use only and should not appear in docs.
2014-04-23auto merge of #13694 : jacob-hegna/rust/master, r=brsonbors-0/+20
... and uint_macros.rs
2014-04-23auto merge of #13693 : thestinger/rust/mem, r=alexcrichtonbors-4/+27
This exposes volatile versions of the memset/memmove/memcpy intrinsics. The volatile parameter must be constant, so this can't simply be a parameter to our intrinsics.
2014-04-23auto merge of #13692 : vadimcn/rust/Win64-pre, r=alexcrichtonbors-18/+101
Stack unwinding doesn't work yet, so this won't pass a lot of tests.
2014-04-23auto merge of #13690 : alexcrichton/rust/unlink-unix-pipe, r=brsonbors-0/+16
This prevents unix sockets from remaining on the system all over the place, and more closely mirrors the behavior of libuv and windows pipes.
2014-04-23auto merge of #13687 : exscape/mut-vector-Show/master, r=alexcrichtonbors-0/+12
Removes the need for hacks to println! mutable slices, among other things.
2014-04-22auto merge of #13597 : bjz/rust/float-api, r=brsonbors-430/+524
This pull request: - Merges the `Round` trait into the `Float` trait, continuing issue #10387. - Has floating point functions take their parameters by value. - Cleans up the formatting and organisation in the definition and implementations of the `Float` trait. More information on the breaking changes can be found in the commit messages.
2014-04-22Fixed Win64 buildVadim Chugunov-18/+101
2014-04-22Removed trailing whitespace in on line 242 in int_macros.rs and on line 156 ↵Jacob Hegna-3/+3
in uint_macros.rs
2014-04-22add support for quadruple precision floating pointDaniel Micay-1/+15
This currently requires linking against a library like libquadmath (or libgcc), because compiler-rt barely has any support for this and most hardware does not yet have 128-bit precision floating point. For this reason, it's currently hidden behind a feature gate. When compiler-rt is updated to trunk, some tests can be added for constant evaluation since there will be support for the comparison operators. Closes #13381
2014-04-22Added examples for parse_bytes(buf: &[u8], radix: uint) in int_macros.rs and ↵Jacob Hegna-0/+20
uint_macros.rs
2014-04-22add volatile copy/copy_nonoverlapping/setDaniel Micay-4/+27
This exposes volatile versions of the memset/memmove/memcpy intrinsics. The volatile parameter must be constant, so this can't simply be a parameter to our intrinsics.
2014-04-22auto merge of #13674 : pcwalton/rust/more-str-inlines, r=alexcrichtonbors-0/+4
Was killing performance of selector matching in Servo. r? @alexcrichton (or anyone)
2014-04-22native: Unlink unix socket paths on dropAlex Crichton-0/+16
This prevents unix sockets from remaining on the system all over the place, and more closely mirrors the behavior of libuv and windows pipes.
2014-04-22auto merge of #13651 : ryantm/rust/master, r=brsonbors-3/+2
2014-04-22Implement Show for &mut [T]Thomas Backman-0/+12
2014-04-21str: Inline `only_ascii` in string iterators.Patrick Walton-0/+4
Was killing performance of selector matching in Servo.
2014-04-21Fix misspellings in comments.Joseph Crail-15/+15
2014-04-20fix copyright message based on `make check`Ryan Mulligan-3/+3
2014-04-20remove meaningless sentence and update copyright.Ryan Mulligan-5/+4
2014-04-20auto merge of #13410 : alexcrichton/rust/issue-12278, r=pcwaltonbors-2/+8
This commit removes the compiler support for floating point modulus operations, as well as from the language. An implementation for this operator is now required to be provided by libraries. Floating point modulus is rarely used, doesn't exist in C, and is always lowered to an fmod library call by LLVM, and LLVM is considering removing support entirely. Closes #12278
2014-04-20auto merge of #13643 : aochagavia/rust/pr-2, r=alexcrichtonbors-4/+6
Fixed a typo in the documentation of std::mem, and refactored a function to use match instead of if. Also added a FIXME to the benchmarks at the end of the file stating that they should be moved to another place, because they have nothing to do with `mem` (see https://github.com/mozilla/rust/issues/13642)
2014-04-20Minor changes in std::memaochagavia-4/+6
Fixed a typo in the documentation of std::mem, and refactored a function to use match instead of if. Also added a FIXME to the benchmarks at the end of the file stating that they should be moved to another place, because they have nothing to do with `mem` (see https://github.com/mozilla/rust/issues/13642)
2014-04-20Fix spelling mistakes in documentation and code.Joseph Crail-2/+2
2014-04-19auto merge of #13613 : alexcrichton/rust/fix-freebsd-compile, r=brsonbors-3/+2
Ah, the wonders of not being gated on FreeBSD...
2014-04-19auto merge of #13610 : jsanders/rust/sender-try-send-docs, r=alexcrichtonbors-5/+5
I was getting a bit confused by these and (I think) managed to track it down to fallout from #13448 and #13465.
2014-04-19Rewrite paragraph describing difference between try_send and send_optJames Sanders-4/+4
2014-04-19auto merge of #13615 : alexcrichton/rust/improve-demangling, r=brsonbors-3/+13
Previously, symbols with rust escape sequences (denoted with dollar signs) weren't demangled if the escape sequence showed up in the middle. This alters the printing loop to look through the entire string for dollar characters.
2014-04-19auto merge of #13614 : cgaebel/rust/master, r=brsonbors-0/+6
We previously allocated 3x for every HashMap creation and resize. This patch reduces it to 1x.
2014-04-19std: Add an experimental connect_timeout functionAlex Crichton-2/+20
This adds a `TcpStream::connect_timeout` function in order to assist opening connections with a timeout (cc #13523). There isn't really much design space for this specific operation (unlike timing out normal blocking reads/writes), so I am fairly confident that this is the correct interface for this function. The function is marked #[experimental] because it takes a u64 timeout argument, and the u64 type is likely to change in the future.
2014-04-18auto merge of #13606 : alexcrichton/rust/better-thread-errors, r=brsonbors-4/+17
On windows, correctly check for errors when spawning threads, and on both windows and unix handle the error more gracefully rather than printing an opaque assertion failure. Closes #13589
2014-04-19Reorder Float methods in trait definition and make consistent in implsBrendan Zabarauskas-293/+268
2014-04-19Fix formatting in float implementationsBrendan Zabarauskas-72/+198