Commit Graph

2250 Commits

Author SHA1 Message Date
Niko Matsakis
5606fc0c90 Revert map.each to something which takes two parameters
rather than a tuple.  The current setup iterates over
`BaseIter<(&'self K, &'self V)>` where 'self is a lifetime declared
*in the each method*.  You can't place such a type in
the impl declaration.  The compiler currently allows it,
but this will not be legal under #5656 and I'm pretty sure
it's not sound now.
2013-04-10 07:51:48 -07:00
bors
80b6bbd7b5 auto merge of #5789 : brson/rust/drop, r=graydon 2013-04-09 19:33:57 -07:00
bors
5e570ce4b0 auto merge of #5766 : thestinger/rust/cmp, r=brson
It was simpler to just give the variants a value instead of listing out all the cases for (*self, *other) in a match statement or writing spaghetti code. This makes the `cmp` method easier to use with FFI too, since you're a cast away from an idiomatic C comparator function. It would be fine implemented another way though.
2013-04-09 16:09:59 -07:00
Brian Anderson
23251b2438 Bump version to 0.7-pre 2013-04-09 10:59:32 -07:00
bors
412a07055c auto merge of #5769 : gifnksm/rust/range_step, r=bstrie
`uint::range_step` or `int::range_step` causes overflow or underflow as following.
code:
```rust
fn main() {
    for uint::range_step(3, 0, -2) |n| {
        println(fmt!("%u", n));
    }
}
```
output:
```
3
1
18446744073709551615
18446744073709551613
...
```
This commit fixes this behavior as follows.
```
3
1
```
2013-04-09 07:52:04 -07:00
bors
30dbbe17c9 auto merge of #5787 : alexcrichton/rust/less-mut-fields, r=catamorphism
This removes some of the easier instances of mutable fields where the explicit self can just become `&mut self` along with removing some unsafe blocks which aren't necessary any more now that purity is gone.

Most of #4568 is done, except for [one case](https://github.com/alexcrichton/rust/blob/less-mut-fields/src/libcore/vec.rs#L1754) where it looks like it has to do with it being a `const` vector. Removing the unsafe block yields:

```
/Users/alex/code/rust2/src/libcore/vec.rs:1755:12: 1755:16 error: illegal borrow unless pure: creating immutable alias to const vec content
/Users/alex/code/rust2/src/libcore/vec.rs:1755         for self.each |e| {
                                                           ^~~~
/Users/alex/code/rust2/src/libcore/vec.rs:1757:8: 1757:9 note: impure due to access to impure function
/Users/alex/code/rust2/src/libcore/vec.rs:1757         }
                                                       ^
error: aborting due to previous error
```

I also didn't delve too much into removing mutable fields with `Cell` or `transmute` and friends.
2013-04-08 18:36:57 -07:00
Brian Anderson
2e907a3ac2 core: Remove all but one drop block in favor of finally 2013-04-08 16:16:32 -07:00
Alex Crichton
255193cc1a Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00
bors
1968130885 auto merge of #5763 : thestinger/rust/clone, r=nikomatsakis
Performing a deep copy isn't ever desired for a persistent data
structure, and it requires a more complex implementation to do
correctly. A deep copy needs to check for cycles to avoid an infinite
loop.
2013-04-08 14:12:55 -07:00
Daniel Micay
68d17bca4b clone: managed boxes need to clone by shallow copy
Performing a deep copy isn't ever desired for a persistent data
structure, and it requires a more complex implementation to do
correctly. A deep copy needs to check for cycles to avoid an infinite
loop.
2013-04-08 16:19:12 -04:00
Huon Wilson
41c6f67109 libcore: from_str_common: provide option to ignore underscores.
Implement the possible improvement listed in the comment on
from_str_bytes_common.
2013-04-08 16:35:39 +10:00
Huon Wilson
49cdf36d2b libcore: from_str_common: correctly signal failure on repeating base 2^n numbers.
A number like 0b1_1111_1111 == 511 would be parsed to Some(255u8) rather than None
by from_str_common, since 255 * 2 + 1 == 255 (mod 256) so the overflow wasn't detected.

Only applied to conversions where the radix was a power of 2, and where all digits
repeated.

Closes #5770.
2013-04-08 16:35:39 +10:00
gifnksm
89676d6a59 libcore: fix overflow/underflow in range_step 2013-04-07 19:55:58 +09:00
Daniel Micay
a3f40184bd cmp: add Ord+TotalOrd impls for Ordering itself 2013-04-07 01:02:51 -04:00
Daniel Micay
c47d80304e cmp: derive Clone for Ordering 2013-04-07 00:33:10 -04:00
bors
d09835d2e3 auto merge of #5751 : metajack/rust/at-clones, r=thestinger
The borrowck-borrow-from-expr-block test had to be updated. I'm not sure why
it compiled before since ~int was already clonable.
2013-04-06 00:06:47 -07:00
Jack Moffitt
d375171fd4 Move tests inside clone.rs and fixed copyright headers. 2013-04-05 17:51:43 -06:00
Jack Moffitt
b22a06000d Implement Clone for @ and @mut types.
The borrowck-borrow-from-expr-block test had to be updated. I'm not sure why
it compiled before since ~int was already clonable.
2013-04-05 16:41:47 -06:00
Niko Matsakis
2a44a1bd97 Fix various warnings, NOTEs, etc 2013-04-05 05:36:03 -04:00
Niko Matsakis
d28f734412 Refactor so that references to traits are not represented using a type with a
bare function store (which is not in fact a kind of value) but rather
ty::TraitRef.  Removes many uses of fail!() and other telltale signs of
type-semantic mismatch.

cc #4183 (not a fix, but related)
2013-04-05 05:36:02 -04:00
bors
babe506333 auto merge of #5722 : metajack/rust/cell-with-ref-mut, r=catamorphism 2013-04-04 17:12:46 -07:00
Jack Moffitt
2c02aab758 Add cell#with_mut_ref for handling mutable references to the content. 2013-04-04 11:34:35 -06:00
Jyun-Yan You
fdf48a7b52 rt: improve mips backend 2013-04-04 18:53:58 +08:00
bors
17ab718d59 auto merge of #5698 : Thiez/rust/de-mutfielding, r=pcwalton
This pull request removes some mut-fields from at_vec, str, vec, unstable, and cell. Sadly in case of Cell this required using either transmute_mut (2 instances) or changing the interface. I chose the former. Perhaps it would be a good idea to merge Cell and Option, and take that opportunity to change the interface to use '&mut self' instead of '&self' (which would enable removing the transmutations) for take and put_back.

r?
2013-04-03 15:07:00 -07:00
bors
5b933aeba2 auto merge of #5696 : thestinger/rust/hashmap, r=sanxiyn
This naming is free now that `oldmap` has finally been removed, so this is a search-and-replace to take advantage of that. It might as well be called `HashMap` instead of being named after the specific implementation, since there's only one.

SipHash distributes keys so well that I don't think there will ever be much need to use anything but a simple hash table with open addressing. If there *is* a better way to do it, it will probably be better in all cases and can just be the default implementation. 

A cuckoo-hashing implementation combining a weaker hash with SipHash could be useful, but that won't be as general purpose - you would need to write a separate fast hash function specialized for the type to really take advantage of it (like taking a page from libstdc++/libc++ and just using the integer value as the "hash"). I think a more specific naming for a truly alternative implementation like that would be fine, with the nice naming reserved for the general purpose container.
2013-04-03 14:04:07 -07:00
Matthijs Hofstra
397a478528 Unstable didn't need transmute_mut after all. 2013-04-03 18:28:44 +02:00
Matthijs Hofstra
c16919d3a8 Removing mut fields from vec.rs, at_vec.rs, str.rs, unstable.rs, and cell.rs. 2013-04-03 16:33:23 +02:00
Daniel Micay
cc148b58ff rename Linear{Map,Set} => Hash{Map,Set} 2013-04-03 10:30:36 -04:00
Daniel Micay
44029a5bbc hashmap: rm linear namespace 2013-04-03 10:30:18 -04:00
James Miller
e2bffb7971 Implement Clone for tuples 2013-04-03 19:43:23 +13:00
bors
26d8b5188a auto merge of #5674 : steveklabnik/rust/improve_reader_util_docs, r=catamorphism
I filled out better descriptions for all of the necessary
functions.

r?
2013-04-02 21:18:43 -07:00
bors
cb16cd9423 auto merge of #5673 : steveklabnik/rust/improve_io_docs, r=catamorphism
When I submitted #5659, it apparently caused some test failures. Then, because I left it in my incoming rather than making a new branch, I deleted my commit.

Let's try this again, this time, with its own branch so that I don't screw it up.

r?
2013-04-02 20:15:43 -07:00
Steve Klabnik
a3e2d6ea81 Remove excess trailing whitespace. 2013-04-02 17:31:42 -07:00
Steve Klabnik
86d5ce5cef remove trailing whitespace 2013-04-02 17:29:02 -07:00
Matthijs Hofstra
f43e6af38d Removed libcore/mutable.rs, Mut<T> is now dead. 2013-04-02 21:15:23 +02:00
Matthijs Hofstra
ca52d08c4b Removed mut-fields from Mut, removed borrow_const from Mut 2013-04-02 20:47:29 +02:00
Steve Klabnik
948ff6056f Typo fix. u8 -> i8 2013-04-01 18:20:30 -07:00
Steve Klabnik
1d658d9b97 Improve docs for Core::ReaderUtil.
I filled out better descriptions for all of the neccesary
functions.
2013-04-01 18:03:54 -07:00
bors
78b53718a8 auto merge of #5667 : graydon/rust/remove-a-mode, r=catamorphism
It seems nobody can figure out whether this is _supposed to_ make a difference anymore, and in testing it seems to work either way, so I removed it. One less alarming warning during a fresh build.
2013-04-01 17:00:42 -07:00
Steve Klabnik
a20d1ad0cb Improve documentation for core::io. 2013-04-01 16:37:40 -07:00
Brian Anderson
243e601e51 doc: Update tutorial description of core 2013-04-01 14:30:14 -07:00
Brian Anderson
37634f3363 core: Update libc docs to clarify usage 2013-04-01 14:29:09 -07:00
Graydon Hoare
0647a0fc28 remove stray mode on callback, seems to not change anything 2013-04-01 14:18:07 -07:00
Marvin Löbel
df66e8d4a1 Fix underflow in char_range_at_reverse
Added char_range_at_reverse underflow test
2013-03-31 10:03:52 +02:00
bors
042a66514d auto merge of #5638 : luqmana/rust/5405, r=brson
#5405

Also, renames the confusingly named `use_new_rt` in `libcore/unstable/lang.rs`
2013-03-30 20:45:42 -07:00
Luqman Aden
74d20b46c5 Rename confusing var, use_new_rt -> use_old_rt. 2013-03-30 20:00:19 -07:00
Luqman Aden
eadd358b2a Correct type signature for start lang item. 2013-03-30 19:59:21 -07:00
Daniel Micay
258a36738e move dlist from core -> std
Closes #3549
2013-03-30 21:06:26 -04:00
bors
6dd20c8186 auto merge of #5630 : erickt/rust/serial, r=erickt
@nikomatsakis and I were talking about how the serializers were a bit too complicated. None of the users of With the `emit_option` and `read_option` functions, the serializers are now moving more high level. This patch series continues that trend. I've removed support for emitting specific string and vec types, and added support for emitting mapping types.
2013-03-30 15:42:43 -07:00
Niko Matsakis
6965fe4bce Add AbiSet and integrate it into the AST.
I believe this patch incorporates all expected syntax changes from extern
function reform (#3678). You can now write things like:

    extern "<abi>" fn foo(s: S) -> T { ... }
    extern "<abi>" mod { ... }
    extern "<abi>" fn(S) -> T

The ABI for foreign functions is taken from this syntax (rather than from an
annotation).  We support the full ABI specification I described on the mailing
list.  The correct ABI is chosen based on the target architecture.

Calls by pointer to C functions are not yet supported, and the Rust type of
crust fns is still *u8.
2013-03-29 18:36:20 -07:00