summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-08-09Remove redundant Ord method impls.OGINO Masanori-54/+3
Basically, generic containers should not use the default methods since a type of elements may not guarantees total order. str could use them since u8's Ord guarantees total order. Floating point numbers are also broken with the default methods because of NaN. Thanks for @thestinger. Timespec also guarantees total order AIUI. I'm unsure whether extra::semver::Identifier does so I left it alone. Proof needed. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-09std::tuple: Use != properly in Eq::ne for tuplesblake2-ppc-1/+1
Just like the Ord methods, Eq::ne needs to be implemented in terms of the same operation on the elements.
2013-08-08Merge remote-tracking branch 'remotes/origin/master' into ↵Erick Tryzelaar-274/+1840
remove-str-trailing-nulls
2013-08-08auto merge of #8336 : stepancheg/rust/socket-addr-from-str, r=brsonbors-70/+367
FromStr implemented from scratch. It is overengineered a bit, however. Old implementation handles errors by fail!()-ing. And it has bugs, like it accepts `127.0.0.1::127.0.0.1` as IPv6 address, and does not handle all ipv4-in-ipv6 schemes. So I decided to implement parser from scratch.
2013-08-08auto merge of #8356 : toddaaro/rust/ws, r=brsonbors-63/+164
This pull request converts the scheduler from a naive shared queue scheduler to a naive workstealing scheduler. The deque is still a queue inside a lock, but there is still a substantial performance gain. Fiddling with the messaging benchmark I got a ~10x speedup and observed massively reduced memory usage. There are still *many* locations for optimization, but based on my experience so far it is a clear performance win as it is now.
2013-08-09Add #[inline] to impl Zero for ()Stepan Koltsov-0/+2
Follow-up to #8155
2013-08-08auto merge of #8385 : cmr/rust/big-rollup, r=alexcrichtonbors-97/+135
This is a fairly large rollup, but I've tested everything locally, and none of it should be platform-specific. r=alexcrichton (bdfdbdd) r=brson (d803c18) r=alexcrichton (a5041d0) r=bstrie (317412a) r=alexcrichton (135c85e) r=thestinger (8805baa) r=pcwalton (0661178) r=cmr (9397fe0) r=cmr (caa4135) r=cmr (6a21d93) r=cmr (4dc3379) r=cmr (0aa5154) r=cmr (18be261) r=thestinger (f10be03)
2013-08-08Enabled workstealing in the scheduler. Previously we had one global work ↵toddaaro-63/+164
queue shared by each scheduler. Now there is a separate work queue for each scheduler, and work is "stolen" from other queues when it is exhausted locally.
2013-08-08std::vec: Fix typo in fn neblake2-ppc-1/+1
2013-08-08std::iterator::order test casesblake2-ppc-0/+47
2013-08-08std: Fix tuple lexicographical orderblake2-ppc-14/+28
Use the definition, where R is <, <=, >=, or > [x, ..xs] R [y, ..ys] = if x != y { x R y } else { xs R ys } Previously, tuples would only implement < and derive the other comparisons from it; this is incorrect. Included are several testcases involving NaN comparisons that are now correct. Previously, tuples would consider an element equal if both a < b and b < a were false, this was also incorrect.
2013-08-08std: Fix Ord for Option, using iterator::orderblake2-ppc-15/+18
2013-08-08std::vec: Use iterator::order functions for Eq, Ord, TotalOrd, TotalEqblake2-ppc-24/+22
2013-08-08std: Implement traits for the one-tupleblake2-ppc-20/+25
(A,) did not have the trait implementations of 2- to 12- tuples.
2013-08-08Add std::iterator::order with lexical ordering functions for sequencesblake2-ppc-0/+110
Use Eq + Ord for lexicographical ordering of sequences. For each of <, <=, >= or > as R, use:: [x, ..xs] R [y, ..ys] = if x != y { x R y } else { xs R ys } Previous code using `a < b` and then `!(b < a)` for short-circuiting fails on cases such as [1.0, 2.0] < [0.0/0.0, 3.0], where the first element was effectively considered equal.
2013-08-08std: more fixes for os.rs for windowsErick Tryzelaar-2/+3
2013-08-08auto merge of #8245 : alexcrichton/rust/fmt2, r=graydonbors-2/+1331
This is a reopening of #8182, although this removes any abuse of the compiler internals. Now it's just a pure syntax extension (hard coded what the attribute names are).
2013-08-07std: import HANDLE for os::list_dir for windowsErick Tryzelaar-0/+1
2013-08-07(cleanup) Improve rtabort message for atomic-sleep.Ben Blum-1/+2
2013-08-07fix recv_ready for Port to take &self and not need to return a tuple. Close ↵Ben Blum-7/+26
#8192.
2013-08-07std: add missing #[inline] annotation to the f64 arithmetic trait impls.Huon Wilson-0/+4
2013-08-07Add weak_rng to get a random algo that puts more emphasis on speed than securityJordi Boggiano-0/+10
2013-08-07Document rand module with more emphasis on cryptographic securityJordi Boggiano-2/+12
2013-08-07Forbid `priv` where it has no effectAlex Crichton-23/+23
This is everywhere except struct fields and enum variants.
2013-08-07Implement DoubleEndedIterator on RangeKevin Ballard-54/+48
Range is now invertable as long as its element type conforms to Integer. Remove int::range_rev() et al in favor of range().invert().
2013-08-07std: Fix for-range loops that can use iteratorsblake2-ppc-10/+10
Fix inappropriate for-range loops to use for-iterator constructs (or other appropriate solution) instead.
2013-08-07Add initial support for a new formatting syntaxAlex Crichton-2/+1331
The new macro is available under the name ifmt! (only an intermediate name)
2013-08-07Turn on the new runtimeBrian Anderson-1/+1
2013-08-07Disable linked failure testsBrian Anderson-0/+25
The implementation currently contains a race that leads to segfaults.
2013-08-07std: Allow spawners to specify stack sizeBrian Anderson-49/+61
2013-08-07std::rt: Pull RUST_MIN_STACK from the environmentBrian Anderson-3/+32
2013-08-07std::rt: 2MB stacks againBrian Anderson-1/+1
2013-08-07Merge remote-tracking branch 'remotes/origin/master' into ↵Erick Tryzelaar-141/+488
remove-str-trailing-nulls
2013-08-07std: fix a bad type cast for in str.to_c_str()Erick Tryzelaar-1/+1
2013-08-07std: Make CString::new unsafe b/c it can mutate a *T ptrErick Tryzelaar-2/+2
2013-08-07std: remove unnecessary test from c_str.drop and use safer transmuteErick Tryzelaar-2/+2
2013-08-07std: Fix c_str.iter() and add testErick Tryzelaar-3/+20
2013-08-07auto merge of #8294 : erickt/rust/map-move, r=bblumbors-60/+92
According to #7887, we've decided to use the syntax of `fn map<U>(f: &fn(&T) -> U) -> U`, which passes a reference to the closure, and to `fn map_move<U>(f: &fn(T) -> U) -> U` which moves the value into the closure. This PR adds these `.map_move()` functions to `Option` and `Result`. In addition, it has these other minor features: * Replaces a couple uses of `option.get()`, `result.get()`, and `result.get_err()` with `option.unwrap()`, `result.unwrap()`, and `result.unwrap_err()`. (See #8268 and #8288 for a more thorough adaptation of this functionality. * Removes `option.take_map()` and `option.take_map_default()`. These two functions can be easily written as `.take().map_move(...)`. * Adds a better error message to `result.unwrap()` and `result.unwrap_err()`.
2013-08-07auto merge of #8326 : thestinger/rust/iterator, r=alexcrichtonbors-31/+89
The `extra::iter` module wasn't actually included in `extra.rs` when it was moved from `std`... I assume no one is going to miss it.
2013-08-07std: removed option.take_map{,_default}Erick Tryzelaar-19/+5
2013-08-07core: option.map_consume -> option.map_moveErick Tryzelaar-37/+35
2013-08-07std: add result.map_move, result.map_err_moveErick Tryzelaar-12/+60
2013-08-07auto merge of #8305 : huonw/rust/triage-fixes, r=cmrbors-11/+14
The two deletions are because the test cases are very old (still using `class` and modes!), and, as far as I can tell (since they are so old), the areas they test are well tested by other rpass tests.
2013-08-07std: adjust str::test_add so that the macro expands to all 3 items (#8012).Huon Wilson-11/+14
Closes #3682.
2013-08-07auto merge of #8323 : kballard/rust/saturating, r=thestingerbors-85/+167
Implement saturating math in `std::num::Saturating` and use it for `Iterator` impls
2013-08-07std: run test fix for ARM androidYoung-il Choi-4/+4
2013-08-07auto merge of #8285 : huonw/rust/deriving+++, r=alexcrichtonbors-3/+49
Some general clean-up relating to deriving: - `TotalOrd` was too eager, and evaluated the `.cmp` call for every field, even if it could short-circuit earlier. - the pointer types didn't have impls for `TotalOrd` or `TotalEq`. - the Makefiles didn't reach deep enough into libsyntax for dependencies. (Split out from https://github.com/mozilla/rust/pull/8258.)
2013-08-06vec: use `offset_inbounds` for iteratorsDaniel Micay-5/+24
This allows LLVM to optimize vector iterators to an `getelementptr` and `icmp` pair, instead of `getelementptr` and *two* comparisons. Code snippet: ~~~ fn foo(xs: &mut [f64]) { for x in xs.mut_iter() { *x += 10.0; } } ~~~ LLVM IR at stage0: ~~~ ; Function Attrs: noinline uwtable define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 { "function top level": %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0 %3 = load double** %2, align 8 %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1 %5 = load i64* %4, align 8 %6 = ptrtoint double* %3 to i64 %7 = and i64 %5, -8 %8 = add i64 %7, %6 %9 = inttoptr i64 %8 to double* %10 = icmp eq double* %3, %9 %11 = icmp eq double* %3, null %or.cond6 = or i1 %10, %11 br i1 %or.cond6, label %match_case, label %match_else match_else: ; preds = %"function top level", %match_else %12 = phi double* [ %13, %match_else ], [ %3, %"function top level" ] %13 = getelementptr double* %12, i64 1 %14 = load double* %12, align 8 %15 = fadd double %14, 1.000000e+01 store double %15, double* %12, align 8 %16 = icmp eq double* %13, %9 %17 = icmp eq double* %13, null %or.cond = or i1 %16, %17 br i1 %or.cond, label %match_case, label %match_else match_case: ; preds = %match_else, %"function top level" ret void } ~~~ Optimized LLVM IR at stage1/stage2: ~~~ ; Function Attrs: noinline uwtable define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 { "function top level": %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0 %3 = load double** %2, align 8 %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1 %5 = load i64* %4, align 8 %6 = lshr i64 %5, 3 %7 = getelementptr inbounds double* %3, i64 %6 %8 = icmp eq i64 %6, 0 %9 = icmp eq double* %3, null %or.cond6 = or i1 %8, %9 br i1 %or.cond6, label %match_case, label %match_else match_else: ; preds = %"function top level", %match_else %.sroa.0.0.in7 = phi double* [ %10, %match_else ], [ %3, %"function top level" ] %10 = getelementptr inbounds double* %.sroa.0.0.in7, i64 1 %11 = load double* %.sroa.0.0.in7, align 8 %12 = fadd double %11, 1.000000e+01 store double %12, double* %.sroa.0.0.in7, align 8 %13 = icmp eq double* %10, %7 br i1 %13, label %match_case, label %match_else match_case: ; preds = %match_else, %"function top level" ret void } ~~~
2013-08-06add an intrinsic for inbounds GEPDaniel Micay-1/+32
2013-08-06vec: avoid `ptrtoint`/`inttoptr` in the iteratorsDaniel Micay-8/+18
This results in throwing away alias analysis information, because LLVM does *not* implement reasoning about these conversions yet. We specialize zero-size types since a `getelementptr` offset will return us the same pointer, making it broken as a simple counter.