Commit Graph

26708 Commits

Author SHA1 Message Date
bors
68129d299b auto merge of #12061 : pongad/rust/delorderable, r=cmr
#12057
2014-02-13 19:16:59 -08:00
Michael Darakananda
bf1464c413 Removed num::Orderable 2014-02-13 20:12:59 -05:00
bors
89b1686bd7 auto merge of #12017 : FlaPer87/rust/replace-mod-crate, r=alexcrichton
The first setp for #9880 is to add a new `crate` keyword. This PR does exactly that. I took a chance to refactor `parse_item_foreign_mod` and I broke it down into 2 separate methods to isolate each feature.

The next step will be to push a new stage0 snapshot and then get rid of all `extern mod` around the code.
2014-02-13 16:32:01 -08:00
bors
94d453e459 auto merge of #12248 : alexcrichton/rust/rollup, r=alexcrichton
This passed `make check` locally, so hopefully it passes on bors!
2014-02-13 15:17:21 -08:00
Luqman Aden
ffdda22aa2 mk: Fix non-android cross builds. 2014-02-13 18:11:23 -05:00
Alex Crichton
640b22852f Rebase conflicts from this giant stack of patches
List of PRs contained in this rollup:

Closes #12167 r=alexcrichton
Closes #12200 r=alexcrichton
Closes #12206 r=pcwalton
Closes #12209 r=huonw
Closes #12211 r=pcwalton
Closes #12217 r=brson
Closes #12218 r=alexcrichton
Closes #12220 r=alexcrichton
Closes #12222 r=kballard
Closes #12225 r=alexcrichton
Closes #12227 r=kballard
Closes #12237 r=alexcrichton
Closes #12240 r=kballard
2014-02-13 13:33:46 -08:00
Alex Crichton
76c313ceb1 Lift $dst outside the closure in write!
If you were writing to something along the lines of `self.foo` then with the new
closure rules it meant that you were borrowing `self` for the entirety of the
closure, meaning that you couldn't format other fields of `self` at the same
time as writing to a buffer contained in `self`.

By lifting the borrow outside of the closure the borrow checker can better
understand that you're only borrowing one of the fields at a time. This had to
use type ascription as well in order to preserve trait object coercions.
2014-02-13 13:05:48 -08:00
JeremyLetang
60bc76fb78 remove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset) 2014-02-13 12:54:17 -08:00
Alex Crichton
1c5295c0bf Register new snapshots 2014-02-13 12:54:17 -08:00
Huon Wilson
44e6883d14 mk: make NO_REBUILD more forceful and more general.
Previously crates like `green` and `native` would still depend on their
parents when running `make check-stage2-green NO_REBUILD=1`, this
ensures that they only depend on their source files.

Also, apply NO_REBUILD to the crate doc tests, so, for example,
`check-stage2-doc-std` will use an already compiled `rustdoc` directly.
2014-02-13 12:54:01 -08:00
Alex Crichton
065e121fc2 Relax an assertion in start_selection()
It asserted that the previous count was always nonnegative, but DISCONNECTED is
a valid value for it to see. In order to continue to remember to store
DISCONNECTED after DISCONNECTED was seen, I also added a helper method.

Closes #12226
2014-02-13 12:54:01 -08:00
Huon Wilson
411a01feb3 std::comm: replace Handle.id with a method.
The `id` shouldn't be changed by external code, and exposing it publicly
allows to be accidentally changed.

Also, remove the first element special case in the `select!` macro.
2014-02-13 12:54:01 -08:00
Tobias Bucher
866d6cc33d Add documentation for conditional-compilation
This documents in-source conditions using #[cfg(...)] and configurations
pre-defined by the compiler.

Fix #7962.
2014-02-13 12:54:01 -08:00
Brendan Zabarauskas
957fcb3f54 Add some missing Show implementations in libstd 2014-02-13 12:54:01 -08:00
Liigo Zhuang
8a5b938b3b Move base64 and hex from libextra to libserialize 2014-02-13 12:50:25 -08:00
Felix S. Klock II
7dc187afd8 Remove a source of O(n^2) running time in bigints.
::num::bigint, Remove a source of O(n^2) running time in `fn shr_bits`.

I'll cut to the chase: On my laptop, this brings the running time on
`pidigits 2000` (from src/test/bench/shootout-pidigits.rs) from this:
```
% time ./pidigits 2000 > /dev/null

real	0m7.695s
user	0m7.690s
sys	0m0.005s
```
to this:
```
% time ./pidigits 2000 > /dev/null

real	0m0.322s
user	0m0.318s
sys	0m0.004s
```

The previous code was building up a vector by repeatedly making a
fresh copy for each element that was unshifted onto the front,
yielding quadratic running time.  This fixes that by building up the
vector in reverse order (pushing elements onto the end) and then
reversing it.

(Another option would be to build up a zero-initialized vector of the
desired length and then installing all of the shifted result elements
into their target index, but this was easier to hack up quickly, and
yields the desired asymptotic improvement.  I have been thinking of
adding a `vec::from_fn_rev` to handle this case, maybe I will try that
this weekend.)
2014-02-13 12:50:25 -08:00
Seo Sanghyeon
606c23a789 Resolve type variables when checking casting to char 2014-02-13 12:50:25 -08:00
Alex Crichton
745aa7482a Include compiler-rt in the distribution tarballs 2014-02-13 12:50:25 -08:00
Steven Fackler
6b429d07c9 Stop unloading syntax libraries
Externally loaded libraries are able to do things that cause references
to them to survive past the expansion phase (e.g. creating @-box cycles,
launching a task or storing something in task local data). As such, the
library has to stay loaded for the lifetime of the process.
2014-02-13 12:50:24 -08:00
Flavio Percoco
5deb3c9ca0 Remove obsolete warnings for extern mod
This patch gets rid of ObsoleteExternModAttributesInParens and
ObsoleteNamedExternModule since the replacement of `extern mod` with
`extern crate` avoids those cases and raises different errors. Both have
been around for at least a version which makes this a good moment to get
rid of them.
2014-02-13 20:52:17 +01:00
Flavio Percoco
9a6d92c1d7 Replace extern mod with extern crate
This patch adds a new keyword `crate` which is intended to replace mod
in the context of `extern mod` as part of the issue #9880. The patch
doesn't replace all `extern mod` cases since it is necessary to first
push a new snapshot 0.

The implementation could've been less invasive than this. However I
preferred to take this chance to split the `parse_item_foreign_mod`
method and pull the `extern crate` part out of there, hence the new
method `parse_item_foreign_crate`.
2014-02-13 20:52:16 +01:00
Flavio Percoco
968633b60a Replace crate usage with krate
This patch replaces all `crate` usage with `krate` before introducing the
new keyword. This ensures that after introducing the keyword, there
won't be any compilation errors.

krate might not be the most expressive substitution for crate but it's a
very close abbreviation for it. `module` was already used in several
places already.
2014-02-13 20:52:07 +01:00
bors
cfb87f10ec auto merge of #12210 : zr40/rust/patch-1, r=cmr
According to kimundi on IRC, the current term for `()` is 'unit'. This commit updates tutorial.md to change 'nil' to 'unit' where `()` is described.
2014-02-13 10:32:18 -08:00
Yehuda Katz
4667c492b5 Adds support for working with URL Paths
It is sometimes useful to parse just the path portion of a URL (path,
query string and fragment) rather than the entire URL.
2014-02-12 21:28:58 -08:00
bors
58eeb07c2a auto merge of #12165 : fhahn/rust/change-some-tests, r=alexcrichton
While working on #11363 I stumbled over a couple of ignored tests, that seem to be fixed or invalid.

* src/test/run-pass/issue-3559.rs was fixed in #4726
* src/test/compile-fail/borrowck-call-sendfn.rs was fixed in #2978
* update src/test/compile-fail/issue-5500-1.rs to work with current Rust (I'm not 100% sure if the original condition is tested as mentioned in #5500, but I think so)
* removed src/test/compile-fail/issue-5500.rs because it is tested in
    src/test/run-fail/issue-5500.rs (they are the same test cases, I just renamed src/test/run-fail/addr-of-bot.rs to be consistent with the other issue name
2014-02-12 14:51:48 -08:00
bors
c62f6cef6f auto merge of #12216 : alexcrichton/rust/another-snap-fix, r=brson
Hurray more snapshot blockers!
2014-02-12 11:51:49 -08:00
Alex Crichton
064281c1ee Ignore another fourcc test on cross compiles 2014-02-12 11:24:34 -08:00
Florian Hahn
195d8fdc4f Reenable some ignored test cases
* src/test/run-pass/issue-3559.rs was fixed in #4726
* src/test/compile-fail/borrowck-call-sendfn.rs was fixed in #2978
* update src/test/compile-fail/issue-5500-1.rs to work with current Rust
* removed src/test/compile-fail/issue-5500.rs because it is tested in
    src/test/run-fail/issue-5500.rs
* src/test/compile-fail/view-items-at-top.rs fixed
* #897 fixed
* compile-fail/issue-6762.rs issue was closed as dup of #6801
* deleted compile-fail/issue-2074.rs because it became irelevant and is
  irrelevant #2074, a test covering this was added in
  4f92f452bd
2014-02-12 20:23:45 +01:00
Alex Crichton
2650b61505 Don't hit epoll unless a scheduler absolutely must
Currently, a scheduler will hit epoll() or kqueue() at the end of *every task*.
The reason is that the scheduler will context switch back to the scheduler task,
terminate the previous task, and then return from run_sched_once. In doing so,
the scheduler will poll for any active I/O.

This shows up painfully in benchmarks that have no I/O at all. For example, this
benchmark:

    for _ in range(0, 1000000) {
        spawn(proc() {});
    }

In this benchmark, the scheduler is currently wasting a good chunk of its time
hitting epoll() when there's always active work to be done (run with
RUST_THREADS=1).

This patch uses the previous two commits to alter the scheduler's behavior to
only return from run_sched_once if no work could be found when trying really
really hard. If there is active I/O, this commit will perform the same as
before, falling back to epoll() to check for I/O completion (to not starve I/O
tasks).

In the benchmark above, I got the following numbers:

    12.554s on today's master
    3.861s  with #12172 applied
    2.261s  with both this and #12172 applied

cc #8341
2014-02-12 09:46:31 -08:00
Alex Crichton
4256d24a16 Percolate the (Scheduler, GreenTask) pair upwards
This is in preparation for running do_work in a loop while there are no active
I/O handles. This changes the do_work and interpret_message_queue methods to
return a triple where the last element is a boolean flag as to whether work was
done or not.

This commit preserves the same behavior as before, it simply re-structures the
code in preparation for future work.
2014-02-12 09:46:31 -08:00
Alex Crichton
cc34dbb840 Expose whether event loops have active I/O
The green scheduler can optimize its runtime based on this by deciding to not go
to sleep in epoll() if there is no active I/O and there is a task to be stolen.

This is implemented for librustuv by keeping a count of the number of tasks
which are currently homed. If a task is homed, and then performs a blocking I/O
operation, the count will be nonzero while the task is blocked. The homing count
is intentionally 0 when there are I/O handles, but no handles currently blocked.
The reason for this is that epoll() would only be used to wake up the scheduler
anyway.

The crux of this change was to have a `HomingMissile` contain a mutable borrowed
reference back to the `HomeHandle`. The rest of the change was just dealing with
this fallout. This reference is used to decrement the homed handle count in a
HomingMissile's destructor.

Also note that the count maintained is not atomic because all of its
increments/decrements/reads are all on the same I/O thread.
2014-02-12 09:46:31 -08:00
bors
1d5c52d8a1 auto merge of #12204 : alexcrichton/rust/seek, r=pcwalton
This adopts the rules posted in #10432:

1. If a seek position is negative, then an error is generated
2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap
   with data and future reads will return errors.
3. Seeks within the bounds of a file are fine.

Closes #10432
2014-02-12 08:11:46 -08:00
bors
d394a48e73 auto merge of #12196 : dguenther/rust/fix-fourcc-example, r=alexcrichton
Cleans up a few issues with `fourcc`:
* Corrects the endianness in the docs example
* Removes `#[cfg(not(test))]` (bors might not build this on Windows. If the build fails, I'll re-add it)
* Adds a FIXME referencing the LLVM assert issue we encountered with bors builds on Windows (Same error as #10872)
2014-02-12 06:21:44 -08:00
bors
fb12aebbd8 auto merge of #12180 : eddyb/rust/rm-ty_type, r=nikomatsakis 2014-02-12 04:36:43 -08:00
Eduard Burtescu
54760b9f27 Removed ty_type (previously used to represent *tydesc). 2014-02-12 14:17:06 +02:00
Matthijs van der Vleuten
4f72c018ce doc: rename 'nil' to 'unit' when describing () 2014-02-12 13:11:12 +01:00
bors
e192cd97e7 auto merge of #12194 : WebeWizard/rust/master, r=cmr 2014-02-12 03:21:44 -08:00
bors
2ca02eae1c auto merge of #12190 : alexcrichton/rust/fix-snap-again, r=brson
Loadable syntax extensions don't work when cross compiling (see #12102), so the
fourcc tests all need to be ignored. They're valuable tests, so they shouldn't
be outright ignored, so they're now flagged with ignore-cross-compile
2014-02-12 01:36:45 -08:00
bors
975908dd58 auto merge of #12185 : nikomatsakis/rust/issue-12033-tweak-test, r=alexchrichton 2014-02-11 23:06:44 -08:00
bors
db264b4a70 auto merge of #12184 : JeremyLetang/rust/rustpkg-link, r=alexcrichton 2014-02-11 21:51:46 -08:00
Alex Crichton
1b6a1e98a8 Finalize the Seek API
This adopts the rules posted in #10432:

1. If a seek position is negative, then an error is generated
2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap
   with data and future reads will return errors.
3. Seeks within the bounds of a file are fine.

Closes #10432
2014-02-11 20:18:34 -08:00
bors
11bc14d724 auto merge of #11578 : alexcrichton/rust/chan-changes, r=brson
The user-facing API-level change of this commit is that `SharedChan` is gone and `Chan` now has `clone`. The major parts of this patch are the internals which have changed.

Channels are now internally upgraded from oneshots to streams to shared channels depending on the use case. I've noticed a 3x improvement in the oneshot case and very little slowdown (if any) in the stream/shared case.

This patch is mostly a reorganization of the `std::comm` module, and the large increase in code is from either dispatching to one of 3 impls or the duplication between the stream/shared impl (because they're not entirely separate).

The `comm` module is now divided into `oneshot`, `stream`, `shared`, and `select` modules. Each module contains the implementation for that flavor of channel (or the select implementation for select).

Some notable parts of this patch

* Upgrades are done through a semi-ad-hoc scheme for oneshots and messages for streams
* Upgrades are processed ASAP and have some interesting interactions with select
* send_deferred is gone because I expect the mutex to land before this
* Some of stream/shared is straight-up duplicated, but I like having the distinction between the two modules
* Select got a little worse, but it's still "basically limping along"
* This lumps in the patch of deallocating the queue backlog on packet drop
* I'll rebase this on top of the "more errors from try_recv" patch once it lands (all the infrastructure is here already)

All in all, this shouldn't be merged until the new mutexes are merged (because send_deferred wasn't implemented).

Closes #11351
2014-02-11 20:16:47 -08:00
Alex Crichton
e633249b31 Test fixes and rebase conflicts 2014-02-11 19:58:44 -08:00
bors
db8a580fb4 auto merge of #12027 : vadimcn/rust/compiler-rt, r=alexcrichton
This is an attempt to remove some more of Rust's dependencies on libgcc and replace it with LLVM's compiler-rt lib.  I've added compiler-rt as a submodule and changed libstd to link with it.  
As far as I could verify, after this change, the only symbols still imported by std from libgcc are the stack unwinding functions.   Other crates, however, still picked up symbols from libgcc, not from libstd, as I had hoped.  So linking definitely requires some work. 

I've only tested this on windows, 32-bit linux and android and fully expect it to fail on other platforms. Patches are welcome.
2014-02-11 18:21:49 -08:00
Alex Crichton
0a6b9219d1 Rewrite channels yet again for upgradeability
This, the Nth rewrite of channels, is not a rewrite of the core logic behind
channels, but rather their API usage. In the past, we had the distinction
between oneshot, stream, and shared channels, but the most recent rewrite
dropped oneshots in favor of streams and shared channels.

This distinction of stream vs shared has shown that it's not quite what we'd
like either, and this moves the `std::comm` module in the direction of "one
channel to rule them all". There now remains only one Chan and one Port.

This new channel is actually a hybrid oneshot/stream/shared channel under the
hood in order to optimize for the use cases in question. Additionally, this also
reduces the cognitive burden of having to choose between a Chan or a SharedChan
in an API.

My simple benchmarks show no reduction in efficiency over the existing channels
today, and a 3x improvement in the oneshot case. I sadly don't have a
pre-last-rewrite compiler to test out the old old oneshots, but I would imagine
that the performance is comparable, but slightly slower (due to atomic reference
counting).

This commit also brings the bonus bugfix to channels that the pending queue of
messages are all dropped when a Port disappears rather then when both the Port
and the Chan disappear.
2014-02-11 16:32:00 -08:00
Alex Crichton
47ef20014c Shuffle around ownership in concurrent queues
Beforehand, using a concurrent queue always mandated that the "shared state" be
stored internally to the queues in order to provide a safe interface. This isn't
quite as flexible as one would want in some circumstances, so instead this
commit moves the queues to not containing the shared state.

The queues no longer have a "default useful safe" interface, but rather a
"default safe" interface (minus the useful part). The queues have to be shared
manually through an Arc or some other means. This allows them to be a little
more flexible at the cost of a usability hindrance.

I plan on using this new flexibility to upgrade a channel to a shared channel
seamlessly.
2014-02-11 16:32:00 -08:00
bors
a4a908eafd auto merge of #11961 : niftynif/rust/btree, r=brson
I implemented an add method for the btree in progress.  It is intended to be refactored later using an alternative to .clone() that passes the borrow checker, but for now, it works as intended. r? @catamorphism
2014-02-11 16:31:48 -08:00
Vadim Chugunov
b7651325eb Build compiler-rt and link it to all crates, similarly to morestack. 2014-02-11 15:59:59 -08:00
bors
0ac6e5afda auto merge of #12158 : nikomatsakis/rust/issue-6801-borrowck-closures, r=pcwalton
I factored the commits by affected files, for the most part. The last 7 or 8 contain the meat of the PR. The rest are small changes to closures found in the codebase. Maybe interesting to read to see some of the impact of the rules.

r? @pcwalton

Fixes #6801
2014-02-11 15:06:49 -08:00
Derek Guenther
0465fd7fae Fixed fourcc example doc 2014-02-11 17:03:59 -06:00