Commit Graph

2133 Commits

Author SHA1 Message Date
Daniel Micay
4f2f545ac2 add Iterator implementations for Option 2013-06-11 14:05:27 -04:00
bors
d1d855993d auto merge of #7047 : bblum/rust/bug_triage, r=graydon
r? anybody
2013-06-11 09:52:40 -07:00
Huon Wilson
7e6a5940cb std: convert pow, hypot, atan2, log to take arguments by reference. 2013-06-11 11:36:03 +10:00
Ben Blum
8081aea3b8 Tag a bunch of destructors that need mutable self with FIXME for #4330. Close #4943. 2013-06-10 18:18:04 -04:00
Ben Blum
967c7d828a Replace str::raw::buf_as_slice with c_str_to_static_slice. Close #3843. 2013-06-10 17:34:28 -04:00
Huon Wilson
e8782eeb63 fix tests, remove some warnings 2013-06-11 02:34:14 +10:00
Huon Wilson
2fa83c0503 std: replace str::is_{alphanumeric,whitespace} with the methods. 2013-06-11 01:07:52 +10:00
Huon Wilson
838191c40b std: replace str::{starts,ends}_with with the method. 2013-06-11 01:03:24 +10:00
Huon Wilson
248b6e38b5 std: replace str::substr with the method. 2013-06-11 00:52:47 +10:00
Huon Wilson
ebefe425b9 std: remove str::to_chars 2013-06-11 00:49:19 +10:00
Huon Wilson
8c59d920a1 std: basic documentation for the new str methods 2013-06-11 00:08:57 +10:00
Huon Wilson
ccd0ac59e9 std: remove str::{connect,concat}*. 2013-06-10 23:57:03 +10:00
Huon Wilson
5a711ea7c3 clean-up unused import warnings 2013-06-10 23:15:01 +10:00
Huon Wilson
ead4468249 std: fix tests 2013-06-10 23:02:55 +10:00
Huon Wilson
ec5a028ada std: convert str::char_at* to methods. 2013-06-10 23:02:55 +10:00
Huon Wilson
f632f46614 std: convert str::trim* to methods. 2013-06-10 23:02:55 +10:00
Huon Wilson
1553874149 std: convert str::reserve* to methods, and methodise str::push_*. 2013-06-10 23:02:55 +10:00
Huon Wilson
a64e886e3c std: remove str::contains in favour of the method 2013-06-10 23:02:55 +10:00
Huon Wilson
017450a611 std: replace str::find_str* with a method 2013-06-10 23:02:54 +10:00
Huon Wilson
7281fb948a std: replace str::{any,all}_between with the iterator equivalent. 2013-06-10 23:02:54 +10:00
Huon Wilson
0cfc08d81e std: convert character-based str::find_* to methods. Add .slice_{to,from} methods. 2013-06-10 23:02:54 +10:00
Huon Wilson
76fc9be5a1 std: convert each_split_str to an iterator 2013-06-10 23:02:54 +10:00
Huon Wilson
ee41ad4168 std: fix compile & test 2013-06-10 23:02:54 +10:00
Huon Wilson
c32fb53cf9 std: remove str::{len, slice, is_empty} in favour of methods. 2013-06-10 23:02:54 +10:00
Huon Wilson
b29cd22bce std: replace str::all/any fns and methods with iterators 2013-06-10 23:02:54 +10:00
Huon Wilson
1e8982bdb2 std: replace str::each_split* with an iterator 2013-06-10 23:02:54 +10:00
bors
6e5e97fc78 auto merge of #7028 : thestinger/rust/cmp, r=brson 2013-06-09 20:13:23 -07:00
Daniel Micay
86833ea286 cmp: remove duplicate free functions 2013-06-09 20:47:40 -04:00
bors
94f72dd736 auto merge of #6904 : catamorphism/rust/rustpkg_version_vcs, r=catamorphism
r? @brson
2013-06-09 13:16:27 -07:00
Daniel Micay
de367157b5 remove deprecated vec::{is_empty, len} functions 2013-06-08 23:19:30 -04:00
Daniel Micay
fe3ad0a204 rm some uses of to_mut_unsafe_ptr 2013-06-08 15:02:32 -04:00
Tim Chevalier
a014088da1 std: Fix search-and-replace typos 2013-06-08 11:59:03 -07:00
Huon Wilson
98ba91f81b remove unused import warnings 2013-06-09 02:22:23 +10:00
Huon Wilson
00f5916809 std: replace the str::each* fns/methods with byte iterators 2013-06-09 02:22:23 +10:00
Huon Wilson
4b806b4d06 std: remove each_char* fns and methods from str, replaced by iterators. 2013-06-09 02:22:23 +10:00
Huon Wilson
513d2292e5 std: remove foldr and alli methods in vec 2013-06-09 02:22:23 +10:00
Huon Wilson
ed299af625 std: remove fold[lr] in favour of iterators 2013-06-09 02:22:23 +10:00
Huon Wilson
65c7c58c8f std: remove {all*,any*,count} in favour of iterators 2013-06-09 02:22:23 +10:00
Huon Wilson
ce4f63dcee std: add reverse vec iterators, replace vec::each*_reverse. 2013-06-09 02:22:23 +10:00
bors
e2ec8e71ce auto merge of #7008 : thestinger/rust/iterator, r=catamorphism
The `IteratorUtil` trait hits a bug in method resolve, but the basic trait has no issue.
2013-06-08 02:28:15 -07:00
Daniel Micay
d27ba09245 add the Iterator trait to the prelude 2013-06-07 22:23:48 -04:00
Tim Chevalier
239b81f111 std: Change str::from_bytes to raise a condition on invalid input
As per #4765
2013-06-07 17:42:50 -07:00
Daniel Micay
07e4d69baa iterator: work around method resolve bug (#5898) 2013-06-07 14:50:06 -04:00
Huon Wilson
54d914a9a9 std: remove each[i]_mut functions, in favour of iterators. 2013-06-08 03:24:27 +10:00
Huon Wilson
f661a15b2b std: remove vec::each2 and vec::each2_mut in favour of iterators 2013-06-08 01:20:47 +10:00
Huon Wilson
5e9f006c5b std: more dummy type parameters on iterators to work around #6967. 2013-06-08 01:10:27 +10:00
bors
74d9de7abd auto merge of #6979 : thestinger/rust/libc, r=brson
LLVM provides these functions as intrinsics, and will generate calls to
libc when appropriate. They are exposed in the `ptr` module as
`copy_nonoverlapping_memory`, `copy_memory` and `set_memory`.

@graydon: r?
2013-06-06 19:40:32 -07:00
Marvin Löbel
cac4891154 Fixups 2013-06-06 22:40:35 +02:00
Marvin Löbel
070015468d Removed IteratorUtil::to_vec and iter::to_vec 2013-06-06 22:11:48 +02:00
Marvin Löbel
857d433b9a Added IteratorUtil::collect 2013-06-06 22:11:48 +02:00
Marvin Löbel
af2086a2f1 Added iter::FromIter 2013-06-06 22:11:47 +02:00
Daniel Micay
8bcefef2f2 libc: omit memcpy, memmove and memset
LLVM provides these functions as intrinsics, and will generate calls to
libc when appropriate. They are exposed in the `ptr` module as
`copy_nonoverlapping_memory`, `copy_memory` and `set_memory`.
2013-06-06 15:18:45 -04:00
bors
0e96369224 auto merge of #6968 : huonw/rust/takeskip-iter, r=thestinger
@thestinger r?

Adding the dummy parameter stops the inference from having to work so hard.
2013-06-06 10:07:41 -07:00
Ramkumar Ramachandra
01c4f11cf8 libstd: use fmt! in to_str impl for (one|two)-tuple
The three-tuple uses fmt!, and there's no reason to hand-concatenate
strings.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-06-06 20:50:29 +05:30
Ramkumar Ramachandra
ab10b1ed29 libstd: fix comment in to_str impl of tuple
There is a pointer to #4760, which is a closed issue.  The real issue is
the more general problem described in #4653.  Correct the comment.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-06-06 20:50:29 +05:30
Alexei Sholik
e75572c879 Deduplicate words in code comments 2013-06-06 10:48:27 +03:00
Huon Wilson
32228f3d57 std: work-around for take/skip type inference (#6967) 2013-06-06 16:40:12 +10:00
Huon Wilson
848dbc93ee std: add an external iterator for mutating vec elements 2013-06-06 15:16:07 +10:00
John Clements
be22fddba0 rand example fixup 2013-06-05 12:01:39 -07:00
Patrick Walton
8114d0e950 librustc: Disallow multiple patterns from appearing in a "let" declaration.
You can still initialize multiple variables at once with "let (x, y) = (1, 2)".
2013-06-04 21:45:42 -07:00
bors
9873f67e94 auto merge of #6942 : thestinger/rust/cleanup, r=catamorphism
borrowed pointers already implement Eq and Ord with deep comparisons
2013-06-04 17:55:34 -07:00
bors
cf2b00dc8b auto merge of #6941 : Thiez/rust/pub_atomics, r=thestinger
As the title suggests, this marks all the fns on the impls on the atomic types in std::unstable::atomics as pub, which makes them significantly more usable (they are rather unusable otherwise).
r?
2013-06-04 16:52:34 -07:00
Daniel Micay
5148e2f78b sys: get rid of shape functions
borrowed pointers already implement Eq and Ord with deep comparisons
2013-06-04 19:00:19 -04:00
Daniel Micay
61ac5fdab7 clone: fix docstring
@T and @mut T for T: Const have DeepClone
2013-06-04 18:40:50 -04:00
Matthijs Hofstra
979b037e5a Made fns in the impls for the Atomic structs pub 2013-06-05 00:37:52 +02:00
Philipp Brüschweiler
1eb3a35094 std::util: fix missed old constructor 2013-06-04 17:29:38 +02:00
Philipp Brüschweiler
3ce75e786d std::util: Modernize NonCopyable constructor
part of #3853
2013-06-04 14:08:25 +02:00
Philipp Brüschweiler
e1c1c059c6 std::io: Modernize some constructors
Part of #3853
2013-06-04 12:47:45 +02:00
Philipp Brüschweiler
34ee63e93b std::cell: Modernize constructors
Part of #3853
2013-06-04 12:03:58 +02:00
bors
133d451715 auto merge of #6886 : jld/rust/vec-each-ret-fix, r=sanxiyn 2013-06-03 18:55:29 -07:00
bors
846545a6e1 auto merge of #6907 : steveklabnik/rust/prelude_docs, r=graydon 2013-06-03 14:37:39 -07:00
Steve Klabnik
fe70361bb6 Add better documentation for the Prelude. 2013-06-03 11:49:06 -07:00
Daniel Micay
e900dba28a rename the Ptr trait to RawPtr
Closes #6607
2013-06-03 13:50:29 -04:00
Brendan Zabarauskas
dee7c5af69 Add traits for concat and connect methods 2013-06-03 13:19:37 +10:00
Daniel Micay
454133127a ptr: split out borrowed pointer utilities
The ptr module is intended to be for raw pointers.

Closes #3111
2013-06-02 19:24:33 -04:00
gareth
d443fc6d90 Add a get_mut method to accompany the get method. 2013-06-02 16:22:43 +01:00
bors
c354a0c7eb auto merge of #6896 : nickdesaulniers/rust/issue4501, r=brson
review? @brson
2013-06-01 22:37:35 -07:00
bors
14c331053e auto merge of #6815 : kballard/rust/hashmap-insert_or_modify_with, r=erickt
`std::hashmap::HashMap.insert_or_update_with()` is basically the opposite
of `find_or_insert_with()`. It inserts a given key-value pair if the key
does not already exist, or replaces the existing value with the output
of the passed function if it does.

This is useful because replicating this with existing functionality is awkward, especially with the current borrow-checker. In my own project I have code that looks like

	if match map.find_mut(&key) {
		None => { true }
		Some(x) => { *x += 1; false }
	} {
		map.insert(key, 0);
	}

and it took several iterations to make it look this good. The new function turns this into

    map.insert_or_update_with(key, 0, |_,x| *x += 1);
2013-06-01 21:31:36 -07:00
Nick Desaulniers
ecd08b989a Swap return value of pipes::init Fixes #4501 2013-06-01 18:19:16 -07:00
Kevin Ballard
75f1b7f96f Add new function hashmap.insert_or_update_with()
fn insert_or_update_with<'a>(&'a mut self,
                             k: K,
                             f: &fn(&K, &mut V)) -> &'a V
2013-06-01 17:38:24 -07:00
Kevin Ballard
7bc950c43c Refactor some hashmap code into a new private function mangle()
Add new private hashmap function

    fn mangle(&mut self,
              k: K,
              not_found: &fn(&K) -> V,
              found: &fn(&K, &mut V)) -> uint

Rewrite find_or_insert() and find_or_insert_with() on top of mangle().

Also take the opportunity to change the return type of find_or_insert()
and find_or_insert_with() to &'a mut V. This fixes #6394.
2013-06-01 17:37:57 -07:00
Jed Davis
c5d7a77a53 Fix vec::each* return values 2013-06-01 11:52:02 -07:00
Erick Tryzelaar
871684376f std: fix run tests when symlink is in the rust checkout path 2013-06-01 10:59:24 -07:00
Patrick Walton
5fb254695b Remove all uses of pub impl. rs=style 2013-06-01 09:18:27 -07:00
bors
2bf053c0a3 auto merge of #6851 : alexcrichton/rust/bugfixes, r=pcwalton
Closes #5090 by using the excellent new generic deriving code

Promotes the unreachable code attribute to a lint attribute (instead of always being a warning)

Fixes some edge cases when creating hashmaps/hashsets and also when consuming them. (fixes #5998)
2013-05-31 23:10:36 -07:00
bors
c23843c447 auto merge of #6876 : cmr/rust/from_elem_opts, r=Aatch
borrowck 1.85x speedup on libstd
2013-05-31 22:04:38 -07:00
Corey Richardson
c299230f3d Optimize vec::from_elem with manual inlining (borrowck 1.85x speedup on libstd) 2013-06-01 00:55:19 -04:00
bors
b570536b38 auto merge of #6729 : bstrie/rust/ascstr, r=Aatch
Formerly this was a free function rather than a method. I've left it in place for now, although redefined it so that it just calls the method.
2013-05-31 19:34:41 -07:00
bors
e516d2333f auto merge of #6864 : thestinger/rust/bool, r=pcwalton 2013-05-31 16:58:42 -07:00
Daniel Micay
1dc4ea004e bool: rm functions duplicating methods 2013-05-31 18:12:12 -04:00
Ben Striegel
c77d58fad8 Add as_c_str method on strings 2013-05-31 18:12:07 -04:00
Daniel Micay
042618da7b ptr: replace unnecessary unsafe code 2013-05-31 11:32:27 -04:00
Daniel Micay
29aba8033a mv the raw pointer {swap,replace}_ptr to std::ptr 2013-05-31 10:31:26 -04:00
bors
030f471f26 auto merge of #6853 : bblum/rust/sized, r=pcwalton
r? @nikomatsakis @pcwalton
2013-05-31 02:01:44 -07:00
bors
1dd5cd9731 auto merge of #6833 : fdr/rust/fix-warnings, r=Aatch
Fix a laundry list of warnings involving unused imports that glutted
up compilation output.  There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
2013-05-31 00:43:45 -07:00
bors
f8cef24b5e auto merge of #6841 : steveklabnik/rust/range_docs, r=thestinger 2013-05-30 20:28:48 -07:00
Alex Crichton
d01c7d0d42 Fix a bug with HashMap::consume 2013-05-30 20:45:14 -05:00
Ben Blum
b8a53b5a4c Add 'Sized' builtin kind; doesn't do anything yet 2013-05-30 21:41:41 -04:00
Steve Klabnik
220e1a6cfc Add example for uint::range_step. 2013-05-30 14:35:07 -07:00
Daniel Farina
aef1e10eba Remove unnecessary 'use' forms
Fix a laundry list of warnings involving unused imports that glutted
up compilation output.  There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
2013-05-30 13:08:18 -07:00
Niko Matsakis
7a1a40890d Remove copy bindings from patterns. 2013-05-30 15:20:36 -04:00
Björn Steinbrink
1720d9f663 Remove a bunch of unnecessary allocations and copies 2013-05-30 11:49:04 +02:00
Alex Crichton
395685079a libextra: Require documentation by default 2013-05-30 01:03:15 -05:00
Alex Crichton
007651cd26 Require documentation by default for libstd
Adds documentation for various things that I understand.
Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-30 01:02:55 -05:00
Patrick Walton
206ab89629 librustc: Stop reexporting the standard modules from prelude. 2013-05-29 19:04:53 -07:00
Patrick Walton
aeda178011 librustc: Redo the unsafe checker and make unsafe methods not callable from safe code 2013-05-29 19:04:50 -07:00
bors
35655a0fb3 auto merge of #6803 : Thiez/rust/native_fmax_fmin, r=brson
Calls to the libc versions of fmin and fmax were relatively slow (perhaps because they could not be inlined?). This pull request provides f32 and f64 with fmin and fmax written in Rust, and shows a significant speed increase on my system; I used https://github.com/thiez/rustray as my benchmark, with --opt-level 3 it brings the ray-tracing time down from 10.8 seconds to about 9.2, which seemed significant to me.

r?
2013-05-29 13:29:06 -07:00
Matthijs Hofstra
3141acf674 Changed to a more efficient implementation. 2013-05-29 20:21:04 +02:00
Matthijs Hofstra
6cc9a26a2d Replaced calls to external fmin/fmax by a Rust implementation. 2013-05-29 18:26:50 +02:00
june0cho
14d59af0a3 Fix vec::mut_slice 2013-05-29 15:04:34 +09:00
bors
e0d6486ed6 auto merge of #6780 : june0cho/rust/issue5984, r=brson
Fix #5984. Also, I found a problem on type inference and left a comment.
2013-05-28 19:58:52 -07:00
bors
c8c60f063f auto merge of #6740 : Aatch/rust/atomic-types, r=brson
This is a follow up to #6732. Makes everything a little more sound.

r? @brson
2013-05-28 18:34:51 -07:00
Alex Crichton
b04c40bb1c Silence various warnings throughout test modules 2013-05-28 15:27:35 -05:00
bors
24784e8030 auto merge of #6771 : thestinger/rust/highlight, r=luqmana
This works with pandoc linked against highlighting-kate >= 0.5.3.8. It seems to just be a no-op with earlier versions, because I successfully ran this through `try`.

This also fixes some consistency issues (like making `Example`/`Examples` always a header and always using three tildes).
2013-05-28 04:02:02 -07:00
Junyoung Cho
56a2e5dc22 core::vec is missing methods for mutable slices 2013-05-28 10:29:35 +09:00
bors
dbc57584bd auto merge of #6724 : thestinger/rust/swap_fast, r=thestinger
Passing higher alignment values gives the optimization passes more freedom since it can copy in larger chunks. This change results in rustc outputting the same post-optimization IR as clang for swaps and most copies excluding the lack of information about padding.

Code snippet:

```rust
#[inline(never)]
fn swap<T>(x: &mut T, y: &mut T) {
    util::swap(x, y);
}
```

Original IR (for `int`):

```llvm
define internal fastcc void @_ZN9swap_283417_a71830ca3ed2d65d3_00E(i64*, i64*) #1 {
static_allocas:
  %2 = icmp eq i64* %0, %1
  br i1 %2, label %_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit, label %3

; <label>:3                                       ; preds = %static_allocas
  %4 = load i64* %0, align 1
  %5 = load i64* %1, align 1
  store i64 %5, i64* %0, align 1
  store i64 %4, i64* %1, align 1
  br label %_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit

_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit:  ; preds = %3, %static_allocas
  ret void
}
```

After #6710:

```llvm
define internal fastcc void @_ZN9swap_283017_a71830ca3ed2d65d3_00E(i64* nocapture, i64* nocapture) #1 {
static_allocas:
  %2 = load i64* %0, align 1
  %3 = load i64* %1, align 1
  store i64 %3, i64* %0, align 1
  store i64 %2, i64* %1, align 1
  ret void
}
```

After this change:

```llvm
define internal fastcc void @_ZN9swap_283017_a71830ca3ed2d65d3_00E(i64* nocapture, i64* nocapture) #1 {
static_allocas:
  %2 = load i64* %0, align 8
  %3 = load i64* %1, align 8
  store i64 %3, i64* %0, align 8
  store i64 %2, i64* %1, align 8
  ret void
}
```

Another example:

```rust
#[inline(never)]
fn set<T>(x: &mut T, y: T) {
    *x = y;
}
```

Before, with `(int, int)` (align 1):

```llvm
define internal fastcc void @_ZN8set_282517_8fa972e3f9e451983_00E({ i64, i64 }* nocapture, { i64, i64 }* nocapture) #1 {
static_allocas:
  %2 = bitcast { i64, i64 }* %1 to i8*
  %3 = bitcast { i64, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 1, i1 false)
  ret void
}
```

After, with `(int, int)` (align 8):

```llvm
define internal fastcc void @_ZN8set_282617_8fa972e3f9e451983_00E({ i64, i64 }* nocapture, { i64, i64 }* nocapture) #1 {
static_allocas:
  %2 = bitcast { i64, i64 }* %1 to i8*
  %3 = bitcast { i64, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  ret void
}
```
2013-05-27 15:56:08 -07:00
Daniel Micay
e6c04dea03 fix casts on 32-bit 2013-05-27 18:14:00 -04:00
bors
b0f3686515 auto merge of #6703 : sanxiyn/rust/allocation-lint, r=sanxiyn
Fix #6145. In particular, handle operator overloading.
2013-05-27 12:38:12 -07:00
Daniel Micay
0d5fdce82e syntax highlight code examples in docstrings 2013-05-27 14:47:21 -04:00
Seo Sanghyeon
8f80323f09 Remove unnecessary allocations flagged by lint 2013-05-28 03:14:44 +09:00
Lindsey Kuper
beec6e4b21 Get rid of no-longer-needed #[doc(hidden)] attributes.
There were several old `#[doc(hidden)]` attributes in libstd and
libextra, left over from when rustdoc didn't hide private
definitions, tagged with `FIXME #3538`.

Since #3538 is now closed, I removed the `#[doc(hidden)]` attributes
as well as the FIXMEs, but I left `#[doc(hidden)]` in
libstd/task/spawn.rs and libstd/task/rt.rs since those two are
apparently `pub`, as well as in libextra/std.rc since std/extra is
`pub`.
2013-05-27 13:29:48 -04:00
bors
3941f78a1b auto merge of #6763 : steveklabnik/rust/core_to_std, r=thestinger
When I submitted #6748 yesterday, I used the old name.

r? @thestinger
2013-05-27 07:08:04 -07:00
Steve Klabnik
e2fcb92a6d Fix docs to use std instead of core.
When I submitted #6748 yesterday, I used the old name.
2013-05-27 08:19:57 -05:00
gareth
04a39359f8 Rename unwrap_input/unwrap_output as suggested by
@brson. Also fix a few documentation bugs.
2013-05-27 13:50:33 +01:00
gareth
49a1ab8745 Make test_change_working_directory change the current
directory to be the parent of the current-current directory,
instead of changing to the tmp directory, which was causing
issues with OS X and its /tmp => /private/tmp symlink.
2013-05-27 13:50:33 +01:00
gareth
76c31217be Refactor core::run in order to address many of the issues
mentioned in #2625.

This change makes the module more oriented around
Process values instead of having to deal with process ids
directly.

Apart from issues mentioned in #2625, other changes include:
- Changing the naming to be more consistent - Process/process
  is now used instead of a mixture of Program/program and
  Process/process.
- More docs/tests.

Some io/scheduler related issues remain (mentioned in #2625).
2013-05-27 13:50:33 +01:00
bors
f5d4ea84f5 auto merge of #6748 : steveklabnik/rust/bool_docs, r=thestinger
There was some before, but now we have a big header, as well as
lots of individual bits of documentation.
2013-05-26 10:32:02 -07:00
Steve Klabnik
9bb8077c18 Add documentation for libstd/bool.rs.
There was some before, but now we have a big header, as well as
lots of individual bits of documentation.
2013-05-26 09:39:55 -05:00
Daniel Micay
14846613bb inline bump_box_refcount 2013-05-26 10:26:04 -04:00
Daniel Micay
b25c520102 make transmute_copy use memcpy, and inline it 2013-05-26 10:26:04 -04:00
Daniel Micay
f6023a01d4 use uninit for cast::transmute_copy 2013-05-26 10:26:03 -04:00
Daniel Micay
d9c0f0f188 add memset32/memset64 2013-05-26 10:26:03 -04:00
Daniel Micay
2eaa5dbb60 C++0x -> C++11 2013-05-26 10:26:03 -04:00
Daniel Micay
cf8e9f9aec make the memcpy/memmove intrinsics higher-level
This allows them to make use of the type's alignment, instead of being
pessimistic and assuming it is only 1.
2013-05-26 10:26:03 -04:00
Tim Chevalier
a243ea39c3 testsuite: Add a test for listing the root directory...
...and don't treat Path("/") like Path("").
2013-05-25 20:47:44 -07:00
Tim Chevalier
196851c4c9 core: Fail with a better error message when list_dir gets an empty path
(Yes, this did happen in real life...)
2013-05-25 20:47:43 -07:00
James Miller
df1814ba08 Add some documentation 2013-05-26 12:54:30 +12:00
James Miller
30b471bf23 Add AtomicOption type 2013-05-26 12:39:53 +12:00
James Miller
008e6e5e7e Make AtomicPtr use *mut, instead of ~ 2013-05-26 11:44:31 +12:00
bors
e2f8b51dc5 auto merge of #6722 : alexcrichton/rust/issue-4219-no-merge-hack, r=brson
Changes the int/uint modules to all use macros instead of using the `merge` attribute. It would be nice to have #4375 resolved as well for this, but that can probably come at a later date.

Closes #4219.
2013-05-25 15:13:54 -07:00
James Miller
523360415c Add basic atomic types 2013-05-25 17:51:26 +12:00
Alex Crichton
ec8fb884e9 Remove usage of the #[merge] hack with int modules 2013-05-24 15:31:34 -05:00
bors
2f69bb9ba9 auto merge of #6712 : thestinger/rust/derive, r=catamorphism 2013-05-24 02:04:47 -07:00
Daniel Micay
0629ef16e8 use deriving for DeepClone 2013-05-24 01:16:15 -04:00
bors
212d6a2f61 auto merge of #6710 : thestinger/rust/swap, r=catamorphism 2013-05-23 22:04:40 -07:00
Daniel Micay
7bff0281c7 optimize util::swap, &mut pointers never alias 2013-05-23 23:00:16 -04:00
Jyun-Yan You
abb2823c35 make arm register definition consistent with rt 2013-05-24 10:42:09 +08:00
Daniel Micay
7d2f836065 add memcpy intrinsic to mirror memmove 2013-05-23 22:29:30 -04:00
Daniel Micay
5ba5865e85 swap_ptr: rm equality check
This isn't needed semantically, and it's the wrong case to optimize for.
2013-05-23 21:57:37 -04:00
Erick Tryzelaar
dc970c13f4 cleanup warnings from libstd 2013-05-23 17:48:16 -07:00
Erick Tryzelaar
1965d72957 core: remove iter_bytes helper functions 2013-05-23 17:48:16 -07:00
Patrick Walton
18df18c817 libstd: Fix merge fallout. 2013-05-22 21:57:11 -07:00
Patrick Walton
c10e0cb9c9 syntax: Change syntax extensions to expand to std::foo instead of core::foo 2013-05-22 21:57:08 -07:00
Patrick Walton
f3723cf7c4 libextra: Rename the actual metadata names of libcore to libstd and libstd to libextra 2013-05-22 21:57:07 -07:00
Patrick Walton
ebfc2b8e56 librustc: Rename core injection to std injection 2013-05-22 21:57:05 -07:00
Patrick Walton
0c820d4123 libstd: Rename libcore to libstd and libstd to libextra; update makefiles.
This only changes the directory names; it does not change the "real"
metadata names.
2013-05-22 21:57:05 -07:00
Jihyun Yu
06685bacf8 add smallintset 2013-05-22 21:01:21 +09:00
bors
5a3e320514 auto merge of #6647 : alexcrichton/rust/unnecessary-alloc, r=graydon
This adds a lint mode for detecting unnecessary allocations on the heap. This isn't super fancy, currently it only has two rules

1. For a function's arguments, if you allocate a `[~|@]str` literal, when the type of the argument is a `&str`, emit a warning.
2. For the same case, emit warnings for boxed vectors when slices are required.

After adding the lint, I rampaged through the libraries and removed all the unnecessary allocations I could find.
2013-05-20 23:55:20 -07:00
bors
6d4845668f auto merge of #6372 : brson/rust/intrinsics, r=catamorphism
...s
2013-05-20 15:49:45 -07:00
bors
54eafc009d auto merge of #6639 : osaut/rust/arc-clean, r=brson
* Add ARC::get method and implements the function from it.
* Add an example showing a simple use of ARC.

Update PR #6622 to avoid git noise.

I will remove the function get later.
2013-05-20 14:46:45 -07:00
Brian Anderson
7bd4217766 Replace all uses of rust-intrinsic ABI with calls to unstable::intrinsics 2013-05-20 14:41:56 -07:00
Alex Crichton
82fa0018c8 Remove all unnecessary allocations (as flagged by lint) 2013-05-20 16:10:40 -05:00
Steve Klabnik
eb3f47a40a Remove two warnings about unneccesary safe blocks.
Since a snapshot was done last night, these are good to go.
2013-05-20 09:17:19 -07:00
Olivier Saut
3f232bc4a0 Add ARC::get method and implements the function from it. Add an example showing a simple use of ARC. 2013-05-20 12:07:14 +02:00
Olivier Saut
a9c7d3f775 Typo corrected and updated copyright years 2013-05-20 12:06:37 +02:00
Brian Anderson
66319b0278 Register snapshots 2013-05-19 23:34:32 -07:00
bors
9f671698e6 auto merge of #6106 : thestinger/rust/iter, r=bstrie
I don't have a strong opinion on the function vs. method, but there's no point in having both. I'd like to make a `repeat` adaptor like Python/Haskell for turning a value into an infinite stream of the value, so this has to at least be renamed.
2013-05-19 08:13:30 -07:00
Corey Richardson
cc57ca012a Use assert_eq! rather than assert! where possible 2013-05-19 08:16:02 -04:00
bors
3ee479f3e9 auto merge of #6577 : brson/rust/io-upstream, r=pcwalton
r?

This is all of my scheduler work on #4419 from the last 3 weeks or so. I've had a few failed pull requests so far but I think the problems are ironed out.

* TCP
* The beginnings of runtime embedding APIs
* Porting various corners of core to be compatible with both schedulers
* libuv timer bindings
* Further refinement of I/O error handling, including a new, incomplete, `read_error` condition
* Incomplete refactoring to make tasks work without coroutines and user-space scheduling
* Implementations of Reader/Writer extension methods
* Implementations of the most important part of core::comm

I'm particularly happy with how easy the [comm types on top of the scheduler](https://github.com/brson/rust/blob/io-upstream/src/libcore/rt/comm.rs). Note that these implementations do not use pipes. If anything here needs careful review though it's this code.

This branch passes 95% of the run-pass tests (with `TESTARGS=--newrt`)

In the next week I'll probably spend some time adding preliminary multithreading and seeing how close we are to removing the old runtime.
2013-05-18 18:37:25 -07:00
Olivier Saut
4b13895c2f Remove trailing whitespaces 2013-05-18 11:53:51 +02:00
Daniel Micay
d953a5ce43 replace old_iter::repeat with the Times trait 2013-05-18 04:57:21 -04:00
Brian Anderson
26becc308e core: Wire up oneshot pipes to newsched 2013-05-17 17:54:27 -07:00
Brian Anderson
03a8e59615 Merge remote-tracking branch 'brson/io' into incoming 2013-05-17 17:53:50 -07:00
Olivier Saut
7dc466f91f Correct the example given for a future, add punctuation where necessary 2013-05-17 23:11:18 +02:00
Huon Wilson
aa179cb0f1 rustc: relax limits on (u)int type limit lint. Fixes #6130. 2013-05-18 01:49:36 +10:00
bors
ce6dc2451f auto merge of #6520 : thestinger/rust/rc, r=pcwalton
This is still enough to prevent cycles (explanation given in the docstring).
2013-05-16 03:25:43 -07:00
Daniel Micay
4702667a62 allow constructing Rc/RcMut from Const types too 2013-05-15 19:18:09 -04:00
Huon Wilson
5dc5efefd4 syntax: deprecate #[auto_{en,de}code] in favour of #[deriving({En,De}codable)].
Replace all instances of #[auto_*code] with the appropriate #[deriving] attribute
and remove the majority of the actual code, leaving stubs to refer the user to
the new syntax.
2013-05-16 08:55:57 +10:00
bors
8a15333c06 auto merge of #6498 : thestinger/rust/deep_clone, r=thestinger
This is mostly for `std::rc` and `std::arc` (but I haven't implemented it for ARC yet).

Implementing it correctly for managed boxes is *very* non-trivial. It would probably require an unholy mix of reflection and TLS.
2013-05-15 12:22:58 -07:00
Brian Anderson
0d1331f4a0 Merge remote-tracking branch 'brson/io' into incoming 2013-05-15 12:09:15 -07:00
Brian Anderson
4724966b06 core::rt: Add uv timer bindings 2013-05-15 12:19:15 -07:00
bors
4e82610099 auto merge of #6487 : recrack/rust/vec_len, r=thestinger
Rename vec::len(var) to var.len()

```
libcore, libfuzzer, librustc, librustdoc, libstd, libsyntax
test/auxiliary
test/bench
test/run-pass
```
2013-05-15 07:38:07 -07:00
Daniel Micay
cda3ac905a rc: fix tests 2013-05-15 04:34:31 -04:00
Daniel Micay
75822f2894 add a DeepClone trait
for deep copies through shared ownership boundaries
2013-05-15 01:36:41 -04:00
Youngmin Yoo
a2a8596c3d Rename vec::len(var) to var.len() 2013-05-15 11:05:28 +09:00
bors
cf0f760560 auto merge of #6333 : bjz/rust/cond-macro, r=thestinger
Addressing issue #6037, this Scheme-style conditional helps to improve code clarity in instances where the `if`, `else if`, and `else` keywords obscure predicates undesirably.

Here is an example:

~~~rust
let clamped =
    if x > mx { mx }
    else if x < mn { mn }
    else { x };
~~~

Using `cond!`, the above could be written as:

~~~rust
let clamped = cond!(
    (x > mx) { mx }
    (x < mn) { mn }
    _        { x  }
);
~~~

The optional default case is denoted by `_`.

I have altered `std::fun_treemap` to demonstrate it in use. I am definitely interested in using it for some of the numeric functions, but I will have to wait for it to reach `stage0` first.
2013-05-14 18:11:00 -07:00
Brendan Zabarauskas
7e4a176dd3 Use parentheses for cond! macro instead of preceding pipes
This is temporary. Once the macro parser has improved or been re-written these can be removed.
2013-05-15 11:02:17 +10:00
bors
c30414f980 auto merge of #6471 : gifnksm/rust/reform-rational, r=brson
`std::ratio` module contains `BigRational` type, but the type is not usable by following reasons.
* `Ratio::new` requires `T: Copy + Num + Ord`, but `BigInt` is not implicitly copyable, because it contains unique vector.
* `BigInt` is not implements `Num`

So, I rewrite `Ratio` as follows.
* `Ratio` requires `T: Clone + Integer + Ord`.
  * `Copy` -> `Clone`: to be able to use `BigRational`
  * `Num` -> `Integer`: It is incorrect that a rational number constructed by two non-integer numbers.
* `BigInt` implements `Num` and `Orderable` which are required by `Integer` bound
2013-05-14 15:28:59 -07:00
Brendan Zabarauskas
b9824e18c2 Add Scheme-style cond! macro to syntax::ext::expand
Addresses issue #6037
2013-05-15 07:02:43 +10:00
Brian Anderson
133aabc5bb Ignore two failing flatpipes tests 2013-05-14 11:35:10 -07:00
Alex Crichton
ccfb3ebf03 rusti: Remove #[allow(vecs_implicitly_copyable)] 2013-05-14 12:25:18 -04:00
Marvin Löbel
04de8f852c Fix cosmetics for fail!() calls 2013-05-14 16:36:24 +02:00
Björn Steinbrink
bdc182cc41 Use static string with fail!() and remove fail!(fmt!())
fail!() used to require owned strings but can handle static strings
now. Also, it can pass its arguments to fmt!() on its own, no need for
the caller to call fmt!() itself.
2013-05-14 16:36:23 +02:00
gifnksm
da9c1fbf27 libstd: Add tests for BigRational 2013-05-14 21:59:13 +09:00
gifnksm
76ecce0e0c libstd: Ratio requires Clone instead of Copy
This allows creating `Ratio<T>` which `T` is non-implicitly copyable types
such as `BigInt`.
2013-05-14 21:59:08 +09:00
gifnksm
41eaa97372 libstd: Rational requires Integer as type bounds instead of Num 2013-05-14 21:55:42 +09:00
gifnksm
e3695468b7 libstd: impl Orderable for BigUint/BigInt 2013-05-14 21:20:27 +09:00
gifnksm
5ce0795de5 libstd: impl Num for BigUint/BigInt 2013-05-14 19:27:20 +09:00
Daniel Micay
e1a1992276 revert PriorityQueue to using init()
uninit() would result in potentially running a destructor on arbitrary
memory if the Ord implementation throws
2013-05-13 19:46:20 -04:00
bors
ad5bfd600d auto merge of #6387 : brson/rust/unstable, r=brson
r? @pcwalton

* Move `SharedMutableState`, `LittleLock`, and `Exclusive` from `core::unstable` to `core::unstable::sync`
* Modernize the `SharedMutableState` interface with methods
* Rename `SharedMutableState` to `UnsafeAtomicRcBox` to match `RcBox`.
2013-05-13 14:49:48 -07:00
Brian Anderson
369231beb4 core: Rename SharedMutableState to UnsafeAtomicRcBox 2013-05-13 12:13:56 -07:00
Brian Anderson
fa1d0477ed core: Move locks, atomic rc to unstable::sync 2013-05-13 12:13:56 -07:00
Patrick Walton
58a37a1f48 libstd: Fix merge fallout. 2013-05-12 17:36:53 -07:00
Patrick Walton
06ef889cdc libsyntax: Remove extern mod foo { ... } from the language. 2013-05-12 16:33:15 -07:00
bors
36771ef609 auto merge of #6429 : gifnksm/rust/bigint-is_even, r=catamorphism
`BigUint::is_even()` didn't return correct value.
2013-05-11 22:40:36 -07:00
Corey Richardson
a279d65102 clean up the last bit of warnings 2013-05-11 20:36:47 -07:00
Tim Chevalier
ed41864464 Warning police 2013-05-11 20:36:44 -07:00
gifnksm
a2b81ccba4 libstd: Fix BigUint::is_even 2013-05-12 10:17:23 +09:00
bors
957251817b auto merge of #6389 : sonwow/rust/issue-3356, r=bstrie
Fix for #3356
2013-05-11 12:55:49 -07:00
bors
9f106a643e auto merge of #6260 : alexcrichton/rust/issue-3466-no-swap, r=pcwalton
There may be a more efficient implementation of `core::util::swap_ptr`. The issue mentioned using `move_val_init`, but I couldn't figure out what that did, so I just used `copy_memory` a few times instead.

I'm not exactly the best at reading LLVM generated by rust, but this does appear to be optimized away just as expected (when possible).
2013-05-10 20:35:00 -07:00
Alex Crichton
998fececd6 Stop using the '<->' operator 2013-05-10 22:51:06 -04:00
bors
c49cf8b330 auto merge of #6205 : brson/rust/flate, r=brson
r? @graydon

I don't think this is necessary in core.
2013-05-10 19:41:00 -07:00
bors
3e0400fb86 auto merge of #6223 : alexcrichton/rust/issue-6183, r=pcwalton
Closes #6183.

The first commit changes the compiler's method of treating a `for` loop, and all the remaining commits are just dealing with the fallout.

The biggest fallout was the `IterBytes` trait, although it's really a whole lot nicer now because all of the `iter_bytes_XX` methods are just and-ed together. Sadly there was a huge amount of stuff that's `cfg(stage0)` gated, but whoever lands the next snapshot is going to have a lot of fun deleting all this code!
2013-05-10 17:56:02 -07:00
Alex Crichton
b05aae2d41 test: Use the new for protocol 2013-05-10 19:20:20 -04:00
Brian Anderson
7652f3ddb8 Move flate from core to std 2013-05-10 16:00:26 -07:00
Youngsoo Son
24ef88cee9 renamed str::from_slice to str::to_owned 2013-05-10 20:08:56 +09:00
bors
fdf601eaf3 auto merge of #6358 : crabtw/rust/mips-segstk, r=brson
I changed ```RED_ZONE_SIZE``` to ```RZ_MAC_32``` because of stack canary failure.
Here is a LLVM patch for MIPS segmented stacks.
http://people.cs.nctu.edu.tw/~jyyou/rust/mips-segstk.patch

Current test results
```
failures:
    rand::tests::test_rng_seeded_custom_seed2
    run::tests::test_forced_destroy_actually_kills
    run::tests::test_unforced_destroy_actually_kills
    time::tests::run_tests
    uv_ll::test::test_uv_ll_struct_size_addrinfo
    uv_ll::test::test_uv_ll_struct_size_uv_timer_t

segfaults:
    rt::io::option::test::test_option_writer_error
    rt::local_services::test::unwind
    rt::sched::test_swap_tasks_then
    stackwalk::test_simple
    stackwalk::test_simple_deep
```
2013-05-10 04:07:50 -07:00
bors
6da2c989ba auto merge of #6329 : sonwow/rust/issue-6306, r=ILyoan
Fix for #6306
2013-05-10 03:04:51 -07:00
Youngsoo Son
b7da975049 renamed vec::from_slice to vec::to_owned 2013-05-10 18:38:54 +09:00
bors
3e106cf2c2 auto merge of #6339 : alexcrichton/rust/unsafe-cvec, r=catamorphism
As noted by @jwise [here](52445129fd (commitcomment-3172192)), it's probably a good idea to keep these unsafe.

The lint check won't warn about these because it ignore `unsafe fn` declarations.
2013-05-09 23:58:53 -07:00
Alex Crichton
a87db3e2cd rustc: Use the new for protocol 2013-05-10 02:46:19 -04:00
Alex Crichton
3ce9dba677 std: Use the new for protocol 2013-05-10 02:46:18 -04:00
Youngsoo Son
c8e93edf55 Move core::task::local_data to core::local_data 2013-05-10 11:42:45 +09:00
bors
7675856253 auto merge of #6354 : Aatch/rust/uninit-intrinsic, r=graydon
Adds an `uninit` intrinsic.

It's just an empty function, so llvm optimizes it down to nothing.

I changed all of the `init` intrinsic usages to `uninit` where it seemed appropriate to.
2013-05-09 12:37:00 -07:00
bors
ce9c0225c4 auto merge of #6349 : thestinger/rust/explicit_copy, r=thestinger
I removed some of the copies, but most are just made explicit. The usage in `libcore` was already fixed, but the attribute was only set to warn (not removed).
2013-05-09 11:18:43 -07:00
Daniel Micay
2bc12635a2 remove vecs_implicitly_copyable from libstd/libcore 2013-05-09 14:00:53 -04:00
Alex Crichton
d6efbad33f Mark c_vec functions as unsafe again 2013-05-09 07:40:19 -04:00
James Miller
414970c46f Add intrinsic declaration where I missed them 2013-05-09 23:16:07 +12:00
James Miller
57509709b4 Make staged versions of the functions that use uninit 2013-05-09 23:05:17 +12:00
bors
ca95e7f94e auto merge of #6345 : seanmoon/rust/fix-typos, r=sanxiyn
Hi there,

Really enjoying Rust. Noticed a few typos so I searched around for a few more--here's some fixes.

Ran `make check` and got `summary of 24 test runs: 4868 passed; 0 failed; 330 ignored`.

Thanks!

Sean
2013-05-09 03:51:32 -07:00
James Miller
f5ab112e6b Replace init() with uninit() where appropriate 2013-05-09 22:41:54 +12:00
Jyun-Yan You
c2bf9bf9fe improve MIPS backend and implement segmented stacks 2013-05-09 16:51:42 +08:00
bors
fda176b070 auto merge of #6337 : thestinger/rust/fix_region, r=thestinger
also removes unnecessary casts from the RcMut implementation
2013-05-09 00:15:33 -07:00
bors
936c07dcf0 auto merge of #6328 : recrack/rust/rename_cleanup, r=sanxiyn
rename vec::each(var) to var.each

> librustc, libsyntax, libstd, librustdoc, libcore
2013-05-08 22:54:37 -07:00
Youngmin Yoo
d4fa0f1485 libstd: rename vec::each(var) to var.each 2013-05-09 14:20:04 +09:00
bors
101d4bf8b2 auto merge of #6332 : huonw/rust/std-base64-match, r=nikomatsakis 2013-05-08 21:45:37 -07:00
Patrick Walton
16a0125e41 libcore: Fix tests. 2013-05-08 17:04:01 -07:00
Patrick Walton
49a66a5c5a librustc: Stop parsing modes and remove them entirely from the language 2013-05-08 17:04:01 -07:00
Patrick Walton
99daec602f librustc: Fix merge fallout. 2013-05-08 17:04:00 -07:00
Patrick Walton
c7522417d4 libstd: Remove some residual mutable fields 2013-05-08 17:04:00 -07:00
Patrick Walton
d12d25534b libcore: Remove more mutable fields from comm 2013-05-08 17:03:59 -07:00
Patrick Walton
6a44482b17 libcore: Remove mutable fields from pipes 2013-05-08 17:03:59 -07:00
Patrick Walton
803a4f45fa libcore: Remove mutable fields from the task builder API 2013-05-08 17:03:59 -07:00
Patrick Walton
b2d1ac100f libcore: Remove mutable fields from rand. 2013-05-08 17:03:58 -07:00
Patrick Walton
ee78d811e4 libstd: Start warning about mutable fields, now that they only exist in stage0 2013-05-08 17:03:58 -07:00
Patrick Walton
bba0680cb0 libstd: Remove mutable fields from future and par 2013-05-08 17:03:58 -07:00
Patrick Walton
92d2ec4d32 libstd: Remove mutable fields from flatpipes and io_util 2013-05-08 17:03:58 -07:00
Patrick Walton
da2ac90812 libstd: Remove mutable fields from fileinput and net_tcp 2013-05-08 17:03:57 -07:00
Daniel Micay
044abef0e5 fix incorrect region code based on the old 'self
also removes unnecessary casts from the RcMut implementation
2013-05-08 16:00:49 -04:00
Sean Moon
bd4ee7c7d2 Fix typos 2013-05-09 02:34:47 +09:00