Commit Graph

15853 Commits

Author SHA1 Message Date
Alex Crichton
dfb5c10dea Remove unused imports throughout src/ 2013-03-04 12:27:01 -05:00
Alex Crichton
55461d888f Change the default level of unused_imports to warn 2013-03-04 12:27:01 -05:00
bors
c639a78dc4 auto merge of #5205 : thestinger/rust/radix, r=graydon
This is an implementation of a map and set for integer keys. It's an ordered container (by byte order, which is sorted order for integers and byte strings when done in the right direction) with O(1) worst-case lookup, removal and insertion. There's no rebalancing or rehashing so it's actually O(1) without amortizing any costs.

The fanout can be adjusted in multiples of 2 from 2-ary through 256-ary, but it's hardcoded at 16-ary because there isn't a way to expose that in the type system yet. To keep things simple, it also only allows `uint` keys, but later I'll expand it to all the built-in integer types and byte arrays.

There's quite a bit of room for performance improvement, along with the boost that will come with dropping the headers on `Owned` `~` and getting rid of the overhead from the stack switches to the allocator. It currently does suffix compression for a single node and then splits into two n-ary trie nodes, which could be replaced with an array for at least 4-8 suffixes before splitting it. There's also the option of doing path compression, which may be a good or a bad idea and depends a lot on the data stored.

I want to share the test suite with the other maps so that's why I haven't duplicated all of the existing integer key tests in this file. I'll send in another pull request to deal with that.

Current benchmark numbers against the other map types:

    TreeMap:
     Sequential integers:
      insert: 0.798295
      search: 0.188931
      remove: 0.435923
     Random integers:
      insert: 1.557661
      search: 0.758325
      remove: 1.720527

    LinearMap:
     Sequential integers:
      insert: 0.272338
      search: 0.141179
      remove: 0.190273
     Random integers:
      insert: 0.293588
      search: 0.162677
      remove: 0.206142

    TrieMap:
     Sequential integers:
      insert: 0.0901
      search: 0.012223
      remove: 0.084139
     Random integers:
      insert: 0.392719
      search: 0.261632
      remove: 0.470401

@graydon is using an earlier version of this for the garbage collection implementation, so that's why I added this to libcore. I left out the `next` and `prev` methods *for now* because I just wanted the essentials first.
2013-03-04 08:21:47 -08:00
Brian Anderson
edcebac1cc There is no function in LLVM called LLVMInitializeMipsAsmLexer 2013-03-03 20:02:06 -08:00
Jyun-Yan You
314605f948 rt: fix some bugs for MIPS target 2013-03-03 20:02:06 -08:00
Jyun-Yan You
c2a61d7df3 rustc: implement MIPS O32 ABI 2013-03-03 20:02:03 -08:00
Jyun-Yan You
5150b9811b rustc: MIPS32 support 2013-03-03 19:27:27 -08:00
Jyun-Yan You
0ecd9e03ff rt: MIPS32 support 2013-03-03 19:27:01 -08:00
bors
d30a4f4e67 auto merge of #5207 : erickt/rust/libsyntax-deprecated-self, r=brson
This adds an explicit `&self` to each method in libsyntax, and sets the `#[deny(deprecated_self)]` in `syntax.rc`.
2013-03-03 16:16:00 -08:00
Erick Tryzelaar
690caf8ab8 libsyntax: deny deprecated_self in libsyntax 2013-03-03 15:25:08 -08:00
Erick Tryzelaar
b9d9157883 libsyntax: add &self to extensions 2013-03-03 15:25:08 -08:00
Erick Tryzelaar
4a73426aa2 libsyntax: add &self to parser methods 2013-03-03 15:25:08 -08:00
Patrick Walton
3c23589b08 etc: Suppress another Valgrind issue. rs=burningtree 2013-03-03 10:30:00 -08:00
bors
a7de81ac3e auto merge of #5203 : erickt/rust/incoming, r=brson
My merges for #5143 missed a couple other copies. This patch corrects this, and gets stage0 to compile libsyntax with `#[deny(vecs_implicitly_copyable)]`. stage1 still fails though.
2013-03-02 20:12:36 -08:00
bors
5655ae46a7 auto merge of #5197 : pcwalton/rust/fn-types, r=pcwalton
r? @catamorphism
2013-03-02 19:18:37 -08:00
Patrick Walton
ccec510f39 librustc: Stop parsing fn@, fn~, and fn& 2013-03-02 18:47:48 -08:00
Patrick Walton
ce3b17badd librustdoc: Remove fn@, fn~, and fn& from compiletest, fuzzer, rustdoc, and rt. rs=defun 2013-03-02 18:47:47 -08:00
Patrick Walton
30bb09c0e7 test: Remove fn@, fn~, and fn& from the test suite. rs=defun 2013-03-02 18:47:47 -08:00
bors
826644e8cb auto merge of #5114 : osaut/rust/incoming, r=brson
Several typos corrected in the comments of  src/libcore/iter.rs and 2013 added to the copyright header (as requested on CONTRIBUTING.md)
2013-03-02 18:21:39 -08:00
Patrick Walton
542119f61f libcore: Remove fn@, fn~, and fn& from libcore. rs=defun 2013-03-02 16:49:32 -08:00
Patrick Walton
a38cbebd8c libstd: Remove fn@, fn~, and fn& from libstd. rs=defun 2013-03-02 16:49:31 -08:00
Patrick Walton
256afb8a10 libsyntax: Remove fn@, fn~, and fn& from libsyntax. rs=defun 2013-03-02 16:49:31 -08:00
Patrick Walton
97fd421319 librustc: Remove fn@, fn~, and fn& from librustc. rs=defun 2013-03-02 16:49:31 -08:00
Patrick Walton
a3f728238b librustc: Forbid chained imports and fix the logic for one-level renaming imports 2013-03-02 16:49:30 -08:00
bors
a14b489925 auto merge of #5199 : thestinger/rust/hashmap, r=brson
Closes #4764
2013-03-02 16:30:39 -08:00
bors
347d19934d auto merge of #5198 : youknowone/rust/repeat-count, r=brson
Before:
````
test.rs:3:21: 3:30 error: expected constant integer for repeat count but found variable
test.rs:3             let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
                              ^~~~~~~~~
````

After:
````
test.rs:3:27: 3:28 error: expected constant integer for repeat count but found variable
test.rs:3             let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
                                     ^
````
2013-03-02 15:33:39 -08:00
bors
d19cbf8da3 auto merge of #5206 : thestinger/rust/cmp, r=brson
minor little performance issue - the vector and string implementations of TotalOrd turn out badly without explicitly inlining this
2013-03-02 13:57:40 -08:00
Daniel Micay
3550233d37 inline the implementation of TotalOrd for integers 2013-03-02 16:30:42 -05:00
Daniel Micay
a4d22635e1 add an initial radix trie implementation 2013-03-02 16:29:41 -05:00
Erick Tryzelaar
4172faea84 libsyntax: add some more explicit copies for vecs_implicitly_copyable) 2013-03-02 11:17:11 -08:00
bors
afdd0b868a auto merge of #5143 : erickt/rust/incoming, r=pcwalton
Good morning,

It's taken a long time, but I finally am almost done freeing libsyntax of `vecs_implicitly_copyable` in this pull request, but I'm running into some issues. I've confirmed that all but the last commit (which only disables `vecs_implicitly_copyable` pass the `check` tests. The last commit errors with this message, which makes no sense to me:

```
/Users/erickt/rust/rust/src/libcore/num/f32.rs:35:37: 35:43 error: expected `,` but found `=`
/Users/erickt/rust/rust/src/libcore/num/f32.rs:35         pub pure fn $name($( $arg : $arg_ty ),*) -> $rv {
                                                                                       ^~~~~~
```

and this stack trace:

```
#1  0x00000001000b059b in sys::begin_unwind_::_a923ca4ae164c::_06 ()
#2  0x00000001000b0542 in sys::begin_unwind::anon::anon::expr_fn_13876 ()
#3  0x00000001000048a1 in sys::begin_unwind::_8ec273289fc0adc0::_06 ()
#4  0x00000001005df999 in diagnostic::__extensions__::meth_7941::span_fatal::_efdf2d14612d79ec::_06 ()
#5  0x0000000100682d48 in parse::parser::__extensions__::meth_16938::fatal::_8aa3239426747a3::_06 ()
#6  0x00000001006850b8 in parse::common::__extensions__::meth_17005::expect::_d3604ec6c7698d5f::_06 ()
#7  0x00000001006b59f1 in parse::common::__extensions__::parse_seq_to_before_end_17860::_48c79835f9eb1011::_06 ()
#8  0x00000001006a50f7 in parse::parser::__extensions__::meth_17606::parse_fn_decl::_14f3785fe78967d::_06 ()
#9  0x00000001006b6f59 in parse::parser::__extensions__::meth_17987::parse_item_fn::_8a6be529cf7b2ca5::_06 ()
#10 0x00000001006ac839 in parse::parser::__extensions__::meth_17761::parse_item_or_view_item::_bfead947d6dd7d25::_06 ()
#11 0x00000001006c8b8f in parse::parser::__extensions__::meth_18364::parse_item::_96b54e33f65abe76::_06 ()
#12 0x000000010076179f in ext::tt::macro_rules::add_new_extension::generic_extension::anon::anon::expr_fn_23365 ()
#13 0x000000010072e793 in ext::expand::expand_item_mac::_a4f486c4465cfb1b::_06 ()
#14 0x00000001007b5ad3 in __morestack ()
```

There also a bunch of new warnings that I haven't cleaned up yet: https://gist.github.com/erickt/5048251.

@nikomatsakis thought there might be some scary bug in the parser caused by moving a vector in the parser instead of copying it, which is why I'm filing this pull request before it's ready. Thanks for any help!
2013-03-02 08:30:41 -08:00
Erick Tryzelaar
5515fd5c8c Merge remote-tracking branch 'remotes/origin/incoming' into incoming 2013-03-02 07:12:53 -08:00
bors
2304fe6208 auto merge of #5196 : thestinger/rust/ord, r=catamorphism
This allows `TreeMap`/`TreeSet` to fully express their requirements and reduces the comparisons from ~1.5 per level to 1 which really helps for string keys.

I also added `ReverseIter` to the prelude exports because I forgot when I originally added it.
2013-03-02 05:15:39 -08:00
Daniel Micay
035233a259 treemap: reimplement using TotalOrd 2013-03-02 14:10:19 -05:00
Daniel Micay
ca1ceb15b1 add a TotalOrd trait 2013-03-02 14:10:16 -05:00
bors
5aca7d6aef auto merge of #5137 : yjh0502/rust/empty_struct, r=nikomatsakis
The fix is straight-forward, but there are several changes
while fixing the issue.

1) disallow `mut` keyword when making a new struct

In code base, there are following code,

```rust
struct Foo { mut a: int };
let a = Foo { mut a: 1 };
```

This is because of structural record, which is
deprecated corrently (see issue #3089) In structural
record, `mut` keyword should be allowd to control
mutability. But without structural record, we don't
need to allow `mut` keyword while constructing struct.

2) disallow structural records in parser level
This is related to 1). With structural records, there
is an ambiguity between empty block and empty struct
To solve the problem, I change parser to stop parsing
structural records. I think this is not a problem,
because structural records are not compiled already.

Misc. issues

There is an ambiguity between empty struct vs. empty match stmt.
with following code,

```rust
match x{} {}
```

Two interpretation is possible, which is listed blow

```rust
match (x{}) {} //  matching with newly-constructed empty struct
(match x{}) {}  //  matching with empty enum(or struct) x
                //  and then empty block
```

It seems that there is no such code in rust code base, but
there is one test which uses empty match statement:
https://github.com/mozilla/rust/blob/incoming/src/test/run-pass/issue-3037.rs

All other cases could be distinguished with look-ahead,
but this can't be. One possible solution is wrapping with
parentheses when matching with an uninhabited type.

```rust
enum what { }
fn match_with_empty(x: what) -> ~str {
    match (x) { //use parentheses to remove the ambiguity
    }
}
```
2013-03-02 04:21:38 -08:00
bors
d3b94f6f34 auto merge of #5193 : sethpink/rust/struct-tup-pp, r=catamorphism
- Removed space between struct name and parentheses
- Fixed indentation of the rest of the file (missing end)
- Don't print parentheses for structs with no fields
- Added test
2013-03-02 03:06:38 -08:00
bors
2f901126d4 auto merge of #5191 : brson/rust/movert, r=brson
Moving them out of the way so the new scheduler code can occupy core::rt.
2013-03-02 02:09:38 -08:00
Daniel Micay
a4175c34c3 make LinearMap fields private
Closes #4764
2013-03-02 05:09:36 -05:00
bors
10faa521ae auto merge of #5188 : ben0x539/rust/doc-call-generic-fn, r=catamorphism
I have seen a few people confused on how to explicitly instantiate generic functions, since the syntax differs from C++'s and C#'s, which is probably where most people asking questions about generic functions are coming from. The only use of the `::<T>` syntax in the reference right now is in the section on paths, which is possibly not where someone trying to find out about generic functions is going to start looking. The tutorial doesn't mention it at all, but I think it's all right to make the reference a tiny bit more redundant and avoid stuffing the tutorial with syntax details.

----

The "Generic functions" subsection mentions that generic functions are instantiated based on context, so let's also mention right away (with a link to the #paths section) that an explicit form is available.

This also adds an example that explicitly instantiates a generic function to the function call expression section.
2013-03-02 01:00:41 -08:00
Jeong YunWon
b662d3c922 Better highlight for repeat count error
Before:
````
test.rs:3:21: 3:30 error: expected constant integer for repeat count but found variable
test.rs:3             let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
                              ^~~~~~~~~
````

After:
````
test.rs:3:27: 3:28 error: expected constant integer for repeat count but found variable
test.rs:3             let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
                                     ^
````
2013-03-02 17:44:35 +09:00
bors
0917e131d5 auto merge of #5187 : ben0x539/rust/docs-unit-struct, r=catamorphism
This adds a few words about unit-like struct types (`struct Foo;`) in the sections for `struct` items, structure expressions and structure types (and fixes an adjacent typo or two). The added text is at the same time triply redundant because of how the sections are split and rather brief because I don't think there's that much to say about field-less structs without digressing into `impl`s and generic functions and whatnot, but it's probably better than nothing for a start.

The added arm for the grammar of struct expressions is really awkward. It's just

    | expr_path

which is clearly not unambiguously a struct expression, but it didn't feel right not to add anything to the grammar chunk (and I can't tell whether the arm for enum-like structs is somehow unambiguous with regular enum expressions, either). Is this okay?
2013-03-02 00:06:41 -08:00
bors
3f91f32938 auto merge of #5186 : ben0x539/rust/contributing, r=brson
I'm wary of editing the offical-looking things like the contribution policy, but I hope fixing typos/the sentence structure is okay.
2013-03-01 23:18:40 -08:00
bors
36e898962d auto merge of #5185 : ben0x539/rust/net-tcp-docs, r=brson
This changes various type_names to TypeNames and fixes the example for `tcp::accept` that was still using the old `match` syntax and `{|args| ...}` closures.

The `accept` example was fairly outdated. I was just going to stay away from all the IO things until the scheduler revamp lands, but `accept` is probably one of the obvious starting points for networking stuff for a learner, and I don't want to get in the way of anyone's enthusiasm.

Doesn't touch non-comment lines, so I hope I will get away without learning about unit tests. It doesn't seem like the test system is set up to extract tests from doc comments right now.
2013-03-01 20:51:40 -08:00
Erick Tryzelaar
aa3505d8ff Merge remote-tracking branch 'remotes/origin/incoming' into incoming 2013-03-01 20:35:55 -08:00
Jihyun Yu
95bc9ea26d Remove REC, change related tests/docs 2013-03-02 12:57:05 +09:00
bors
10929ed1ca auto merge of #5165 : brson/rust/unstable, r=brson
r?

This probably isn't controversial, but I want somebody else to sign off on it.
2013-03-01 19:45:41 -08:00
Seth Pink
dcd2f73560 Fix some struct-tuple def prettyprint issues
- Removed space between struct name and parentheses
- Fixed indentation of the rest of the file (missing end)
- Don't print parentheses for structs with no fields
- Added test
2013-03-02 13:32:40 +10:00
bors
0fd1b58f23 auto merge of #5190 : brson/rust/snap, r=brson 2013-03-01 18:15:41 -08:00
Patrick Walton
657c442eca Merge remote branch 'nmatsakis/parser-perf-problem' into incoming 2013-03-01 18:09:27 -08:00