Commit Graph

23066 Commits

Author SHA1 Message Date
Derek Chiang
a937d1875e Implement barrier. 2014-01-25 11:59:29 -05:00
bors
0f637ebd06 auto merge of #11790 : lfairy/rust/rename-num-consts, r=alexcrichton
The following are renamed:

* `min_value` => `MIN`
* `max_value` => `MAX`
* `bits` => `BITS`
* `bytes` => `BYTES`

All tests pass, except for `run-pass/phase-syntax-link-does-resolve.rs`. I doubt that failure is related, though.

Fixes #10010.
2014-01-25 07:56:27 -08:00
bors
caabbb8388 auto merge of #11788 : salemtalha/rust/master, r=huonw
Fixes #11785.
2014-01-25 06:31:31 -08:00
bors
b0ef2d56a8 auto merge of #11775 : alexcrichton/rust/select-fix, r=pcwalton
The race here happened when a port had its deschedule in select() canceled, but
the other chan had already been dropped. This meant that the DISCONNECTED case
was hit in abort_selection, but the to_wake cell hadn't been emptied yet (this
was done after aborting), causing an assert in abort_selection to trip.

To fix this, the to_wake cell is just emptied before abort_selection is called
(we know that we're the owner of it already).
2014-01-25 05:11:28 -08:00
Chris Wong
988e4f0a1c Uppercase numeric constants
The following are renamed:

* `min_value` => `MIN`
* `max_value` => `MAX`
* `bits` => `BITS`
* `bytes` => `BYTES`

Fixes #10010.
2014-01-25 21:38:25 +13:00
Salem Talha
1b4623d1dd Fixed iter's is_empty to use is_none() and added relevant test flag 2014-01-25 02:44:06 -05:00
Derek Chiang
e8baed0b2d Fix some docs about rt 2014-01-25 02:16:17 -05:00
Corey Richardson
bf5152f486 Fix zero-sized memory mapping 2014-01-24 22:30:01 -08:00
Corey Richardson
7499e2dd45 Add benchmarks 2014-01-24 22:30:00 -08:00
Corey Richardson
69afce64c7 Update task-perf-one-million 2014-01-24 22:30:00 -08:00
Corey Richardson
dee7fa58dd Use mmap to map in task stacks and guard page
Also implement caching of stacks.
2014-01-24 22:30:00 -08:00
Corey Richardson
462f09e949 Add support for arbitrary flags to MemoryMap.
This also fixes up the documentation a bit, it was subtly incorrect.
2014-01-24 22:30:00 -08:00
bors
de57a22b9a auto merge of #11774 : sfackler/rust/move-macros, r=pcwalton
They all have to go into a single module at the moment unfortunately.
Ideally, the logging macros would live in std::logging, condition! would
live in std::condition, format! in std::fmt, etc. However, this
introduces cyclic dependencies between those modules and the macros they
use which the current expansion system can't deal with. We may be able
to get around this by changing the expansion phase to a two-pass system
but that's for a later PR.

Closes #2247
cc #11763
2014-01-24 20:31:37 -08:00
bors
7c028c9ba7 auto merge of #11772 : sanxiyn/rust/reexport, r=cmr
The field is always set to true.
2014-01-24 19:11:39 -08:00
Andrew Chin
506c71c980 Use an absolute path in test_process_output_fail_to_start
This test is designed to ensure that running a non-existent executable
results in a correct error message (FileNotFound in this case of this
test).  However, if you try to run an executable that doesn't exist, and
that requires searching through the $PATH, and one of the $PATH components
is not readable, then a PermissionDenied error will be returned, instead
of FileNotFound.
2014-01-24 19:15:06 -05:00
bors
dc48adc69f auto merge of #11748 : brson/rust/timerfdandroid, r=alexcrichton
It doesn't seem to exist.
2014-01-24 16:11:31 -08:00
bors
8de3fab82a auto merge of #11732 : luqmana/rust/native-getaddrinfo, r=alexcrichton
The last bit I needed to be able to use libnative :P
2014-01-24 14:51:36 -08:00
Luqman Aden
adb5128020 libnative: Avoid gai_strerror on windows. 2014-01-24 16:44:16 -05:00
Luqman Aden
a04cc4db2c libstd: Use iotest! for for get_host_addresses. 2014-01-24 16:44:16 -05:00
bors
a1d9d9e6d2 auto merge of #11744 : alexcrichton/rust/issue-5219, r=thestinger
By default, the compiler and libraries are all still built with rpaths, but this
can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc.

Closes #5219
2014-01-24 10:26:33 -08:00
Alex Crichton
35e26e94d8 Fix a spuriously tripped assert in select()
The race here happened when a port had its deschedule in select() canceled, but
the other chan had already been dropped. This meant that the DISCONNECTED case
was hit in abort_selection, but the to_wake cell hadn't been emptied yet (this
was done after aborting), causing an assert in abort_selection to trip.

To fix this, the to_wake cell is just emptied before abort_selection is called
(we know that we're the owner of it already).
2014-01-24 10:05:58 -08:00
Alex Crichton
e715cdba31 Allow opting-out of rpath usage
By default, the compiler and libraries are all still built with rpaths, but this
can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc.

cc #5219
2014-01-24 09:24:45 -08:00
bors
8c805fa70b auto merge of #11760 : dmac/rust/addressable-search, r=alexcrichton
This change adds two improvements to docs searching functionality.

First, search results will immediately be displayed when a ?search=searchterm
query string parameter is provided to any docs url.

Second, search results are now inserted into the browser history, allowing for
easier navigation between search results and docs pages.
2014-01-24 08:46:33 -08:00
Steven Fackler
3ba916ddff Delete ignore! macro
This was a holdover from when we didn't allow nested comment blocks
(think #if 0). It isn't used anywhere.
2014-01-24 08:46:31 -08:00
Steven Fackler
86a8b031f5 Move macro_rules! macros to libstd
They all have to go into a single module at the moment unfortunately.
Ideally, the logging macros would live in std::logging, condition! would
live in std::condition, format! in std::fmt, etc. However, this
introduces cyclic dependencies between those modules and the macros they
use which the current expansion system can't deal with. We may be able
to get around this by changing the expansion phase to a two-pass system
but that's for a later PR.

Closes #2247
cc #11763
2014-01-24 08:35:39 -08:00
bors
a5ab960d2e auto merge of #11750 : bnoordhuis/rust/follow-rustc-symlink, r=thestinger
Before this commit, rustc looked in `dirname $0`/../lib for libraries
but that doesn't work when rustc is invoked through a symlink.

This commit makes rustc look in `dirname $(readlink $0)`/../lib, i.e.
it first canonicalizes the symlink before walking up the directory tree.

Fixes #3632.
2014-01-24 06:06:33 -08:00
Seo Sanghyeon
0f36438a8e Remove reexport field 2014-01-24 20:46:19 +09:00
bors
5675f2813f auto merge of #11742 : eminence/rust/dylib-test-fix, r=alexcrichton
On my Gentoo Linux machine, the c-dynamic-dylib test is failing, because libcfoo can't be found.  bar has a correct rpath for finding libfoo.so, but libfoo.so's rpath doesn't contain the right entries for finding libcfoo.


Below is the test failure on my machine.  This test pass with this commit:

```
maketest: c-dynamic-dylib
----- /storage/home/achin/devel/rust/src/test/run-make/c-dynamic-dylib/ --------------------
------ stdout ---------------------------------------------
make[1]: Entering directory `/storage/home/achin/devel/rust/src/test/run-make/c-dynamic-dylib'
gcc -Wall -Werror -g -fPIC -m64 -L /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib -c -o /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib/libcfoo.o cfoo.c
gcc -Wall -Werror -g -fPIC -m64 -L /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib -o /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib/libcfoo.so /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib/libcfoo.o -shared
/storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/stage2/bin/rustc --out-dir /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib -L /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib foo.rs
/storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/stage2/bin/rustc --out-dir /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib -L /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib bar.rs
/storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib/bar
rm /storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib/libcfoo.o
make[1]: Leaving directory `/storage/home/achin/devel/rust/src/test/run-make/c-dynamic-dylib'

------ stderr ---------------------------------------------
/storage/home/achin/devel/rust/x86_64-unknown-linux-gnu/test/run-make/c-dynamic-dylib/bar: error while loading shared libraries: libcfoo.so: cannot open shared object file: No such file or directory
make[1]: *** [all] Error 127

------        ---------------------------------------------

```
2014-01-24 03:16:31 -08:00
bors
4ce84fa1de auto merge of #11720 : sfackler/rust/macro-export-source, r=alexcrichton
The old method of serializing the AST gives totally bogus spans if the
expansion of an imported macro causes compilation errors. The best
solution seems to be to serialize the actual textual macro definition
and load it the same way the std-macros are. I'm not totally confident
that getting the source from the CodeMap will always do the right thing,
but it seems to work in simple cases.
2014-01-24 00:06:31 -08:00
bors
cd8ee786f9 auto merge of #11718 : ktt3ja/rust/borrowck-error-msg, r=brson
A mutable and immutable borrow place some restrictions on what you can
with the variable until the borrow ends. This commit attempts to convey
to the user what those restrictions are. Also, if the original borrow is
a mutable borrow, the error message has been changed (more specifically,
i. "cannot borrow `x` as immutable because it is also borrowed as
mutable" and ii. "cannot borrow `x` as mutable more than once" have
been changed to "cannot borrow `x` because it is already borrowed as
mutable").

In addition, this adds a (custom) span note to communicate where the
original borrow ends.

```rust
fn main() {
    match true {
        true => {
            let mut x = 1;
            let y = &x;
            let z = &mut x;
        }
        false => ()
    }
}

test.rs:6:21: 6:27 error: cannot borrow `x` as mutable because it is already borrowed as immutable
test.rs:6             let z = &mut x;
                              ^~~~~~
test.rs:5:21: 5:23 note: previous borrow of `x` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `x` until the borrow ends
test.rs:5             let y = &x;
                              ^~
test.rs:7:10: 7:10 note: previous borrow ends here
test.rs:3         true => {
test.rs:4             let mut x = 1;
test.rs:5             let y = &x;
test.rs:6             let z = &mut x;
test.rs:7         }
                  ^
```

```rust
fn foo3(t0: &mut &mut int) {
    let t1 = &mut *t0;
    let p: &int = &**t0;
}

fn main() {}

test.rs:3:19: 3:24 error: cannot borrow `**t0` because it is already borrowed as mutable
test.rs:3     let p: &int = &**t0;
                            ^~~~~
test.rs:2:14: 2:22 note: previous borrow of `**t0` as mutable occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `**t0` until the borrow ends
test.rs:2     let t1 = &mut *t0;
                       ^~~~~~~~
test.rs:4:2: 4:2 note: previous borrow ends here
test.rs:1 fn foo3(t0: &mut &mut int) {
test.rs:2     let t1 = &mut *t0;
test.rs:3     let p: &int = &**t0;
test.rs:4 }
          ^
```

For the "previous borrow ends here" note, if the span is too long (has too many lines), then only the first and last lines are printed, and the middle is replaced with dot dot dot:
```rust
fn foo3(t0: &mut &mut int) {
    let t1 = &mut *t0;
    let p: &int = &**t0;



}

fn main() {}

test.rs:3:19: 3:24 error: cannot borrow `**t0` because it is already borrowed as mutable
test.rs:3     let p: &int = &**t0;
                            ^~~~~
test.rs:2:14: 2:22 note: previous borrow of `**t0` as mutable occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `**t0` until the borrow ends
test.rs:2     let t1 = &mut *t0;
                       ^~~~~~~~
test.rs:7:2: 7:2 note: previous borrow ends here
test.rs:1 fn foo3(t0: &mut &mut int) {
...
test.rs:7 }
          ^
```

(Sidenote: the `span_end_note` currently also has issue #11715)
2014-01-23 22:46:32 -08:00
bors
bf9c25562d auto merge of #11686 : mankyKitty/rust/rename-invert-to-flip-issue-10632, r=alexcrichton
Renamed the ```invert()``` function in ```iter.rs``` to ```flip()```, from #10632 

Also renamed the ```Invert<T>``` type to ```Flip<T>```.

Some related code comments changed. Documentation that I could find has
been updated, and all the instances I could locate where the
function/type were called have been updated as well.

This is my first contribution to Rust! Apologies in advance if I've snarfed the 
PR process, I'm not used to rebase.

I initially had issues with the ```codegen``` section of the tests failing, however
the ```make check``` process is not reporting any failures at this time. I think
that was a local env issue more than me facerolling my changes. :)
2014-01-23 19:56:35 -08:00
bors
2b62371c20 auto merge of #11478 : klutzy/rust/rustpkg-crate-id, r=cmr
This patchset consists of three parts:

- rustpkg doesn't guess crate version if it is not given by user.
- `rustpkg::version::Version` is replaced by `Option<~str>`.
  It removes some semantic versioning portions which is not currently used.
  (cc #8405 and #11396)
  `rustpkg::crate_id::CrateId` is also replaced by `syntax::crateid::CrateId`.
- rustpkg now computes hash to find crate, instead of manual filename parse.

cc @metajack
2014-01-23 17:31:44 -08:00
aydin.kim
be6fb8f2cd update llvm 2014-01-23 15:15:43 -08:00
Alex Crichton
219478fb41 Build llvm-extract (needed by codegen tests) 2014-01-23 15:13:00 -08:00
Daniel MacDougall
b869f36e78 Make docs search results URL-addressable
This change adds two improvements to docs searching functionality.

First, search results will immediately be displayed when a ?search=searchterm
query string parameter is provided to any docs url.

Second, search results are now inserted into the browser history, allowing for
easier navigation between search results and docs pages.
2014-01-23 14:04:50 -08:00
Sean Chalmers
292ed3e55c Update flip() to be rev().
Consensus leaned in favour of using rev instead of flip.
2014-01-23 22:18:18 +01:00
Sean Chalmers
55d6e0e1b7 Rename Invert to Flip - Issue 10632
Renamed the invert() function in iter.rs to flip().

Also renamed the Invert<T> type to Flip<T>.

Some related code comments changed. Documentation that I could find has
been updated, and all the instances I could locate where the
function/type were called have been updated as well.
2014-01-23 21:50:18 +01:00
Alex Crichton
aa78da3f45 Handle EINTR in epoll for native timers 2014-01-23 12:34:01 -08:00
Kiet Tran
b3290d322e Make some borrow checker errors more user friendly
A mutable and immutable borrow place some restrictions on what you can
with the variable until the borrow ends. This commit attempts to convey
to the user what those restrictions are. Also, if the original borrow is
a mutable borrow, the error message has been changed (more specifically,
i. "cannot borrow `x` as immutable because it is also borrowed as
mutable" and ii. "cannot borrow `x` as mutable more than once" have
been changed to "cannot borrow `x` because it is already borrowed as
mutable").

In addition, this adds a (custom) span note to communicate where the
original borrow ends.
2014-01-23 14:44:28 -05:00
Steven Fackler
d908e97da3 Redo exported macro serialization
The old method of serializing the AST gives totally bogus spans if the
expansion of an imported macro causes compilation errors. The best
solution seems to be to serialize the actual textual macro definition
and load it the same way the std-macros are. I'm not totally confident
that getting the source from the CodeMap will always do the right thing,
but it seems to work in simple cases.
2014-01-23 09:01:36 -08:00
bors
657e353022 auto merge of #11739 : thestinger/rust/rm-old-ext, r=alexcrichton 2014-01-23 05:56:30 -08:00
Ben Noordhuis
51103c89d0 Make check-summary.py support file globbing
Fixes the following error when executing `make check-lite`:

    Traceback (most recent call last):
      File "/home/bnoordhuis/src/rust/src/etc/check-summary.py", line 27, in <module>
        map(summarise, logfiles)
      File "/home/bnoordhuis/src/rust/src/etc/check-summary.py", line 10, in summarise
        with open(fname) as fd:
    IOError: [Errno 2] No such file or directory: 'tmp/*.log'
2014-01-23 13:06:21 +01:00
bors
7cabd40320 auto merge of #11737 : alexcrichton/rust/issue-11729, r=thestinger
Closes #11729
2014-01-23 03:51:29 -08:00
Ben Noordhuis
8cce35e490 Follow symlinks in sysroot
Before this commit, rustc looked in `dirname $0`/../lib for libraries
but that doesn't work when rustc is invoked through a symlink.

This commit makes rustc look in `dirname $(readlink $0)`/../lib, i.e.
it first canonicalizes the symlink before walking up the directory tree.

Fixes #3632.
2014-01-23 11:45:23 +01:00
bors
aa9cf4cf8d auto merge of #11701 : FeGs/rust/stray-debug-in-metadata, r=alexcrichton
When there is `println!` macro in the code, compiling is never end.

```rust
// print.rs
fn main() {
  println!("Hello!");
}
```

```bash
$ RUST_LOG=rustc rustc print.rs
```

And this is a part of output from stderr.

```bash
# ...
Looking up syntax::ast::DefId{crate: 1u32, node: 176234u32}
looking up syntax::ast::DefId{crate: 1u32, node: 176235u32} : extra::ebml::Doc<>{data: &[168u8, 16u8, 0u8, 0u8, 16u8, 51u8, 101u8, 53u8, 97u8, 101u8, 98u8, 56u8, 51u8, 55u8, 97u8, 101u8, 49u8, 54u8, 50u8
# ...
# vector which has infinite length.
```

* note : rust 0.9, 0.10-pre
2014-01-23 01:31:39 -08:00
Brian Anderson
e70ca23b8d native: Don't use timerfd on Android
It doesn't seem to exist.
2014-01-23 01:08:34 -08:00
bors
19e0cbe420 auto merge of #11682 : thestinger/rust/vector, r=brson
This is just an initial implementation and does not yet fully replace `~[T]`. A generic initialization syntax for containers is missing, and the slice functionality needs to be reworked to make auto-slicing unnecessary.

Traits for supporting indexing properly are also required. This also needs to be fixed to make ring buffers as easy to use as vectors.

The tests and documentation for `~[T]` can be ported over to this type when it is removed. I don't really expect DST to happen for vectors as having both `~[T]` and `Vec<T>` is overcomplicated and changing the slice representation to 3 words is not at all appealing. Unlike with traits, it's possible (and easy) to implement `RcSlice<T>` and `GcSlice<T>` without compiler help.
2014-01-22 23:26:33 -08:00
bors
52ba3b6414 auto merge of #11611 : SiegeLord/rust/exp_printing, r=alexcrichton
Fixes #6593

Currently, Rust provides no way to print very large or very small floating point values which come up routinely in scientific and modeling work. The classical solution to this is to use the scientific/exponential notation, which not-coincidentally, corresponds to how floating point values are encoded in memory. Given this, there are two solutions to the problem. One is what, as far as I understand it, Python does. I.e. for floating point numbers in a certain range it does what we do today with the `'f'` formatting flag, otherwise it switches to exponential notation. The other way is to provide a set of formatting flags to explicitly choose the exponential notation, like it is done in C. I've chosen the second way as I think its important to provide that kind of control to the user.

This pull request changes the `std::num::strconv::float_to_str_common` function to optionally format floating point numbers using the exponential (scientific) notation. The base of the significant can be varied between 2 and 25, while the base of the exponent can be 2 or 10.

Additionally this adds two new formatting specifiers to `format!` and friends: `'e'` and `'E'` which switch between outputs like `1.0e5` and `1.0E5`. Mostly parroting C stdlib in this sense, although I wasn't going for an exact output match.
2014-01-22 22:01:40 -08:00
Andrew Chin
24c560a69f Set LD_LIBRARY_PATH on linux for c-dynamic-dylib test
Else, libfoo can't find libcfoo.so.

bar has an rpath, which lets it find libfoo.  But libfoo doesn't have an
rapth that tells it where to find libcfoo
2014-01-22 23:49:36 -05:00
Daniel Micay
b2ec71fc27 hashmap: port to Vec<T> 2014-01-22 23:13:57 -05:00
Daniel Micay
1798de7d08 add new vector representation as a library 2014-01-22 23:13:57 -05:00
Daniel Micay
17d23b8c17 vec: make unsafe indexing functions higher-level 2014-01-22 23:13:57 -05:00
Daniel Micay
802d41fe23 libc: switch free to the proper signature
This does not attempt to fully propagate the mutability everywhere, but
gives new code a hint to avoid the same issues.
2014-01-22 23:13:53 -05:00
Alex Crichton
b8e43838cf Implement native timers
Native timers are a much hairier thing to deal with than green timers due to the
interface that we would like to expose (both a blocking sleep() and a
channel-based interface). I ended up implementing timers in three different ways
for the various platforms that we supports.

In all three of the implementations, there is a worker thread which does send()s
on channels for timers. This worker thread is initialized once and then
communicated to in a platform-specific manner, but there's always a shared
channel available for sending messages to the worker thread.

* Windows - I decided to use windows kernel timer objects via
  CreateWaitableTimer and SetWaitableTimer in order to provide sleeping
  capabilities. The worker thread blocks via WaitForMultipleObjects where one of
  the objects is an event that is used to wake up the helper thread (which then
  drains the incoming message channel for requests).

* Linux/(Android?) - These have the ideal interface for implementing timers,
  timerfd_create. Each timer corresponds to a timerfd, and the helper thread
  uses epoll to wait for all active timers and then send() for the next one that
  wakes up. The tricky part in this implementation is updating a timerfd, but
  see the implementation for the fun details

* OSX/FreeBSD - These obviously don't have the windows APIs, and sadly don't
  have the timerfd api available to them, so I have thrown together a solution
  which uses select() plus a timeout in order to ad-hoc-ly implement a timer
  solution for threads. The implementation is backed by a sorted array of timers
  which need to fire. As I said, this is an ad-hoc solution which is certainly
  not accurate timing-wise. I have done this implementation due to the lack of
  other primitives to provide an implementation, and I've done it the best that
  I could, but I'm sure that there's room for improvement.

I'm pretty happy with how these implementations turned out. In theory we could
drop the timerfd implementation and have linux use the select() + timeout
implementation, but it's so inaccurate that I would much rather continue to use
timerfd rather than my ad-hoc select() implementation.

The only change that I would make to the API in general is to have a generic
sleep() method on an IoFactory which doesn't require allocating a Timer object.
For everything but windows it's super-cheap to request a blocking sleep for a
set amount of time, and it's probably worth it to provide a sleep() which
doesn't do something like allocate a file descriptor on linux.
2014-01-22 19:31:39 -08:00
Daniel Micay
a2dab3c46e remove old rc extension from detection files 2014-01-22 20:39:32 -05:00
SiegeLord
acd718b378 Remove the initial and trailing blank doc-comment lines 2014-01-22 20:32:40 -05:00
SiegeLord
c13e0de836 Add some tests for the exponential notation 2014-01-22 20:32:40 -05:00
SiegeLord
25b107f1e3 Add LowerExp 'e' and UpperExp 'E' format traits/specifiers 2014-01-22 20:32:40 -05:00
SiegeLord
2b4bd0780b float_to_str_bytes_common can now handle exponential notation 2014-01-22 20:32:40 -05:00
Luqman Aden
5aa31c43a0 libnative: Implement get_host_addresses. 2014-01-22 20:05:06 -05:00
Alex Crichton
8edf57ee42 Don't fatally fail in driver::early_error
Closes #11729
2014-01-22 15:48:55 -08:00
Alex Crichton
530909f2d8 Implement std::rt::at_exit
This routine is currently only used to clean up the timer helper thread in the
libnative implementation, but there are possibly other uses for this.

The documentation is clear that the procedures are *not* run with any task
context and hence have very little available to them. I also opted to disallow
at_exit inside of at_exit and just abort the process at that point.
2014-01-22 15:15:28 -08:00
Ben Noordhuis
cdd146b895 Add std::os::self_exe_name() 2014-01-22 23:47:12 +01:00
bors
aedf567a95 auto merge of #10943 : fhahn/rust/issue-7313-replace-c-types, r=alexcrichton
I've started working on a patch for #7313 . So far I tried to replace C types in `src/libstd/unstable/*` and related files.

So far, I have two questions. Is there a convention for passing pointers around in `std` as Rust types? Sometimes pointers are passed around as `*c_char` (which seems to be an `*i8`), `*c_void` or `*u8`, which leads to a lot of casts. E.g: [`exchange_malloc`](https://github.com/fhahn/rust/compare/issue-7313-replace-c-types?expand=1#diff-39f44b8c3f4496abab854b3425ac1617R60) used to return a `*c_char` but the function in turn only calls `malloc_raw` which returns a `*c_void`.
Is there a specific reason for this?

The second question is about `CString` and related functions like `with_c_str`. At the moment these functions use `*c_char*`. Should I replace it with `*u8` or keep it, because it's an wrapper around classical C strings?
2014-01-22 11:06:24 -08:00
Florian Hahn
2eb4f05850 Replace C types with Rust types in libstd, closes #7313 2014-01-22 19:20:47 +01:00
klutzy
a6a31ecb04 rustpkg::crate_id: Remove CrateId
There is no significant difference between `rustpkg::crate_id::CrateId`
and `syntax::crateid::CrateId`. rustpkg's one is replaced by syntax's
one.
2014-01-23 03:03:55 +09:00
klutzy
df9067cd15 rustpkg: Compute hash to find crate
Previously rustpkg tried to parse filenames to find crate. Now ue use
deterministic hashes, so it becomes possible to directly construct
filename and check if the file exists.
2014-01-23 03:03:55 +09:00
klutzy
655433e334 rustpkg::version: Remove enum Version
Currently rustpkg doesn't use SemanticVersion or Tagged, so they are
removed. Remaining variants are replaced by `Option<~str>`.
2014-01-23 03:02:40 +09:00
klutzy
fa84593fc3 rustpkg: Do not guess version if not given
rustpkg accessed git repo to read tags and guess package version,
but it's not quite useful: version can be given explicitly by user,
and implicit guess may cause confusions.
2014-01-23 03:02:39 +09:00
Seo Sanghyeon
7689353918 Allow trailing commas in argument lists and tuple patterns 2014-01-23 01:55:53 +09:00
Hong Chulju
86b0564f73 rustc/metadata: Removed stray debug statements 2014-01-22 19:38:20 +09:00
bors
750d48b0ad auto merge of #11711 : alexcrichton/rust/issue-11683, r=brson
There's lots of fun rationale in the comments of the diff.

Closes #11683
2014-01-22 00:51:20 -08:00
Brian Anderson
045716a6e9 xfail another external macro test on android 2014-01-21 21:52:35 -08:00
bors
f8477c9da5 auto merge of #11500 : jhasse/rust/patch-rlib, r=alexcrichton
Currently `rustpkg` only looks for shared libraries. After this patch it also looks for `*.rlib` files.
2014-01-21 17:26:14 -08:00
bors
918a7314a8 auto merge of #11129 : SimonSapin/rust/foo-vs-foo_opt, r=alexcrichton
[On 2013-12-06, I wrote to the rust-dev mailing list](https://mail.mozilla.org/pipermail/rust-dev/2013-December/007263.html):

> Subject: Let’s avoid having both foo() and foo_opt()
>
> We have some functions and methods such as [std::str::from_utf8](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8.html) that may succeed and give a result, or fail when the input is invalid.
>
> 1. Sometimes we assume the input is valid and don’t want to deal with the error case. Task failure works nicely.
>
> 2. Sometimes we do want to do something different on invalid input, so returning an `Option<T>` works best.
>
> And so we end up with both `from_utf8` and `from_utf8`. This particular case is worse because we also have `from_utf8_owned` and `from_utf8_owned_opt`, to cover everything.
>
> Multiplying names like this is just not good design. I’d like to reduce this pattern.
>
> Getting behavior 1. when you have 2. is easy: just call `.unwrap()` on the Option. I think we should rename every `foo_opt()` function or method to just `foo`, remove the old `foo()` behavior, and tell people (through documentation) to use `foo().unwrap()` if they want it back?
>
> The downsides are that unwrap is more verbose and gives less helpful error messages on task failure. But I think it’s worth it.


The email discussion has gone around long enough. Let’s discuss a concrete proposal. For the following functions or methods, I removed `foo` (that caused task failure) and renamed `foo_opt` (that returns `Option`) to just `foo`.

Vector methods:

* `get_opt` (rename only, `get` did not exist as it would have been just `[]`)
* `head_opt`
* `last_opt`
* `pop_opt`
* `shift_opt`
* `remove_opt`

`std::path::BytesContainer` method:

* `container_as_str_opt`

`std::str` functions:

* `from_utf8_opt`
* `from_utf8_owned_opt` (also remove the now unused `not_utf8` condition)

Is there something else that should recieve the same treatement?

I did not rename `recv_opt` on channels based on @brson’s [feedback](https://mail.mozilla.org/pipermail/rust-dev/2013-December/007270.html).

Feel free to pick only some of these commits.
2014-01-21 15:56:16 -08:00
Simon Sapin
ec422d70c3 [std::str] Remove the now unused not_utf8 condition. 2014-01-21 15:48:48 -08:00
Simon Sapin
05ae134ace [std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old from_utf8_owned() behavior 2014-01-21 15:48:48 -08:00
Simon Sapin
b8c4149293 [std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() behavior 2014-01-21 15:48:48 -08:00
Simon Sapin
46b01647ba [std::path] Rename .container_as_str_opt() to .container_as_str(), drop the old .container_as_str() behavior 2014-01-21 15:48:47 -08:00
Simon Sapin
e75d0a9b7e [std::vec] Rename .remove_opt() to .remove(), drop the old .remove() behavior 2014-01-21 15:48:47 -08:00
Simon Sapin
b5e65731c0 [std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behavior 2014-01-21 15:48:47 -08:00
Simon Sapin
bada25e425 [std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behavior 2014-01-21 15:48:47 -08:00
Simon Sapin
aa66b91767 [std::vec] Rename .last_opt() to .last(), drop the old .last() behavior 2014-01-21 15:48:46 -08:00
Simon Sapin
add8f9680e [std::vec] Rename .head_opt() to .head(), drop the old .head() behavior 2014-01-21 11:45:08 -08:00
Simon Sapin
d25334d63a [std::vec] Rename .get_opt() to .get() 2014-01-21 11:44:13 -08:00
bors
505572b3f8 auto merge of #11700 : bharrisau/rust/thumb, r=alexcrichton
To build for the cortex-M series ARM processors LLC needs to be told to build for the thumb instruction set. There are two ways to do this, either with the triple "thumb\*-\*-\*" or with -march=thumb (which just overrides the triple anyway). I chose the first way.

The following will fail because the local cc doesn't know what to do with -mthumb.
````
rustc test.rs --lib --target thumb-linux-eab
error: linking with `cc` failed: exit code: 1
note: cc: error: unrecognized command line option ‘-mthumb’
````

Changing the linker works as expected.
````
rustc test.rs --lib --target thumb-linux-eabi --linker arm-none-eabi-gcc
````

Ideally I'd have the triple thumb-none-eabi, but adding a new OS looks like much more work (and I'm not familiar enough with what it does to know if it is needed).
2014-01-21 11:26:13 -08:00
bors
232d8e5605 auto merge of #11665 : alexcrichton/rust/zed-cleanup, r=brson
* Stop using hardcoded numbers that have to all get updated when something changes (inevitable errors and rebase conflicts) as well as removes some unneeded -Z options (obsoleted over time).
* Remove `std::rt::borrowck`
2014-01-21 10:06:18 -08:00
Alex Crichton
d84c3369f7 Remove no-debug-borrows from the makefiles 2014-01-21 10:02:48 -08:00
Alex Crichton
254e35c268 Capitalize debugging opts and make them u64 2014-01-21 09:23:56 -08:00
Alex Crichton
a8807771b2 Purge borrowck from libstd
This hasn't been in use since `@mut` was removed
2014-01-21 09:23:56 -08:00
Alex Crichton
57f8073b5e Remove obsoleted -Z options
* borrowck_note_pure - unused
* borrowck_note_loan - unused
* no_debug_borrows - unused
* lint_llvm - equivalent to -Z no-prepopulate-passes + --llvm-passes lint
2014-01-21 09:23:56 -08:00
Alex Crichton
eca980be57 Stop using hardcoded numbers for -Z options
Instead use a macro and generate them!
2014-01-21 09:23:54 -08:00
Alex Crichton
12c5fc5877 Flag all TLS functions as inline(never)
There's lots of fun rationale in the comments of the diff.

Closes #11683
2014-01-21 08:19:35 -08:00
Huon Wilson
39713b8295 Remove unnecessary parentheses. 2014-01-21 22:00:18 +11:00
Huon Wilson
3901228811 rustc: add lint for parens in if, while, match and return.
The parens in `if (true) {}` are not not necessary, so we'll warn about
them.
2014-01-21 21:58:48 +11:00
Ben Harris
50d0e07065 Add support for ARM thumb architecture 2014-01-21 18:27:49 +08:00
bors
40df5a2e9a auto merge of #11699 : alexcrichton/rust/snapshot, r=huonw
Upgrade the version to 0.10-pre
2014-01-21 01:31:30 -08:00
bors
6f3326f84d auto merge of #11687 : sfackler/rust/macro-export-inner-crate, r=alexcrichton
It previously missed anything in an inner module.
2014-01-21 00:06:22 -08:00
bors
813db08fe6 auto merge of #11684 : FlaPer87/rust/doc_typos, r=cmr 2014-01-20 22:46:20 -08:00
bors
80a2306aee auto merge of #11662 : alexcrichton/rust/faster-parens, r=huonw
The included test case would essentially never finish compiling without this
patch. It recursies twice at every ExprParen meaning that the branching factor
is 2^n

The included test case will take so long to parse on the old compiler that it'll
surely never let this crop up again.
2014-01-20 20:06:23 -08:00
Alex Crichton
cb12de14c9 Register new snapshots
Upgrade the version to 0.10-pre
2014-01-20 19:45:38 -08:00
bors
94236fc078 auto merge of #11653 : alexcrichton/rust/issue-11647, r=luqmana
Closes #11647
2014-01-20 16:56:25 -08:00
bors
b6400f9984 auto merge of #11675 : alexcrichton/rust/fix-snap, r=cmr
They need to read the metadata of cross-compiled crates, so the pretty things
need to have the right target.
2014-01-20 15:26:27 -08:00
Alex Crichton
c62ef2e807 Fix cross-compiled pretty tests
They need to read the metadata of cross-compiled crates, so the pretty things
need to have the right target.
2014-01-20 13:51:12 -08:00
Alex Crichton
1f542cd264 Fix a pathological const checking case
The included test case would essentially never finish compiling without this
patch. It recursies twice at every ExprParen meaning that the branching factor
is 2^n

The included test case will take so long to parse on the old compiler that it'll
surely never let this crop up again.
2014-01-20 13:49:31 -08:00
Alex Crichton
c6123ca105 rustuv: Re-work sockaddr glue to not use malloc
This means we can purge even more C from src/rt!
2014-01-20 13:32:45 -08:00
Alex Crichton
caa321ab7d Don't emit landing pads with -Z no-landing-pads
Closes #11647
2014-01-20 13:29:49 -08:00
bors
d4640f9d66 auto merge of #11673 : omasanori/rust/sep-doc, r=alexcrichton 2014-01-20 11:41:29 -08:00
bors
bf89b68a37 auto merge of #11664 : bjz/rust/identities, r=alexcrichton
`Zero` and `One` have precise definitions in mathematics as the identities of the `Add` and `Mul` operations respectively. As such, types that implement these identities are now also required to implement their respective operator traits. This should reduce their misuse whilst still enabling them to be used in generalized algebraic structures (not just numbers). Existing usages of `#[deriving(Zero)]` in client code could break under these new rules, but this is probably a sign that they should have been using something like `#[deriving(Default)]` in the first place.

For more information regarding the mathematical definitions of the additive and multiplicative identities, see the following Wikipedia articles:

- http://wikipedia.org/wiki/Additive_identity
- http://wikipedia.org/wiki/Multiplicative_identity

Note that for floating point numbers the laws specified in the doc comments of `Zero::zero` and `One::one` may not always hold. This is true however for many other traits currently implemented by floating point numbers. What traits floating point numbers should and should not implement is an open question that is beyond the scope of this pull request.

The implementation of `std::num::pow` has been made more succinct and no longer requires `Clone`. The coverage of the associated unit test has also been increased to test for more combinations of bases, exponents, and expected results.
2014-01-20 10:16:30 -08:00
Steven Fackler
d049c27f5b Scan the entire crate for exported macros
It previously missed anything in an inner module.
2014-01-20 09:22:46 -08:00
bors
f8efde148c auto merge of #11670 : sfackler/rust/extctxt-span-note, r=alexcrichton
It was the only span_* missing.
2014-01-20 08:41:30 -08:00
bors
02d4572696 auto merge of #11661 : huonw/rust/fixed-length-instantiation, r=thestinger
Previously, they were treated like ~[] and &[] (which can have length
0), but fixed length vectors are fixed length, i.e. we know at compile
time if it's possible to have length zero (which is only for [T, .. 0]).

Fixes #11659.
2014-01-20 06:16:29 -08:00
bors
068d828850 auto merge of #11660 : sfackler/rust/quote-unused-sp, r=huonw
The provided span isn't used in all cases (namely primitives).
2014-01-20 04:11:32 -08:00
bors
e83e5769ee auto merge of #11657 : huonw/rust/less-lang-duplication, r=cmr
We can use a secondary macro to calculate the count from the information
we're already having to pass to the lang items macro.
2014-01-20 02:31:42 -08:00
Flavio Percoco
1089bfef60 Fix documentation typos 2014-01-20 11:17:27 +01:00
bors
e594acad5f auto merge of #11656 : brson/rust/omgandroid, r=cmr 2014-01-20 01:11:35 -08:00
Brendan Zabarauskas
509283d149 Improve std::num::pow implementation
The implementation has been made more succinct and no longer requires Clone. The coverage of the associated unit test has also been increased to check more combinations of bases, exponents, and expected results.
2014-01-20 18:09:46 +11:00
Brendan Zabarauskas
cf56624a4a Add operator trait constraints to std::num::{Zero, One} and document their appropriate use
Zero and One have precise definitions in mathematics. Documentation has been added to describe the appropriate uses for these traits and the laws that they should satisfy.

For more information regarding these identities, see the following wikipedia pages:

- http://wikipedia.org/wiki/Additive_identity
- http://wikipedia.org/wiki/Multiplicative_identity
2014-01-20 18:09:46 +11:00
bors
a0ecb15411 auto merge of #11652 : hdima/rust/base64-padding-newlines, r=alexcrichton
Ignore all newline characters in Base64 decoder to make it compatible with other Base64 decoders.

Most of the Base64 decoder implementations ignore all newline characters in the input string. There are some examples:

Python:

```python
>>> "
A
Q
=
=
".decode("base64")
'\x01'
```

Ruby:

```ruby
irb(main):001:0> "
A
Q
=
=
".unpack("m")
=> [""]
```

Erlang:

```erlang
1> base64:decode("
A
Q
=
=
").
<<1>>
```

Moreover some Base64 encoders append newline character at the end of the output string by default:

Python:

```python
>>> "".encode("base64")
'AQ==
'
```

Ruby:

```ruby
irb(main):001:0> [""].pack("m")
=> "AQ==
"
```

So I think it's fairly important for Rust Base64 decoder to accept Base64 inputs even with newline characters in the padding.
2014-01-19 22:31:42 -08:00
bors
764f2cb6f3 auto merge of #11649 : FlaPer87/rust/pow, r=cmr
There was an old and barely used implementation of pow, which expected
both parameters to be uint and required more traits to be implemented.
Since a new implementation for `pow` landed, I'm proposing to remove
this old impl in favor of the new one.

The benchmark shows that the new implementation is faster than the one being removed:

```
    test num::bench::bench_pow_function               ..bench:      9429 ns/iter (+/- 2055)
    test num::bench::bench_pow_with_uint_function     ...bench:     28476 ns/iter (+/- 2202)
```
2014-01-19 19:46:35 -08:00
bors
0e6455e2b8 auto merge of #10801 : musitdev/rust/jsondoc2, r=cmr
I update the example of json use to the last update of the json.rs code. I delete the old branch.
From my last request, I remove the example3 because it doesn't compile. I don't understand why and I don't have the time now to investigate.
2014-01-19 18:21:39 -08:00
bors
7c33df0dbb auto merge of #11644 : huonw/rust/less-fatality, r=cmr
This means that compilation continues for longer, and so we can see more
errors per compile. This is mildly more user-friendly because it stops
users having to run rustc n times to see n macro errors: just run it
once to see all of them.
2014-01-19 16:56:40 -08:00
bors
f7cc8a625b auto merge of #11643 : kballard/rust/path-root-path, r=erickt 2014-01-19 15:31:57 -08:00
OGINO Masanori
6b18ef5358 Fix misuse of character/byte in std::path.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-01-20 07:42:28 +09:00
bors
18061e85b7 auto merge of #11642 : erickt/rust/path, r=huonw
This pull request exposes a platform independent way to get the path separator. This is useful when building complicated paths by hand.
2014-01-19 13:11:37 -08:00
Steven Fackler
88d0c182b7 Add span_note to ExtCtxt
It was the only span_* missing.
2014-01-19 11:25:11 -08:00
bors
5512fb49a0 auto merge of #11639 : sfackler/rust/macro-crate-path, r=alexcrichton
If the library is in the working directory, its path won't have a "/"
which will cause dlopen to search /usr/lib etc. It turns out that Path
auto-normalizes during joins so Path::new(".").join(path) is actually a
no-op.
2014-01-19 05:56:35 -08:00
bors
52f1d905b0 auto merge of #11635 : thestinger/rust/zero-size-alloc, r=alexcrichton
The `malloc` family of functions may return a null pointer for a
zero-size allocation, which should not be interpreted as an
out-of-memory error.

If the implementation does not return a null pointer, then handling
this will result in memory savings for zero-size types.

This also switches some code to `malloc_raw` in order to maintain a
centralized point for handling out-of-memory in `rt::global_heap`.

Closes #11634
2014-01-19 04:31:53 -08:00
musitdev
aeb541674c extra::json: add documentation and examples 2014-01-19 11:56:27 +01:00
bors
53733c87b6 auto merge of #11633 : chromatic/rust/master, r=alexcrichton 2014-01-19 02:01:49 -08:00
musitdev
339946cf2f extra::json: add documentation and examples 2014-01-19 09:39:07 +01:00
bors
6d58c70fb3 auto merge of #11628 : alexcrichton/rust/issue-11593, r=brson
Turns out we were just forgetting to encode the privacy for trais, and
everything without privacy defaults to public!

Closes #11593
2014-01-19 00:36:48 -08:00
musitdev
1a8a901f86 Squashed commit of the following:
commit d00623d60afd460755b749ad5f94935f756f29d2
Author: musitdev <philippe.delrieu@free.fr>
Date:   Sat Jan 4 22:31:40 2014 +0100

    correct last comments.

commit ef09d6b6d1eebbd7c713c9dad96ed7bfc19dd884
Author: musitdev <philippe.delrieu@free.fr>
Date:   Thu Jan 2 20:28:53 2014 +0100

    update with the last remarks.

commit 46a028fe1fcdc2a7dcdd78a63001793eff614349
Author: musitdev <philippe.delrieu@free.fr>
Date:   Thu Jan 2 10:17:18 2014 +0100

    wrap example code in main function.

commit 2472901929bef09786b7aef8ca7c89fbe67d8e3e
Author: musitdev <philippe.delrieu@free.fr>
Date:   Mon Dec 30 19:32:46 2013 +0100

    Correct code to compile.

commit ed96b2223176781743e984af0e19abcb82150f1f
Author: musitdev <philippe.delrieu@free.fr>
Date:   Thu Dec 5 11:32:28 2013 +0100

    Correct the comment based on the PR comment.
    Change init call to new to reflect last change.

commit 38b0390c3533a16f822a6df5f90b907bd8ed6edc
Author: musitdev <philippe.delrieu@free.fr>
Date:   Wed Dec 4 22:34:25 2013 +0100

    correct from_utf8_owned call.

commit 08bed4c5f4fadf93ec457b605a1a1354323d2f5c
Author: musitdev <philippe.delrieu@free.fr>
Date:   Wed Dec 4 22:12:41 2013 +0100

    correct code '''

commit 02fddcbe2ab37fe842872691105bc4c5cff5abb5
Author: musitdev <philippe.delrieu@free.fr>
Date:   Wed Dec 4 13:25:54 2013 +0100

    correct typing error

commit b26830b8ddb49f551699e791832ed20640a0fafc
Author: musitdev <philippe.delrieu@free.fr>
Date:   Wed Dec 4 13:18:39 2013 +0100

    pass make check

commit e87c4f53286122efd0d2364ea45600d4fa4d5744
Author: musitdev <philippe.delrieu@free.fr>
Date:   Wed Dec 4 10:47:24 2013 +0100

    Add Json example and documentation.
2014-01-19 08:56:28 +01:00
Huon Wilson
6f3c202d3e rustc: check instantiability of fixed length vectors properly.
Previously, they were treated like ~[] and &[] (which can have length
0), but fixed length vectors are fixed length, i.e. we know at compile
time if it's possible to have length zero (which is only for [T, .. 0]).

Fixes #11659.
2014-01-19 18:48:20 +11:00
bors
7d79cc73fb auto merge of #11616 : huonw/rust/ast_map, r=pnkfelix
NodeIds are sequential integers starting at zero, so we can achieve some
memory savings by just storing the items all in a line in a vector.

The occupancy for typical crates seems to be 75-80%, so we're already
more efficient than a HashMap (maximum occupancy 75%), not even counting
the extra book-keeping that HashMap does.
2014-01-18 23:16:33 -08:00
Steven Fackler
dac3c53ee1 Avoid unused variable warning in quote_*!
The provided span isn't used in all cases (namely primitives).
2014-01-18 23:00:50 -08:00
bors
6d55211700 auto merge of #11615 : adwhit/rust/master, r=cmr
This is my first patch so feedback appreciated!

Bug when initialising `bitv:Bitv::new(int,bool)` when `bool=true`. It created a `Bitv` with underlying representation `!0u` rather than the actual desired bit layout ( e.g. `11111111` instead of `00001111`). This works OK because a size attribute is included which keeps access to legal bounds.  However when using `BitvSet::from_bitv(Bitv)`, we then find that `bitvset.contains(i)` can return true when `i` should not in fact be in the set.

```
let bs = BitvSet::from_bitv(Bitv::new(100, true));
assert!(!bs.contains(&127)) //fails
```

The fix is to create the correct representation by treating various cases separately and using a bitshift `(1<<nbits) - 1` to generate correct number of `1`s where necessary.
2014-01-18 21:56:34 -08:00
Huon Wilson
a68172cddf rustc: remove the explicit count from the lang_item macro.
We can use a secondary macro to calculate the count from the information
we're already having to pass to the lang items macro.
2014-01-19 14:15:57 +11:00
bors
dbce62c6bb auto merge of #11311 : hdima/rust/vim-syntax-spell-check, r=cmr
Add `@Spell` clusters to Vim syntax highlighting file to do spell checking only inside comments and strings
2014-01-18 19:06:37 -08:00
Brian Anderson
2d656d6285 Pass the correct --target flag when type checking pretty-printed code in tests
This makes pretty print tests that have aux crates work correctly on Android.
Without they generate errors ICEs about incorrect node ids. Not sure why.
2014-01-18 18:23:46 -08:00
Huon Wilson
68517a2cca syntax: convert ast_map to use a SmallIntMap.
NodeIds are sequential integers starting at zero, so we can achieve some
memory savings by just storing the items all in a line in a vector.

The occupancy for typical crates seems to be 75-80%, so we're already
more efficient than a HashMap (maximum occupancy 75%), not even counting
the extra book-keeping that HashMap does.
2014-01-19 12:56:26 +11:00
bors
c0578b4a41 auto merge of #11632 : brson/rust/issue-11602, r=huonw 2014-01-18 16:46:39 -08:00
Brian Anderson
2ff5963b9d xfail more external syntax extension tests on android 2014-01-18 16:32:33 -08:00
bors
d0f6ef080b auto merge of #11620 : alexcrichton/rust/rustc-silent, r=brson
This commit re-works how the monitor() function works and how it both receives
and transmits errors. There are a few cases in which the compiler can abort:

1. A normal compiler error. In this case, the compiler raises a FatalError as
   the failure value of the task. If this happens, then the monitor task does
   nothing. It ignores all stderr output of the child task and it also
   suppresses the failure message of the main task itself. This means that on a
   normal compiler error just the error message itself is printed.

2. A normal internal compiler error. These are invoked from sess.span_bug() and
   friends. In these cases, they follow the same path (raising a FatalError),
   but they will also print an ICE message which has a URL to go report a bug.

3. An actual compiler bug. This happens whenever anything calls fail!() instead
   of going through the session itself. In this case, we print out stuff about
   RUST_LOG=2 and we by default capture all stderr and print via warn!() so it's
   only printed out with the RUST_LOG var set.
2014-01-18 14:36:41 -08:00
bors
b5a110c7fe auto merge of #11607 : alexcrichton/rust/issue-9957, r=cmr
For `use` statements, this means disallowing qualifiers when in functions and
disallowing `priv` outside of functions.

For `extern mod` statements, this means disallowing everything everywhere. It
may have been envisioned for `pub extern mod foo` to be a thing, but it
currently doesn't do anything (resolve doesn't pick it up), so better to err on
the side of forwards-compatibility and forbid it entirely for now.

Closes #9957
2014-01-18 13:01:47 -08:00
bors
c5d05acf39 auto merge of #11606 : alexcrichton/rust/issue-9259, r=brson
This must have been fixed in some recent trans refactor/rewrite, hurray!

Closes #9259
2014-01-18 11:32:06 -08:00
Flavio Percoco
3830a3b4f2 Replace old pow_with_uint with the new pow func
There was an old and barely used implementation of pow, which expected
both parameters to be uint and required more traits to be implemented.
Since a new implementation for `pow` landed, I'm proposing to remove
this old impl in favor of the new one.

The benchmark shows that the new implementation is faster than the one
being removed:

test num::bench::bench_pow_function               ..bench:      9429 ns/iter (+/- 2055)
test num::bench::bench_pow_with_uint_function     ...bench:     28476 ns/iter (+/- 2202)
2014-01-18 20:17:12 +01:00
Flavio Percoco
aaf8ba7c51 Added benchmark for pow and pow_with_uint 2014-01-18 20:16:30 +01:00
Alex Crichton
4d5da45e7e Add a test for closed issue #9259
This must have been fixed in some recent trans refactor/rewrite, hurray!

Closes #9259
2014-01-18 11:01:15 -08:00
Alex Crichton
d37e2f79cc Disallow implementation of cross-crate priv traits
Turns out we were just forgetting to encode the privacy for trais, and
everything without privacy defaults to public!

Closes #11593
2014-01-18 10:58:01 -08:00
Alex Crichton
2784313344 rustc: Clean up error reporting
This commit re-works how the monitor() function works and how it both receives
and transmits errors. There are a few cases in which the compiler can abort:

1. A normal compiler error. In this case, the compiler raises a FatalError as
   the failure value of the task. If this happens, then the monitor task does
   nothing. It ignores all stderr output of the child task and it also
   suppresses the failure message of the main task itself. This means that on a
   normal compiler error just the error message itself is printed.

2. A normal internal compiler error. These are invoked from sess.span_bug() and
   friends. In these cases, they follow the same path (raising a FatalError),
   but they will also print an ICE message which has a URL to go report a bug.

3. An actual compiler bug. This happens whenever anything calls fail!() instead
   of going through the session itself. In this case, we print out stuff about
   RUST_LOG=2 and we by default capture all stderr and print via warn!() so it's
   only printed out with the RUST_LOG var set.
2014-01-18 10:49:32 -08:00
Alex Crichton
4a78364d49 Forbid unnecessary visibility on view items
For `use` statements, this means disallowing qualifiers when in functions and
disallowing `priv` outside of functions.

For `extern mod` statements, this means disallowing everything everywhere. It
may have been envisioned for `pub extern mod foo` to be a thing, but it
currently doesn't do anything (resolve doesn't pick it up), so better to err on
the side of forwards-compatibility and forbid it entirely for now.

Closes #9957
2014-01-18 10:46:32 -08:00
Dmitry Vasiliev
99cde8482e Ignore all newline characters in Base64 decoder
Ignore all newline characters in Base64 decoder to make it compatible
with other Base64 decoders.
2014-01-18 19:18:44 +01:00
Erick Tryzelaar
f13086f457 Expose platform independent path separators 2014-01-18 09:19:10 -08:00
bors
bf07c80838 auto merge of #11629 : brson/rust/whattayaknowitsmoreandroidfixes, r=cmr 2014-01-18 07:36:43 -08:00
bors
2952685917 auto merge of #11622 : bjz/rust/simplify-primitive-trait, r=brson
As part of #10387, this removes the `Primitive::{bits, bytes, is_signed}` methods and removes the trait's operator trait constraints for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES`statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888.

- The operator trait constraints are already covered by the `Num` trait.
2014-01-18 05:36:47 -08:00
bors
88dd987df0 auto merge of #11605 : alexcrichton/rust/issue-9582, r=brson
Closes #9582
2014-01-18 01:06:47 -08:00
bors
1da2962e2e auto merge of #11001 : DaGenix/rust/iter-renaming, r=alexcrichton
Most Iterators renamed to make their naming more consistent. Most significantly, the Iterator and Iter suffixes have been completely removed.
2014-01-17 23:41:45 -08:00
Kevin Ballard
b3c93b34f3 Make WindowsPath::new("C:foo").root_path() return Some("C:") 2014-01-17 23:07:53 -08:00
Brian Anderson
50f4a0ec74 Move macro-crate to run-pass-fulldeps and force-host the aux build 2014-01-17 22:34:58 -08:00
Brian Anderson
4a3a61bd83 xfail shootout-reverse-complement on android 2014-01-17 22:34:58 -08:00
Palmer Cox
3fd8c8b330 Rename iterators for consistency
Rename existing iterators to get rid of the Iterator suffix and to
give them names that better describe the things being iterated over.
2014-01-18 01:15:15 -05:00
bors
0f8c29f0b4 auto merge of #11086 : metajack/rust/rustpkg-new-crateid-syntax, r=cmr
...arts.

This fixes a bug where new syntax crate IDs would cause rustpkg to fail to
build crates.
2014-01-17 22:06:46 -08:00
Steven Fackler
1e20960f79 Actually force a / in the path for ext crates
If the library is in the working directory, its path won't have a "/"
which will cause dlopen to search /usr/lib etc. It turns out that Path
auto-normalizes during joins so Path::new(".").join(path) is actually a
no-op.
2014-01-17 21:51:38 -08:00
Daniel Micay
ae2a5ecbf6 handle zero-size allocations correctly
The `malloc` family of functions may return a null pointer for a
zero-size allocation, which should not be interpreted as an
out-of-memory error.

If the implementation does not return a null pointer, then handling
this will result in memory savings for zero-size types.

This also switches some code to `malloc_raw` in order to maintain a
centralized point for handling out-of-memory in `rt::global_heap`.

Closes #11634
2014-01-17 23:41:31 -05:00
bors
c58d2bacb7 auto merge of #11503 : FlaPer87/rust/master, r=huonw
The patch adds the missing pow method for all the implementations of the
Integer trait. This is a small addition that will most likely be
improved by the work happening in #10387.

Fixes #11499
2014-01-17 20:36:47 -08:00
Brian Anderson
f52bd5e4b7 rustc: Feature gate log_syntax!. Closes #11602 2014-01-17 20:10:47 -08:00
bors
f4498c71e2 auto merge of #11497 : huonw/rust/trie-internal-iter, r=alexcrichton
This stores the stack of iterators inline (we have a maximum depth with
`uint` keys), and then uses direct pointer offsetting to manipulate it,
in a blazing fast way:

Before:

    bench_iter_large          ... bench:     43187 ns/iter (+/- 3082)
    bench_iter_small          ... bench:       618 ns/iter (+/- 288)

After:

    bench_iter_large          ... bench:     13497 ns/iter (+/- 1575)
    bench_iter_small          ... bench:       220 ns/iter (+/- 91)

Also, removes `.each_{key,value}_reverse` as an offering to
placate the gods of external iterators for my heinous sin of 
attempting to add new internal ones (in a previous version of this
PR).
2014-01-17 17:56:41 -08:00
chromatic
0578c15abd Fixed typos in comments of librustc backend. 2014-01-17 17:14:47 -08:00
bors
2ff358c062 auto merge of #11618 : alexcrichton/rust/force-host, r=brson
The new macro loading infrastructure needs the ability to force a
procedural-macro crate to be built with the host architecture rather than the
target architecture (because the compiler is just about to dlopen it).
2014-01-17 15:46:40 -08:00
Huon Wilson
0148055a56 std::trie: use unsafe code to give a 3x speed up to the iterator.
This stores the stack of iterators inline (we have a maximum depth with
`uint` keys), and then uses direct pointer offsetting to manipulate it,
in a blazing fast way:

Before:

    bench_iter_large          ... bench:     43187 ns/iter (+/- 3082)
    bench_iter_small          ... bench:       618 ns/iter (+/- 288)

After:

    bench_iter_large          ... bench:     13497 ns/iter (+/- 1575)
    bench_iter_small          ... bench:       220 ns/iter (+/- 91)
2014-01-18 10:46:11 +11:00
Huon Wilson
f0c554d0d8 std::trie: remove each_{key,value}_reverse internal iterators.
This are *trivial* to reimplement in terms of each_reverse if that extra
little bit of performance is needed.
2014-01-18 10:45:34 +11:00
Brendan Zabarauskas
f125b71c00 Add FIXME comments regarding issue #11526. 2014-01-18 09:13:10 +11:00
Brendan Zabarauskas
472dfe74b3 Simplify std::num::Primitive trait definition
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888.

- The operator trait constraints are already covered by the `Num` trait.
2014-01-18 09:12:53 +11:00
Jack Moffitt
7fb712e269 Warning police. 2014-01-17 14:45:07 -07:00
Jack Moffitt
f7088edc03 Change some rustpkg tests to use new crate_id syntax. 2014-01-17 14:45:07 -07:00
Jack Moffitt
363fa51c66 Use the libsyntax PkgId parser in Rustpkg, but keep Rustpkg's version smarts.
This fixes a bug where new syntax crate IDs would cause rustpkg to fail to
build crates.
2014-01-17 14:45:07 -07:00
bors
aa67e13498 auto merge of #11604 : alexcrichton/rust/issue-11162, r=brson
Apparently this isn't necessary, and it's just causing problems.

Closes #11162
2014-01-17 13:36:43 -08:00
bors
9bf85a250c auto merge of #11598 : alexcrichton/rust/io-export, r=brson
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered
  private modules
* Remove with_mem_writer
* Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)

cc #11119
2014-01-17 12:02:07 -08:00
Alex Crichton
bd469341eb test: Add the ability to force a host target
The new macro loading infrastructure needs the ability to force a
procedural-macro crate to be built with the host architecture rather than the
target architecture (because the compiler is just about to dlopen it).
2014-01-17 11:13:22 -08:00
Alex Crichton
295b46fc08 Tweak the interface of std::io
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered
  private modules
* Remove with_mem_writer
* Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)
2014-01-17 10:00:47 -08:00
bors
4098327b1f auto merge of #11585 : nikomatsakis/rust/issue-3511-rvalue-lifetimes, r=pcwalton
Major changes:

- Define temporary scopes in a syntax-based way that basically defaults
  to the innermost statement or conditional block, except for in
  a `let` initializer, where we default to the innermost block. Rules
  are documented in the code, but not in the manual (yet).
  See new test run-pass/cleanup-value-scopes.rs for examples.
- Refactors Datum to better define cleanup roles.
- Refactor cleanup scopes to not be tied to basic blocks, permitting
  us to have a very large number of scopes (one per AST node).
- Introduce nascent documentation in trans/doc.rs covering datums and
  cleanup in a more comprehensive way.

r? @pcwalton
2014-01-17 07:56:45 -08:00
Niko Matsakis
b520c2f280 Adjust comments in test case 2014-01-17 10:47:29 -05:00
Niko Matsakis
483ae32189 Update years on more license headers 2014-01-17 10:18:39 -05:00
Niko Matsakis
578b9d1d97 Update year on license header 2014-01-17 10:13:53 -05:00
Huon Wilson
4be3262058 syntax::ext: replace span_fatal with span_err in many places.
This means that compilation continues for longer, and so we can see more
errors per compile. This is mildly more user-friendly because it stops
users having to run rustc n times to see n macro errors: just run it
once to see all of them.
2014-01-18 02:03:04 +11:00
Flavio Percoco
ed7e576d9c Add a generic power function
The patch adds a `pow` function for types implementing `One`, `Mul` and
`Clone` trait.

The patch also renames f32 and f64 pow into powf in order to still have
a way to easily have float powers. It uses llvms intrinsics.

The pow implementation for all num types uses the exponentiation by
square.

Fixes bug #11499
2014-01-17 15:41:26 +01:00
bors
1e1871f35e auto merge of #11479 : khodzha/rust/peekable_empty, r=brson
to fix https://github.com/mozilla/rust/issues/11218
2014-01-17 06:32:01 -08:00
Niko Matsakis
b1da8c618f Change expansion of for loop to use a match statement
so that the "innermost enclosing statement" used for rvalue
temporaries matches up with user expectations
2014-01-17 08:30:06 -05:00
Niko Matsakis
8f16356e5f Extend temporary lifetimes if there is a ref in an enum binding
too.

Previously I had omitted this case since function calls don't get the same
treatment on the RHS, but it's different on the pattern and is more consistent
-- the goal is to identify `let` statements where `ref` bindings create
interior pointers.
2014-01-17 08:10:42 -05:00
Niko Matsakis
56f4d1831a Link lifetimes in let patterns just as we do for match patterns 2014-01-17 08:04:38 -05:00
bors
7d75bbf50d auto merge of #11601 : dguenther/rust/fix_test_summary, r=brson
The test run summary currently prints the wrong number of tests run. This PR fixes it by adding a newline to the log output, and also adds support for counting bench runs.

Closes #11381
2014-01-17 04:11:46 -08:00
Alex Whitney
32408a6e32 Fixed bug when initialising bitv from bool=true 2014-01-17 12:07:32 +00:00
bors
93fb12e3d0 auto merge of #11498 : c-a/rust/optimize_vuint_at, r=alexcrichton
Use a lookup table, SHIFT_MASK_TABLE, that for every possible four
bit prefix holds the number of times the value should be right shifted and what
the right shifted value should be masked with. This way we can get rid of the
branches which in my testing gives approximately a 2x speedup.

Timings on Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz

-- Before --
running 5 tests
test ebml::tests::test_vuint_at ... ok
test ebml::bench::vuint_at_A_aligned          ... bench:       494 ns/iter (+/- 3)
test ebml::bench::vuint_at_A_unaligned        ... bench:       494 ns/iter (+/- 4)
test ebml::bench::vuint_at_D_aligned          ... bench:       467 ns/iter (+/- 5)
test ebml::bench::vuint_at_D_unaligned        ... bench:       467 ns/iter (+/- 5)

-- After --
running 5 tests
test ebml::tests::test_vuint_at ... ok
test ebml::bench::vuint_at_A_aligned ... bench: 181 ns/iter (+/- 2)
test ebml::bench::vuint_at_A_unaligned ... bench: 192 ns/iter (+/- 1)
test ebml::bench::vuint_at_D_aligned ... bench: 181 ns/iter (+/- 3)
test ebml::bench::vuint_at_D_unaligned ... bench: 197 ns/iter (+/- 6)
2014-01-17 00:01:56 -08:00
Niko Matsakis
0c916c58e8 Make main() public in uninit-empty-types 2014-01-17 01:02:16 -05:00
klutzy
b33d2fede8 syntax::ast: Remove/Recover tests
`xorpush_test` and `test_marksof` are at `syntax::ast_util`.

Fixes #7952
2014-01-17 13:27:47 +09:00
klutzy
ec6aba37d7 rustc::metadata: Remove trait FileSearch 2014-01-17 13:27:47 +09:00
klutzy
f30a9b3d5b rustc::driver: Capitalize structs and enums
driver::session::crate_metadata is unused; removed.
2014-01-17 13:27:47 +09:00
bors
80a3f453db auto merge of #11151 : sfackler/rust/ext-crate, r=alexcrichton
This is a first pass on support for procedural macros that aren't hardcoded into libsyntax. It is **not yet ready to merge** but I've opened a PR to have a chance to discuss some open questions and implementation issues.

Example
=======
Here's a silly example showing off the basics:

my_synext.rs
```rust
#[feature(managed_boxes, globs, macro_registrar, macro_rules)];

extern mod syntax;

use syntax::ast::{Name, token_tree};
use syntax::codemap::Span;
use syntax::ext::base::*;
use syntax::parse::token;

#[macro_export]
macro_rules! exported_macro (() => (2))

#[macro_registrar]
pub fn macro_registrar(register: |Name, SyntaxExtension|) {
    register(token::intern(&"make_a_1"),
        NormalTT(@SyntaxExpanderTT {
            expander: SyntaxExpanderTTExpanderWithoutContext(expand_make_a_1),
            span: None,
        } as @SyntaxExpanderTTTrait,
        None));
}

pub fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[token_tree]) -> MacResult {
    if !tts.is_empty() {
        cx.span_fatal(sp, "make_a_1 takes no arguments");
    }
    MRExpr(quote_expr!(cx, 1i))
}
```

main.rs:
```rust
#[feature(phase)];

#[phase(syntax)]
extern mod my_synext;

fn main() {
    assert_eq!(1, make_a_1!());
    assert_eq!(2, exported_macro!());
}
```

Overview
=======
Crates that contain syntax extensions need to define a function with the following signature and annotation:
```rust
#[macro_registrar]
pub fn registrar(register: |ast::Name, ext::base::SyntaxExtension|) { ... }
```
that should call the `register` closure with each extension it defines. `macro_rules!` style macros can be tagged with `#[macro_export]` to be exported from the crate as well.

Crates that wish to use externally loadable syntax extensions load them by adding the `#[phase(syntax)]` attribute to an `extern mod`. All extensions registered by the specified crate are loaded with the same scoping rules as `macro_rules!` macros. If you want to use a crate both for syntax extensions and normal linkage, you can use `#[phase(syntax, link)]`.

Open questions
===========
* ~~Does the `macro_crate` syntax make sense? It wraps an entire `extern mod` declaration which looks a bit weird but is nice in the sense that the crate lookup logic can be identical between normal external crates and external macro crates. If the `extern mod` syntax, changes, this will get it for free, etc.~~ Changed to a `phase` attribute.
* ~~Is the magic name `macro_crate_registration` the right way to handle extension registration? It could alternatively be handled by a function annotated with `#[macro_registration]` I guess.~~ Switched to an attribute.
* The crate loading logic lives inside of librustc, which means that the syntax extension infrastructure can't directly access it. I've worked around this by passing a `CrateLoader` trait object from the driver to libsyntax that can call back into the crate loading logic. It should be possible to pull things apart enough that this isn't necessary anymore, but it will be an enormous refactoring project. I think we'll need to create a couple of new libraries: libsynext libmetadata/ty and libmiddle.
* Item decorator extensions can be loaded but the `deriving` decorator itself can't be extended so you'd need to do e.g. `#[deriving_MyTrait] #[deriving(Clone)]` instead of `#[deriving(MyTrait, Clone)]`. Is this something worth bothering with for now?

Remaining work
===========
- [x] ~~There is not yet support for rustdoc downloading and compiling referenced macro crates as it does for other referenced crates. This shouldn't be too hard I think.~~
- [x] ~~This is not testable at stage1 and sketchily testable at stages above that. The stage *n* rustc links against the stage *n-1* libsyntax and librustc. Unfortunately, crates in the test/auxiliary directory link against the stage *n* libstd, libextra, libsyntax, etc. This causes macro crates to fail to properly dynamically link into rustc since names end up being mangled slightly differently. In addition, when rustc is actually installed onto a system, there are actually do copies of libsyntax, libstd, etc: the ones that user code links against and a separate set from the previous stage that rustc itself uses. By this point in the bootstrap process, the two library versions *should probably* be binary compatible, but it doesn't seem like a sure thing. Fixing this is apparently hard, but necessary to properly cross compile as well and is being tracked in #11145.~~ The offending tests are ignored during `check-stage1-rpass` and `check-stage1-cfail`. When we get a snapshot that has this commit, I'll look into how feasible it'll be to get them working on stage1.
- [x] ~~`macro_rules!` style macros aren't being exported. Now that the crate loading infrastructure is there, this should just require serializing the AST of the macros into the crate metadata and yanking them out again, but I'm not very familiar with that part of the compiler.~~
- [x] ~~The `macro_crate_registration` function isn't type-checked when it's loaded. I poked around in the `csearch` infrastructure a bit but didn't find any super obvious ways of checking the type of an item with a certain name. Fixing this may also eliminate the need to `#[no_mangle]` the registration function.~~ Now that the registration function is identified by an attribute, typechecking this will be like typechecking other annotated functions.
- [x] ~~The dynamic libraries that are loaded are never unloaded. It shouldn't require too much work to tie the lifetime of the `DynamicLibrary` object to the `MapChain` that its extensions are loaded into.~~
- [x] ~~The compiler segfaults sometimes when loading external crates. The `DynamicLibrary` reference and code objects from that library are both put into the same hash table. When the table drops, due to the random ordering the library sometimes drops before the objects do. Once #11228 lands it'll be easy to fix this.~~
2014-01-16 16:36:53 -08:00
Niko Matsakis
5e7657fafb Distinguish zero-size types from those that we return as void 2014-01-16 19:10:17 -05:00