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