Commit Graph

23066 Commits

Author SHA1 Message Date
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
Niko Matsakis
76c90283ce Fix uninit() intrinsic when used with empty types 2014-01-16 18:47:42 -05:00
Niko Matsakis
fd318300cf Fix test to account for new temporary lifetime rules, which cause the channel to be dropped prematurely. 2014-01-16 18:47:22 -05:00
Steven Fackler
328b47d837 Load macros from external modules 2014-01-16 15:01:48 -08:00
Niko Matsakis
4b52d899ff Further refine treatment of voidish arrays 2014-01-16 16:29:52 -05:00
Alex Crichton
afa392a840 Forbid coercing unsafe functions to closures
Closes #9582
2014-01-16 12:20:59 -08:00
Alex Crichton
11dcd9a097 Don't run 'ar s' on OSX
Apparently this isn't necessary, and it's just causing problems.

Closes #11162
2014-01-16 12:18:22 -08:00
Niko Matsakis
14b0abfd82 Consider all zero-sized data structures to be voidish, bypassing some "quirky" parts of LLVM (see e.g. LLVM bug 9900) but also generating better code 2014-01-16 15:11:22 -05:00
bors
61416626ac auto merge of #11571 : derekchiang/rust/fix-task-docs, r=alexcrichton
There might be a reason, but I failed to see why these comments couldn't be proper rust docs.
2014-01-16 11:26:40 -08:00
bors
9434e7c6cb auto merge of #11599 : sanxiyn/rust/accurate-span-3, r=luqmana 2014-01-16 09:01:49 -08:00
Derek Guenther
8f4edf9bf8 Update test run summary 2014-01-16 09:36:34 -06:00
bors
fa91446b2b auto merge of #11597 : sfackler/rust/err-enums, r=alexcrichton
An enum allows callers to deal with errors in a more reasonable way.
2014-01-16 07:06:58 -08:00
bors
f63a7f598a auto merge of #11596 : derekchiang/rust/fix-libnative-docs, r=alexcrichton 2014-01-16 05:51:44 -08:00
Seo Sanghyeon
1f5dc552d6 Correct span for ExprCall and ExprIndex 2014-01-16 22:45:01 +09:00
Niko Matsakis
7ff6b094fb Remove typo 2014-01-16 05:56:56 -05:00
bors
6361c1dee5 auto merge of #11579 : kballard/rust/windows-path-join, r=erickt
WindowsPath::new("C:").join("a") produces r"C:". This is incorrect.
It should produce "C:a".
2014-01-16 00:51:44 -08:00
Steven Fackler
9fe5d1620c Stop returning error strings in From{Base64,Hex}
An enum allows callers to deal with errors in a more reasonable way.
2014-01-15 23:15:04 -08:00
Derek Chiang
0e94ae4d8a Fix some docs in std::rt::task 2014-01-16 14:24:04 +08:00
Derek Chiang
f98f76e3a7 Fixing a typo: bookeeping -> bookkeeping 2014-01-16 14:17:56 +08:00
bors
793f740c0a auto merge of #11575 : pcwalton/rust/parse-substrs, r=alexcrichton
This was used by the quasiquoter.

r? @alexcrichton
2014-01-15 21:51:42 -08:00
bors
6708558c34 auto merge of #11548 : bjz/rust/bitwise, r=alexcrichton
One less trait in `std::num` and three less exported in the prelude.

cc. #10387
2014-01-15 20:36:48 -08:00
bors
bf2ab22cd0 auto merge of #11574 : neeee/rust/master, r=alexcrichton
Reverted according to https://github.com/mozilla/rust/issues/11458#issuecomment-32269477. Fixes #11458.
2014-01-15 19:06:45 -08:00
bors
a5ed0c58cb auto merge of #11565 : mozilla/rust/snapshot, r=huonw 2014-01-15 17:46:42 -08:00
Niko Matsakis
84f33fb134 Cleanup trait callees 2014-01-15 20:31:20 -05:00
Brendan Zabarauskas
1dd6906db2 Merge Bitwise and BitCount traits and remove from prelude, along with Bounded
One less trait in std::num, and three less exported in the prelude.
2014-01-16 11:51:33 +11:00
Niko Matsakis
6badef49fe Remove FIXMEs and add license 2014-01-15 19:44:38 -05:00
Niko Matsakis
e71571a3cd Use as_slice() method on option 2014-01-15 19:35:38 -05:00
bors
36971217aa auto merge of #11568 : FlaPer87/rust/even, r=alexcrichton
This implementation should be a bit more optimal than calling `self.is_multiple_of(&2)`
2014-01-15 16:02:01 -08:00
Niko Matsakis
419ac4a1b8 Issue #3511 - Rationalize temporary lifetimes.
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.
2014-01-15 18:34:38 -05:00
bors
149fc76698 auto merge of #11550 : alexcrichton/rust/noinline, r=thestinger
The failure functions are generic, meaning they're candidates for getting
inlined across crates. This has been happening, leading to monstrosities like
that found in #11549. I have verified that the codegen is *much* better now that
we're not inlining the failure path (the slow path).
2014-01-15 13:51:50 -08:00
Kevin Ballard
c57920b37b path: Fix joining Windows path when the receiver is "C:"
WindowsPath::new("C:").join("a") produces r"C:\a". This is incorrect.
It should produce "C:a".
2014-01-15 12:53:56 -08:00
bors
7ce3386511 auto merge of #11112 : alexcrichton/rust/issue-11087, r=brson
This should allow callers to know whether the channel was empty or disconnected
without having to block.

Closes #11087
2014-01-15 12:37:00 -08:00
Carl-Anton Ingmarsson
f4c9ed42aa fixup! ebml::extra: Optimize reader::vuint_at() 2014-01-15 20:58:41 +01:00
Alex Crichton
adb895a34f Allow more "error" values in try_recv()
This should allow callers to know whether the channel was empty or disconnected
without having to block.

Closes #11087
2014-01-15 11:21:56 -08:00
bors
f60d937dd9 auto merge of #11543 : thestinger/rust/gc, r=cmr
This type isn't yet very useful since it only pretends cycles won't be
a problem. Anyone using it should be made aware that they're going to
leak.
2014-01-15 11:21:45 -08:00
Patrick Walton
ff6c0af15b libsyntax: Remove the obsolete ability to parse from substrings.
This was used by the quasiquoter.
2014-01-15 10:59:48 -08:00
Flavio Percoco
515978d1bd Use the least significant beat to determine if int/uint is even 2014-01-15 19:11:00 +01:00
lucy
3b32ea8c93 Revert "show options for -W help and -W". Fixes #11458.
This reverts commit 1009c21ad7.
2014-01-15 18:38:10 +01:00
Alex Crichton
7a37294acc Add a configure to disable libstd version injection
We'll use this when building snapshots so we can upgrade freely, but all
compilers will inject a version by default.
2014-01-15 08:22:16 -08:00
bors
7bebdbd968 auto merge of #11561 : eddyb/rust/moar-inlines, r=pcwalton 2014-01-15 06:26:38 -08:00
Daniel Micay
29840addd4 remove the concept of managed-unique from libstd
Closes #11545
2014-01-15 08:22:59 -05:00
Daniel Micay
197fe67e11 register snapshots 2014-01-15 08:22:56 -05:00
bors
180ac0cc07 auto merge of #11556 : am0d/rust/docs, r=huonw 2014-01-15 05:01:47 -08:00
bors
b549b08ca3 auto merge of #11557 : brson/rust/anotherandroidfix, r=thestinger 2014-01-15 03:36:43 -08:00
Eduard Burtescu
7ca3bea5bf libstd: Added more #[inline] annotations and replaced uses of libc::abort with the intrinsic. 2014-01-15 11:45:12 +02:00
bors
29070c3bee auto merge of #11535 : thestinger/rust/header, r=alexcrichton
Unique pointers and vectors currently contain a reference counting
header when containing a managed pointer.

This `{ ref_count, type_desc, prev, next }` header is not necessary and
not a sensible foundation for tracing. It adds needless complexity to
library code and is responsible for breakage in places where the branch
 has been left out.

The `borrow_offset` field can now be removed from `TyDesc` along with
the associated handling in the compiler.

Closes #9510
Closes #11533
2014-01-14 23:01:51 -08:00
Alex Crichton
86c60b68f9 Flag failure functions as inline(never)
The failure functions are generic, meaning they're candidates for getting
inlined across crates. This has been happening, leading to monstrosities like
that found in #11549. I have verified that the codegen is *much* better now that
we're not inlining the failure path (the slow path).
2014-01-14 22:52:03 -08:00
bors
e063e96ec9 auto merge of #11547 : b1nd/rust/rust-doc, r=alexcrichton
closes #10535
2014-01-14 20:56:39 -08:00
Brian Anderson
6232290f73 extra: Ignore time tests on android correctly 2014-01-14 19:57:59 -08:00
a_m0d
e9c30ebaaf Mark LineIterator as public so its docs get generated. 2014-01-14 22:13:54 -05:00
Daniel Micay
77758f0b5e add implementation of Repr for ~[T] 2014-01-14 22:01:44 -05:00
Daniel Micay
6809b172e0 remove borrow_offset as ~ is now free of headers 2014-01-14 22:01:44 -05:00
Daniel Micay
0e885e42b1 remove reference counting headers from ~
Unique pointers and vectors currently contain a reference counting
header when containing a managed pointer.

This `{ ref_count, type_desc, prev, next }` header is not necessary and
not a sensible foundation for tracing. It adds needless complexity to
library code and is responsible for breakage in places where the branch
has been left out.

The `borrow_offset` field can now be removed from `TyDesc` along with
the associated handling in the compiler.

Closes #9510
Closes #11533
2014-01-14 22:01:40 -05:00
b1nd
431e2bb923 Removed redundant code, improve performance
closes #10535
2014-01-15 12:09:50 +11:00
Huon Wilson
e1ebdb8790 std::trie: optimise insert slightly.
This reduces the number of moves/memcpy's we do, which makes insert
faster, especially in cases of keys with long equal prefixes (the
_low_bits tests):

Before:

    bench_insert_large                ... bench:    553966 ns/iter (+/- 64050)
    bench_insert_large_low_bits       ... bench:   1048151 ns/iter (+/- 92484)
    bench_insert_small                ... bench:    168840 ns/iter (+/- 22410)
    bench_insert_small_low_bits       ... bench:    185069 ns/iter (+/- 38332)

After:

    bench_insert_large                ... bench:    422132 ns/iter (+/- 35112)
    bench_insert_large_low_bits       ... bench:    339083 ns/iter (+/- 34421)
    bench_insert_small                ... bench:    134539 ns/iter (+/- 15254)
    bench_insert_small_low_bits       ... bench:     88775 ns/iter (+/- 5746)
2014-01-15 12:03:21 +11:00
Huon Wilson
6b5e63ff2d std::trie: add benchmarks for insert. 2014-01-15 11:32:53 +11:00
bors
dd8b011319 auto merge of #11521 : dguenther/rust/hide_libdir_relative, r=alexcrichton
Renamed `LIBDIR_RELATIVE` to `CFG_LIBDIR_RELATIVE`. It's not a configurable variable, but it looks out of place without the `CFG_` prefix.

Fixes #11420
2014-01-14 15:11:30 -08:00
Daniel Micay
f40d5b1050 add an experimental tag for Gc<T> due to cycles
This type isn't yet very useful since it only pretends cycles won't be
a problem. Anyone using it should be made aware that they're going to
leak.
2014-01-14 17:13:22 -05:00
Derek Guenther
a599d897fc Renamed LIBDIR_RELATIVE to CFG_LIBDIR_RELATIVE 2014-01-14 15:52:57 -06:00
bors
faa0b5aa61 auto merge of #11538 : eddyb/rust/llvm-attributes, r=alexcrichton 2014-01-14 13:51:34 -08:00
bors
9075025c7b auto merge of #11485 : eddyb/rust/sweep-old-rust, r=nikomatsakis 2014-01-14 12:32:11 -08:00
bors
b77a7e76a1 auto merge of #11539 : dotdash/rust/void_type_fixup, r=alexcrichton
Currently, we have c_void defined to be represented as an empty struct,
but LLVM expects C's void* to be represented as i8*. That means we
currently generate code in which LLVM doesn't recognize malloc() and
free() and can't apply certain optimization that would remove calls to
those functions.
2014-01-14 11:16:38 -08:00
Björn Steinbrink
5902263d0a Fix the representation of C void pointers in LLVM IR
Currently, we have c_void defined to be represented as an empty struct,
but LLVM expects C's void* to be represented as i8*. That means we
currently generate code in which LLVM doesn't recognize malloc() and
free() and can't apply certain optimization that would remove calls to
those functions.
2014-01-14 19:22:23 +01:00
Eduard Burtescu
8e2027a082 Add noalias and noreturn attributes in more cases. 2014-01-14 19:17:38 +02:00
bors
9dbbfb8341 auto merge of #11438 : b1nd/rust/rust-doc, r=alexcrichton
cc @cmr

Temporary change to issue #10535. Requires significant re-factoring to search completely based on the index paths. For example searching for "File::" in this fix will return no results. Still need to search completely based on path (rather than name's + types) to completely fix. Will continue to work this
2014-01-14 08:41:38 -08:00
Shamir Khodzha
4993c7c804 renamed empty() to is_empty() 2014-01-14 18:38:06 +04:00
b1nd
9a45c9d7c6 Completed patch searching for rust docs
Made temporary changes to include multiple keywords in rustdoc search

Implemented search based on multiple keywords

Added some commenting and house cleaning

Added path searching to rustdoc
2014-01-14 19:26:43 +11:00
bors
9008931125 auto merge of #11531 : brson/rust/yetmoreandroidfixes, r=alexcrichton 2014-01-13 21:51:37 -08:00
Brian Anderson
062b0fd264 std: Ignore bind error tests on android. #11530 2014-01-13 19:45:37 -08:00
Luqman Aden
d42e75883b librustc: Don't translate an expr twice when implicitly coercing to a trait object. Fixes #11197. 2014-01-13 20:52:44 -05:00
Luqman Aden
17f984c54b librustc: Don't allow use after move of implicitly coerced object. Fixes #11481. 2014-01-13 20:51:49 -05:00
bors
ab66f76254 auto merge of #11305 : pcwalton/rust/at-patterns, r=pcwalton
r? @nikomatsakis
2014-01-13 14:51:34 -08:00
Patrick Walton
119c6141f5 librustc: Remove @ pointer patterns from the language 2014-01-13 14:45:21 -08:00
Brian Anderson
54e662acbd xfail another native test on android (#11419) 2014-01-13 13:15:06 -08:00
Patrick Walton
ce358fca33 libsyntax: Make managed box @ patterns obsolete 2014-01-13 13:11:01 -08:00
bors
b8c60f906b auto merge of #11482 : fhahn/rust/issue-8005-better-error-msg-semi-last-stmt, r=alexcrichton
This is a patch for #8005, thanks @lfairy for the hint.

It seems like `block.expr` is None, if the last line of a function has a semi colon (= it ends with a statement).

@kmcallister does this error message cover the intended use cases? 
I'm not sure about the message, the wording and the span could probably be improved.
2014-01-13 11:06:41 -08:00
Florian Hahn
c74c854adc Better error message for semicolon on the last line of a function
closes #8005
2014-01-13 19:45:34 +01:00
bors
b97ace2f6b auto merge of #11513 : huonw/rust/generic-errs, r=alexcrichton
Unsuffixed literals like 1 and 1.1, and free type parameters sometimes
have to be printed in error messages, which ended up with \<V0>, \<VI0>
and \<VF0>. This change puts the words "generic" and "integer"/"float"
into the message so it's not a completely black box.
2014-01-13 09:21:41 -08:00
Huon Wilson
e25d7069b5 rustc: make error messages containing generic more self-explanatory.
Unsuffixed literals like 1 and 1.1, and free type parameters sometimes
have to be printed in error messages, which ended up with <V0>, <VI0>
and <VF0>. This change puts the words "generic" and "integer"/"float"
into the message so it's not a completely black box.
2014-01-13 22:34:50 +11:00
Yehuda Katz
8f6ffdefc3 Add Clone to TreeSet 2014-01-13 02:21:19 -08:00
bors
b93a4dac2e auto merge of #11506 : brson/rust/androidfixes, r=cmr 2014-01-12 19:36:37 -08:00
Brian Anderson
58097c1a73 xfail two tests that hang on Android (#11419) 2014-01-12 19:31:26 -08:00
Brian Anderson
46905c04f5 Bump version to 0.10-pre 2014-01-12 17:45:22 -08:00
Brendan Zabarauskas
cd248e29b1 Clean up std::num::cmath and remove stale comments 2014-01-13 10:33:54 +11:00
Brendan Zabarauskas
1246f0b094 Remove RealExt
These functions are of little utility outside a small subset of use cases. If people need them for their own projects then they can use their own bindings for libm (which aren't hard to make).
2014-01-13 10:32:50 +11:00
bors
0091a15a43 auto merge of #11502 : jhasse/rust/crate_type, r=alexcrichton
This is unnecessary and also leads to a bug: When the user specifies

```
#[crate_type = "rlib"];
```

rustpkg still creates a dylib.

Also it's good not to duplicate functionality. `build_session_options` handles this just fine.
2014-01-12 12:31:49 -08:00
Carl-Anton Ingmarsson
e52f7c9239 ebml::extra: Optimize reader::vuint_at()
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.
2014-01-12 20:25:57 +01:00
Kiet Tran
deb3ca53a8 Mark allowed dead code and lang items as live
Dead code pass now explicitly checks for `#[allow(dead_code)]` and
`#[lang=".."]` attributes on items and marks them as live if they have
those attributes. The former is done so that if we want to suppress
warnings for a group of dead functions, we only have to annotate the
"root" of the call chain.
2014-01-12 13:54:36 -05:00
Jan Niklas Hasse
e64b49d8ff Don't overwrite the options.output value from build_session_options 2014-01-12 19:16:25 +01:00
Carl-Anton Ingmarsson
1130886138 extra::ebml: Add unit test for vuint_at() 2014-01-12 13:33:52 +01:00
Carl-Anton Ingmarsson
e9b188a590 extra::ebml: Make reader::Res public
Since reader::vuint_at() returns a result of type reader::Res it makes sense
to make it public.

Due to rust's current behavior of externally referenced private structures,
https://github.com/mozilla/rust/issues/10573, you could still use the result and
assign it to a variable if you let the compiler do the type assignment,
but you could not explicitly annotate a variable to hold a reader::Res.
2014-01-12 13:33:52 +01:00
bors
1fda761e9c auto merge of #11495 : kud1ing/rust/backticks, r=huonw 2014-01-12 02:56:28 -08:00
kud1ing
871ffd1c05 more backticks 2014-01-12 10:35:10 +01:00
Jan Niklas Hasse
6ccc1e88b7 Fix indention 2014-01-12 02:36:29 +01:00
Jan Niklas Hasse
76967a008b Support linking of rlib files in rustpkg 2014-01-12 02:31:33 +01:00
Eduard Burtescu
509fc92a9b Removed remnants of @mut and ~mut from comments and the type system. 2014-01-12 02:26:04 +02:00
bors
54a85d4d67 auto merge of #11480 : SiegeLord/rust/float_base, r=cmr
This fixes the incorrect lexing of things like:

~~~rust
let b = 0o2f32;
let d = 0o4e6;
let f = 0o6e6f32;
~~~

and brings the float literal lexer in line with the description of the float literals in the manual.
2014-01-11 16:21:24 -08:00
bors
68ebe8141a auto merge of #11477 : adridu59/rust/bug-report, r=cmr
Mostly cleanups for doc and READMEs. Fixes the bug reporting link.
2014-01-11 15:01:32 -08:00
bors
db9ef28695 auto merge of #11338 : jhasse/rust/patch-rustpkgtarget, r=alexcrichton
#11243
2014-01-11 13:06:27 -08:00
Jan Niklas Hasse
e330d4b8bc Use target libraries instead of host libraries. Fixes #11243 2014-01-11 20:44:39 +01:00
SiegeLord
5ea6d0201d Tighten up float literal lexing.
Specifically, dissallow setting the number base for every type of float
literal, not only those that contain the decimal point. This is in line with
the description in the manual.
2014-01-11 14:21:59 -05:00