Commit Graph

25610 Commits

Author SHA1 Message Date
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
bors
e594acad5f auto merge of #11656 : brson/rust/omgandroid, r=cmr 2014-01-20 01:11:35 -08:00
bors
290c29c24c auto merge of #11654 : korenchkin/rust/doc_guide-testing_format, r=cmr 2014-01-19 23:51:33 -08: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
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
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
bors
1a9641bf8e auto merge of #11567 : divtxt/rust/master, r=cmr
I found the boxes diagram in the tutorial misleading about how the enum worked.

The current diagram makes it seem that there is a separate Cons struct when there is only one type of struct for the  List type, and Nil is drawn almost as if it's not consuming memory.

I'm aware of the optimization that happens for this enum which takes advantage of the fact that pointer cannot be null but this is an implementation detail and not the only one that applies here.  I can add a note below the diagram mentioning this if you like.
2014-01-18 20:31:47 -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
korenchkin
e0ea31f56c Consistent formatting for args and attrs 2014-01-18 21:45:05 +01: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
f3f2e697d8 auto merge of #11619 : adridu59/rust/patch-md, r=cmr
Noticeably necroes #10892.
Also closes #11559.

r? @alexcrichton
2014-01-18 09:01:46 -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
Adrien Tétar
14f605df21 doc: fix dangling links in rust.md
Fixes #11559 (not that the manual couldn't use a review).
2014-01-18 13:30:32 +01:00
bors
fb40bdbb62 auto merge of #11614 : remen/rust/patch-1, r=alexcrichton
#[cfg(test)] was being interpreted as starting a header
2014-01-18 03:41:42 -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