Commit Graph

27100 Commits

Author SHA1 Message Date
bors
05975a4928 auto merge of #12849 : nick29581/rust/doubles, r=alexcrichton 2014-03-13 07:11:41 -07:00
bors
50fb2a4f1f auto merge of #12610 : eddyb/rust/deref-now-auto, r=nikomatsakis
Enables the dereference overloads introduced by #12491 to be applied wherever automatic dereferences would be used (field accesses, method calls and indexing).
2014-03-13 05:51:40 -07:00
Niko Matsakis
01a15d5870 Tweak comments 2014-03-13 14:21:46 +02:00
Niko Matsakis
a7db0d5d30 compile-fail: Beef up borrowck test to include some scenarios where we borrow mutably twice in a row 2014-03-13 14:21:46 +02:00
Eduard Burtescu
27c62449db Region + borrow checker support and tests for overloaded autoderef. 2014-03-13 14:21:46 +02:00
Eduard Burtescu
feedd37653 Apply @nikomatsakis' nits and comments patch. 2014-03-13 14:21:45 +02:00
Eduard Burtescu
26398b4f6d Introduce a common recursion limit for auto-dereference and monomorphization. 2014-03-13 14:21:45 +02:00
Eduard Burtescu
20b4e159ed Implement automatic overloaded dereference.
Closes #7141.
2014-03-13 14:21:45 +02:00
Eduard Burtescu
cdc18b96d6 Remove Rc's borrow method to avoid conflicts with RefCell's borrow in Rc<RefCell<T>>. 2014-03-13 14:21:45 +02:00
bors
2c8bce1c76 auto merge of #12845 : eddyb/rust/vec-no-drop-flag, r=thestinger 2014-03-13 04:36:36 -07:00
bors
12b2607572 auto merge of #12602 : alexcrichton/rust/backtrace, r=brson
Whenever a failure happens, if a program is run with
`RUST_LOG=std::rt::backtrace` a backtrace will be printed to the task's stderr
handle. Stack traces are uncondtionally printed on double-failure and
rtabort!().

This ended up having a nontrivial implementation, and here's some highlights of
it:

* We're bundling libbacktrace for everything but OSX and Windows
* We use libgcc_s and its libunwind apis to get a backtrace of instruction
  pointers
* On OSX we use dladdr() to go from an instruction pointer to a symbol
* On unix that isn't OSX, we use libbacktrace to get symbols
* Windows, as usual, has an entirely separate implementation

Lots more fun details and comments can be found in the source itself.

Closes #10128
2014-03-13 01:11:39 -07:00
Alex Crichton
829df69f9f Add basic backtrace functionality
Whenever a failure happens, if a program is run with
`RUST_LOG=std::rt::backtrace` a backtrace will be printed to the task's stderr
handle. Stack traces are uncondtionally printed on double-failure and
rtabort!().

This ended up having a nontrivial implementation, and here's some highlights of
it:

* We're bundling libbacktrace for everything but OSX and Windows
* We use libgcc_s and its libunwind apis to get a backtrace of instruction
  pointers
* On OSX we use dladdr() to go from an instruction pointer to a symbol
* On unix that isn't OSX, we use libbacktrace to get symbols
* Windows, as usual, has an entirely separate implementation

Lots more fun details and comments can be found in the source itself.

Closes #10128
2014-03-13 00:24:20 -07:00
bors
6cbba7c54e auto merge of #12414 : DaGenix/rust/failing-iterator-wrappers, r=alexcrichton
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults.
    
Fixes #12368
2014-03-12 23:51:40 -07:00
bors
792da8424f auto merge of #12823 : alexcrichton/rust/issue-12666, r=pcwalton
If a TTY fails to get initialized, it still needs to have uv_close invoked on
it. This fixes the problem by constructing the TtyWatcher struct before the call
to uv_tty_init. The struct has a destructor on it which will close the handle
properly.

Closes #12666
2014-03-12 22:36:40 -07:00
bors
e86e1d88b2 auto merge of #12822 : erickt/rust/cleanup, r=acrichto
This PR makes `std::io::FileStat` hashable, and `Path` serializable as a byte array.
2014-03-12 21:21:44 -07:00
Palmer Cox
9ba6bb5a71 Update io iterators to produce IoResults
Most IO related functions return an IoResult so that the caller can handle failure
in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all
supress errors. This means that code that needs to handle errors can't use any of these
iterators. All three of these iterators were updated to produce IoResults.

Fixes #12368
2014-03-12 22:42:50 -04:00
bors
a53242a1a3 auto merge of #12756 : pongad/rust/remove_owned_str_pat, r=alexcrichton
match-drop-strs-issue-4541.rs deleted as it's the same with issue-4541.rs
2014-03-12 19:21:44 -07:00
Erick Tryzelaar
62026fd6b6 syntax: change the #[deriving(Hash)] typaram variable name 2014-03-12 18:58:54 -07:00
Erick Tryzelaar
d2cfd543f7 serialize: make Paths serializable 2014-03-12 18:58:54 -07:00
Erick Tryzelaar
be12c9f753 std: allow io::File* structs to be hashable 2014-03-12 18:58:54 -07:00
bors
2eebeb8137 auto merge of #12081 : cgaebel/rust/robinhood-hashing, r=alexcrichton
Partially addresses #11783.

Previously, rust's hashtable was totally unoptimized. It used an Option
per key-value pair, and used very naive open allocation.

The old hashtable had very high variance in lookup time. For an example,
see the 'find_nonexisting' benchmark below. This is fixed by keys in
'lucky' spots with a low probe sequence length getting their good spots
stolen by keys with long probe sequence lengths. This reduces hashtable
probe length variance, while maintaining the same mean.

Also, other optimization liberties were taken. Everything is as cache
aware as possible, and this hashtable should perform extremely well for
both large and small keys and values.

Benchmarks:

```
comprehensive_old_hashmap         378 ns/iter (+/- 8)
comprehensive_new_hashmap         206 ns/iter (+/- 4)
1.8x faster

old_hashmap_as_queue              238 ns/iter (+/- 8)
new_hashmap_as_queue              119 ns/iter (+/- 2)
2x faster

old_hashmap_insert                172 ns/iter (+/- 8)
new_hashmap_insert                146 ns/iter (+/- 11)
1.17x faster

old_hashmap_find_existing         50 ns/iter (+/- 12)
new_hashmap_find_existing         35 ns/iter (+/- 6)
1.43x faster

old_hashmap_find_notexisting      49 ns/iter (+/- 49)
new_hashmap_find_notexisting      34 ns/iter (+/- 4)
1.44x faster

Memory usage of old hashtable (64-bit assumed):

aligned(8+sizeof(Option)+sizeof(K)+sizeof(V))/0.75 + 48ish bytes

Memory usage of new hashtable:

(aligned(sizeof(K))
+ aligned(sizeof(V))
+ 8)/0.9 + 112ish bytes

Timing of building librustc:

compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc
time: 0.457 s   parsing
time: 0.028 s   gated feature checking
time: 0.000 s   crate injection
time: 0.108 s   configuration 1
time: 1.049 s   expansion
time: 0.219 s   configuration 2
time: 0.222 s   maybe building test harness
time: 0.223 s   prelude injection
time: 0.268 s   assinging node ids and indexing ast
time: 0.075 s   external crate/lib resolution
time: 0.026 s   language item collection
time: 1.016 s   resolution
time: 0.038 s   lifetime resolution
time: 0.000 s   looking for entry point
time: 0.030 s   looking for macro registrar
time: 0.061 s   freevar finding
time: 0.138 s   region resolution
time: 0.110 s   type collecting
time: 0.072 s   variance inference
time: 0.126 s   coherence checking
time: 9.110 s   type checking
time: 0.186 s   const marking
time: 0.049 s   const checking
time: 0.418 s   privacy checking
time: 0.057 s   effect checking
time: 0.033 s   loop checking
time: 1.293 s   compute moves
time: 0.182 s   match checking
time: 0.242 s   liveness checking
time: 0.866 s   borrow checking
time: 0.150 s   kind checking
time: 0.013 s   reachability checking
time: 0.175 s   death checking
time: 0.461 s   lint checking
time: 13.112 s  translation
  time: 4.352 s llvm function passes
  time: 96.702 s    llvm module passes
  time: 50.574 s    codegen passes
time: 154.611 s LLVM passes
  time: 2.821 s running linker
time: 15.750 s  linking


compile_and_link: x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc
time: 0.422 s   parsing
time: 0.031 s   gated feature checking
time: 0.000 s   crate injection
time: 0.126 s   configuration 1
time: 1.014 s   expansion
time: 0.251 s   configuration 2
time: 0.249 s   maybe building test harness
time: 0.273 s   prelude injection
time: 0.279 s   assinging node ids and indexing ast
time: 0.076 s   external crate/lib resolution
time: 0.033 s   language item collection
time: 1.028 s   resolution
time: 0.036 s   lifetime resolution
time: 0.000 s   looking for entry point
time: 0.029 s   looking for macro registrar
time: 0.063 s   freevar finding
time: 0.133 s   region resolution
time: 0.111 s   type collecting
time: 0.077 s   variance inference
time: 0.565 s   coherence checking
time: 8.953 s   type checking
time: 0.176 s   const marking
time: 0.050 s   const checking
time: 0.401 s   privacy checking
time: 0.063 s   effect checking
time: 0.032 s   loop checking
time: 1.291 s   compute moves
time: 0.172 s   match checking
time: 0.249 s   liveness checking
time: 0.831 s   borrow checking
time: 0.121 s   kind checking
time: 0.013 s   reachability checking
time: 0.179 s   death checking
time: 0.503 s   lint checking
time: 14.385 s  translation
  time: 4.495 s llvm function passes
  time: 92.234 s    llvm module passes
  time: 51.172 s    codegen passes
time: 150.809 s LLVM passes
  time: 2.542 s running linker
time: 15.109 s  linking
```

BUT accesses are much more cache friendly. In fact, if the probe
sequence length is below 8, only two cache lines worth of hashes will be
pulled into cache. This is unlike the old version which would have to
stride over the stoerd keys and values, and would be more cache
unfriendly the bigger the stored values got.

And did you notice the higher load factor? We can now reasonably get a
load factor of 0.9 with very good performance.

Please review this very closely. This is my first major contribution to Rust. Sorry for the ugly diff!
2014-03-12 18:06:47 -07:00
Alex Crichton
65cca4bd3f rustuv: Fix a use-after-free in TTY failure
If a TTY fails to get initialized, it still needs to have uv_close invoked on
it. This fixes the problem by constructing the TtyWatcher struct before the call
to uv_tty_init. The struct has a destructor on it which will close the handle
properly.

Closes #12666
2014-03-12 17:59:14 -07:00
Michael Darakananda
f079c94f72 rustc: Remove matching on ~str from the language
The `~str` type is not long for this world as it will be superseded by the
soon-to-come DST changes for the language. The new type will be
`~Str`, and matching over the allocation will no longer be supported.
Matching on `&str` will continue to work, in both a pre and post DST world.
2014-03-12 19:17:36 -04:00
Clark Gaebel
5bdbd21009 Performance-oriented hashtable.
Previously, rust's hashtable was totally unoptimized. It used an Option
per key-value pair, and used very naive open allocation.

The old hashtable had very high variance in lookup time. For an example,
see the 'find_nonexisting' benchmark below. This is fixed by keys in
'lucky' spots with a low probe sequence length getting their good spots
stolen by keys with long probe sequence lengths. This reduces hashtable
probe length variance, while maintaining the same mean.

Also, other optimization liberties were taken. Everything is as cache
aware as possible, and this hashtable should perform extremely well for
both large and small keys and values.

Benchmarks:

comprehensive_old_hashmap         378 ns/iter (+/- 8)
comprehensive_new_hashmap         206 ns/iter (+/- 4)
1.8x faster

old_hashmap_as_queue              238 ns/iter (+/- 8)
new_hashmap_as_queue              119 ns/iter (+/- 2)
2x faster

old_hashmap_insert                172 ns/iter (+/- 8)
new_hashmap_insert                146 ns/iter (+/- 11)
1.17x faster

old_hashmap_find_existing         50 ns/iter (+/- 12)
new_hashmap_find_existing         35 ns/iter (+/- 6)
1.43x faster

old_hashmap_find_notexisting      49 ns/iter (+/- 49)
new_hashmap_find_notexisting      34 ns/iter (+/- 4)
1.44x faster

Memory usage of old hashtable (64-bit assumed):

aligned(8+sizeof(K)+sizeof(V))/0.75 + 6 words

Memory usage of new hashtable:

(aligned(sizeof(K))
+ aligned(sizeof(V))
+ 8)/0.9 + 6.5 words

BUT accesses are much more cache friendly. In fact, if the probe
sequence length is below 8, only two cache lines worth of hashes will be
pulled into cache. This is unlike the old version which would have to
stride over the stoerd keys and values, and would be more cache
unfriendly the bigger the stored values got.

And did you notice the higher load factor? We can now reasonably get a
load factor of 0.9 with very good performance.
2014-03-12 18:30:11 -04:00
bors
4d64441bcb auto merge of #12848 : alexcrichton/rust/rollup, r=alexcrichton 2014-03-12 15:07:06 -07:00
Alex Crichton
3f2434eee3 Test fixes from rolling up PRs
Closes #12803 (std: Relax an assertion in oneshot selection) r=brson
Closes #12818 (green: Fix a scheduler assertion on yielding) r=brson
Closes #12819 (doc: discuss try! in std::io) r=alexcrichton
Closes #12820 (Use generic impls for `Hash`) r=alexcrichton
Closes #12826 (Remove remaining nolink usages) r=alexcrichton
Closes #12835 (Emacs: always jump the cursor if needed on indent) r=brson
Closes #12838 (Json method cleanup) r=alexcrichton
Closes #12843 (rustdoc: whitelist the headers that get a § on hover) r=alexcrichton
Closes #12844 (docs: add two unlisted libraries to the index page) r=pnkfelix
Closes #12846 (Added a test that checks that unary structs can be mutably borrowed) r=sfackler
Closes #12847 (mk: Fix warnings about duplicated rules) r=nmatsakis
2014-03-12 15:01:27 -07:00
Alex Crichton
1a7e55f4f5 mk: Fix warnings about duplicated rules
The footer.tex rule didn't depend on $(1) of the macro it was being defined in,
so it was getting duplicated, causing many warnings.
2014-03-12 15:01:25 -07:00
Dmitry Promsky
167bfaf234 Added a test that checks that unary structs can be mutably borrowed.
Closes #11267
2014-03-12 15:01:25 -07:00
Huon Wilson
f9ecedbc75 docs: add two unlisted libraries to the index page. 2014-03-12 15:01:25 -07:00
Huon Wilson
e1e4816e16 rustdoc: whitelist the headers that get a § on hover.
Previously the :hover rules were making the links to the traits/types in
something like

    impl<K: Hash + Eq, V> ... { ... }

be displayed with a trailing `§` when hovered over. This commit
restricts that behaviour to specific headers, i.e. those that are known
to be section headers (like those rendered in markdown doc-comments, and
the "Modules", "Functions" etc. headings).
2014-03-12 15:01:25 -07:00
zslayton
0bfb61ed9d Closes #12829. Names changed for consistency, find_path optimized, method impls refactored to reduce repitition.
Fixed formatting, reworked find_path to use fewer Options.

Removed stray tab.
2014-03-12 15:01:25 -07:00
Micah Chalmer
d28d5b7fb4 Emacs: always jump the cursor if needed on indent
The rust-mode-indent-line function had a check, which ran after all the
calculations for how to indent had already happened, that skipped
actually performing the indent if the line was already at the right
indentation.

Because of that, the cursor did not jump to the indentation if the line
wasn't changing.  This was particularly annoying if there was nothing
but spaces on the line and you were at the beginning of it--it looked
like the indent just wasn't working.

This removes the check and adds test cases to cover this.
2014-03-12 15:01:25 -07:00
lpy
aac6e31763 Remove remaining nolink usages.(fixes #12810) 2014-03-12 15:01:25 -07:00
Erick Tryzelaar
9959188d0e Use generic impls for Hash 2014-03-12 13:39:47 -07:00
Peter Marheine
207ebf13f1 doc: discuss try! in std::io 2014-03-12 13:39:47 -07:00
Alex Crichton
91bed14ca8 green: Fix a scheduler assertion on yielding
This commit fixes a small bug in the green scheduler where a scheduler task
calling `maybe_yield` would trip the assertion that `self.yield_check_count > 0`

This behavior was seen when a scheduler task was scheduled many times
successively, sending messages in a loop (via the channel `send` method), which
in turn invokes `maybe_yield`. Yielding on a sched task doesn't make sense
because as soon as it's done it will implicitly do a yield, and for this reason
the yield check is just skipped if it's a sched task.

I am unable to create a reliable test for this behavior, as there's no direct
way to have control over the scheduler tasks.

cc #12666, I discovered this when investigating that issue
2014-03-12 13:39:47 -07:00
Alex Crichton
80f92f5c5f std: Relax an assertion in oneshot selection
The assertion was erroneously ensuring that there was no data on the port when
the port had selection aborted on it. This assertion was written in error
because it's possible for data to be waiting on a port, even after it was
disconnected. When aborting selection, if we see that there's data on the port,
then we return true that data is available on the port.

Closes #12802
2014-03-12 13:39:47 -07:00
Nick Cameron
0d80de0dfa Update last_span in replace_token 2014-03-12 13:12:01 -07:00
Eduard Burtescu
500bade87e Vec: remove the drop flag to make it no larger than (*T, uint, uint). 2014-03-12 22:01:33 +02:00
bors
3316a0e6b2 auto merge of #12797 : pczarn/rust/str_safety, r=huonw
Along the lines of `shift_ref` and `pop_ref`.
2014-03-12 12:12:05 -07:00
bors
18356675e5 auto merge of #12816 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton
Fixes #12811 as described in the issue.
2014-03-12 07:42:03 -07:00
bors
c2e5135358 auto merge of #12807 : pnkfelix/rust/fsk-issue5121-fns-with-early-lifetime-params, r=pnkfelix
Fix issue #5121: Add proper support for early/late distinction for lifetime bindings.

There are some little refactoring cleanups as separate commits; the real meat that has the actual fix is in the final commit.

The original author of the work was @nikomatsakis; I have reviewed it, revised it slightly, refactored it into these separate commits, and done some rebasing work.
2014-03-12 06:27:03 -07:00
bors
397abb7242 auto merge of #12839 : alexcrichton/rust/fix-snap, r=huonw
This test is blocking a snapshot. Apparently the snapshot bot doesn't print
'limited-debuginfo::main()' but rather just 'main()'. Who knew?
2014-03-12 00:32:03 -07:00
Felix S. Klock II
742e458102 Add proper support for early/late distinction for lifetime bindings.
Uses newly added Vec::partition method to simplify resolve_lifetime.
2014-03-12 08:05:28 +01:00
Felix S. Klock II
586b619c76 Changed lists of lifetimes in ast and ty to use Vec instead of OptVec.
There is a broader revision (that does this across the board) pending
in #12675, but that is awaiting the arrival of more data (to decide
whether to keep OptVec alive by using a non-Vec internally).

For this code, the representation of lifetime lists needs to be the
same in both ScopeChain and in the ast and ty structures.  So it
seemed cleanest to just use `vec_ng::Vec`, now that it has a cheaper
empty representation than the current `vec` code.
2014-03-12 08:05:20 +01:00
Felix S. Klock II
28ebec5160 Introduce Scope<'a> shorthand for &'a ScopeChain<'a>. 2014-03-12 08:02:38 +01:00
Felix S. Klock II
189c0085d1 alpha-rename .ident to .name in Lifetime, including in rustdoc. 2014-03-12 08:02:32 +01:00
Alex Crichton
486a25a30f test: Relax a debuginfo test
This test is blocking a snapshot. Apparently the snapshot bot doesn't print
'limited-debuginfo::main()' but rather just 'main()'. Who knew?
2014-03-11 23:59:56 -07:00
Felix S. Klock II
460ca4f037 Alpha-rename .ident fields of type Name to .name. 2014-03-12 07:51:49 +01:00
Felix S. Klock II
da19563dbc Port partition method from ~[T] to Vec<T>, for use early-late lifetime code. 2014-03-12 07:51:49 +01:00