]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agolibstd: Use iotest! for for get_host_addresses.
Luqman Aden [Wed, 22 Jan 2014 21:05:28 +0000 (16:05 -0500)]
libstd: Use iotest! for for get_host_addresses.

10 years agolibnative: Implement get_host_addresses.
Luqman Aden [Wed, 22 Jan 2014 20:38:19 +0000 (15:38 -0500)]
libnative: Implement get_host_addresses.

10 years agoTypo in module tutorial
Ben Striegel [Wed, 22 Jan 2014 21:03:00 +0000 (16:03 -0500)]
Typo in module tutorial

10 years agoauto merge of #10943 : fhahn/rust/issue-7313-replace-c-types, r=alexcrichton
bors [Wed, 22 Jan 2014 19:06:24 +0000 (11:06 -0800)]
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?

10 years agoReplace C types with Rust types in libstd, closes #7313
Florian Hahn [Thu, 12 Dec 2013 21:27:26 +0000 (22:27 +0100)]
Replace C types with Rust types in libstd, closes #7313

10 years agoauto merge of #11727 : sanxiyn/rust/trailing-comma, r=alexcrichton
bors [Wed, 22 Jan 2014 17:21:25 +0000 (09:21 -0800)]
auto merge of #11727 : sanxiyn/rust/trailing-comma, r=alexcrichton

Fix #6506.
Fix #7358.

10 years agoAllow trailing commas in argument lists and tuple patterns
Seo Sanghyeon [Wed, 22 Jan 2014 16:55:53 +0000 (01:55 +0900)]
Allow trailing commas in argument lists and tuple patterns

10 years agoauto merge of #11711 : alexcrichton/rust/issue-11683, r=brson
bors [Wed, 22 Jan 2014 08:51:20 +0000 (00:51 -0800)]
auto merge of #11711 : alexcrichton/rust/issue-11683, r=brson

There's lots of fun rationale in the comments of the diff.

Closes #11683

10 years agoauto merge of #11719 : brson/rust/bleh, r=alexcrichton
bors [Wed, 22 Jan 2014 06:06:20 +0000 (22:06 -0800)]
auto merge of #11719 : brson/rust/bleh, r=alexcrichton

10 years agoxfail another external macro test on android
Brian Anderson [Wed, 22 Jan 2014 05:52:35 +0000 (21:52 -0800)]
xfail another external macro test on android

10 years agoauto merge of #11500 : jhasse/rust/patch-rlib, r=alexcrichton
bors [Wed, 22 Jan 2014 01:26:14 +0000 (17:26 -0800)]
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.

10 years agoauto merge of #11129 : SimonSapin/rust/foo-vs-foo_opt, r=alexcrichton
bors [Tue, 21 Jan 2014 23:56:16 +0000 (15:56 -0800)]
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.

10 years ago[std::str] Remove the now unused not_utf8 condition.
Simon Sapin [Mon, 23 Dec 2013 16:50:27 +0000 (17:50 +0100)]
[std::str] Remove the now unused not_utf8 condition.

10 years ago[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old from_utf8_...
Simon Sapin [Mon, 23 Dec 2013 16:45:01 +0000 (17:45 +0100)]
[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old from_utf8_owned() behavior

10 years ago[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() behavior
Simon Sapin [Mon, 23 Dec 2013 16:30:49 +0000 (17:30 +0100)]
[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() behavior

10 years ago[std::path] Rename .container_as_str_opt() to .container_as_str(), drop the old ...
Simon Sapin [Mon, 23 Dec 2013 16:15:53 +0000 (17:15 +0100)]
[std::path] Rename .container_as_str_opt() to .container_as_str(), drop the old .container_as_str() behavior

10 years ago[std::vec] Rename .remove_opt() to .remove(), drop the old .remove() behavior
Simon Sapin [Mon, 23 Dec 2013 15:53:20 +0000 (16:53 +0100)]
[std::vec] Rename .remove_opt() to .remove(), drop the old .remove() behavior

10 years ago[std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behavior
Simon Sapin [Mon, 23 Dec 2013 15:40:42 +0000 (16:40 +0100)]
[std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behavior

10 years ago[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behavior
Simon Sapin [Mon, 23 Dec 2013 15:20:52 +0000 (16:20 +0100)]
[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behavior

10 years ago[std::vec] Rename .last_opt() to .last(), drop the old .last() behavior
Simon Sapin [Mon, 23 Dec 2013 14:08:23 +0000 (15:08 +0100)]
[std::vec] Rename .last_opt() to .last(), drop the old .last() behavior

10 years ago[std::vec] Rename .head_opt() to .head(), drop the old .head() behavior
Simon Sapin [Mon, 23 Dec 2013 13:46:54 +0000 (14:46 +0100)]
[std::vec] Rename .head_opt() to .head(), drop the old .head() behavior

10 years ago[std::vec] Rename .get_opt() to .get()
Simon Sapin [Mon, 23 Dec 2013 13:38:02 +0000 (14:38 +0100)]
[std::vec] Rename .get_opt() to .get()

10 years agoauto merge of #11700 : bharrisau/rust/thumb, r=alexcrichton
bors [Tue, 21 Jan 2014 19:26:13 +0000 (11:26 -0800)]
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).

10 years agoauto merge of #11665 : alexcrichton/rust/zed-cleanup, r=brson
bors [Tue, 21 Jan 2014 18:06:18 +0000 (10:06 -0800)]
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`

10 years agoRemove no-debug-borrows from the makefiles
Alex Crichton [Tue, 21 Jan 2014 17:39:00 +0000 (09:39 -0800)]
Remove no-debug-borrows from the makefiles

10 years agoCapitalize debugging opts and make them u64
Alex Crichton [Mon, 20 Jan 2014 21:55:10 +0000 (13:55 -0800)]
Capitalize debugging opts and make them u64

10 years agoPurge borrowck from libstd
Alex Crichton [Sun, 19 Jan 2014 09:35:31 +0000 (01:35 -0800)]
Purge borrowck from libstd

This hasn't been in use since `@mut` was removed

10 years agoRemove obsoleted -Z options
Alex Crichton [Sun, 19 Jan 2014 09:19:02 +0000 (01:19 -0800)]
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

10 years agoStop using hardcoded numbers for -Z options
Alex Crichton [Sun, 19 Jan 2014 09:17:54 +0000 (01:17 -0800)]
Stop using hardcoded numbers for -Z options

Instead use a macro and generate them!

10 years agoFlag all TLS functions as inline(never)
Alex Crichton [Tue, 21 Jan 2014 16:19:35 +0000 (08:19 -0800)]
Flag all TLS functions as inline(never)

There's lots of fun rationale in the comments of the diff.

Closes #11683

10 years agoauto merge of #11663 : huonw/rust/paren-lint, r=cmr
bors [Tue, 21 Jan 2014 12:26:15 +0000 (04:26 -0800)]
auto merge of #11663 : huonw/rust/paren-lint, r=cmr

The parens in `if (true) {}` are not necessary, so we'll warn about them.

cc #3070 and #11432

10 years agoRemove unnecessary parentheses.
Huon Wilson [Sun, 19 Jan 2014 08:21:14 +0000 (19:21 +1100)]
Remove unnecessary parentheses.

10 years agorustc: add lint for parens in if, while, match and return.
Huon Wilson [Sun, 19 Jan 2014 03:57:47 +0000 (14:57 +1100)]
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.

10 years agoAdd support for ARM thumb architecture
Ben Harris [Tue, 21 Jan 2014 06:47:14 +0000 (14:47 +0800)]
Add support for ARM thumb architecture

10 years agoauto merge of #11699 : alexcrichton/rust/snapshot, r=huonw
bors [Tue, 21 Jan 2014 09:31:30 +0000 (01:31 -0800)]
auto merge of #11699 : alexcrichton/rust/snapshot, r=huonw

Upgrade the version to 0.10-pre

10 years agoauto merge of #11687 : sfackler/rust/macro-export-inner-crate, r=alexcrichton
bors [Tue, 21 Jan 2014 08:06:22 +0000 (00:06 -0800)]
auto merge of #11687 : sfackler/rust/macro-export-inner-crate, r=alexcrichton

It previously missed anything in an inner module.

10 years agoauto merge of #11684 : FlaPer87/rust/doc_typos, r=cmr
bors [Tue, 21 Jan 2014 06:46:20 +0000 (22:46 -0800)]
auto merge of #11684 : FlaPer87/rust/doc_typos, r=cmr

10 years agoauto merge of #11674 : indirect/rust/doc_file, r=alexcrichton
bors [Tue, 21 Jan 2014 05:26:22 +0000 (21:26 -0800)]
auto merge of #11674 : indirect/rust/doc_file, r=alexcrichton

Found out about `file!` today from o11c in IRC.

10 years agoauto merge of #11662 : alexcrichton/rust/faster-parens, r=huonw
bors [Tue, 21 Jan 2014 04:06:23 +0000 (20:06 -0800)]
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.

10 years agoRegister new snapshots
Alex Crichton [Tue, 21 Jan 2014 03:42:50 +0000 (19:42 -0800)]
Register new snapshots

Upgrade the version to 0.10-pre

10 years agoauto merge of #11486 : Matthias247/rust/doc, r=cmr
bors [Tue, 21 Jan 2014 02:31:38 +0000 (18:31 -0800)]
auto merge of #11486 : Matthias247/rust/doc, r=cmr

I wrote a chapter for the FFI tutorial that describes how to perform callbacks from C code to Rust and gives some hints about what to consider and synchronization.

I just needed that for my own wrapper and thought it would be helpful for others.

10 years agoauto merge of #11653 : alexcrichton/rust/issue-11647, r=luqmana
bors [Tue, 21 Jan 2014 00:56:25 +0000 (16:56 -0800)]
auto merge of #11653 : alexcrichton/rust/issue-11647, r=luqmana

Closes #11647

10 years agoauto merge of #11675 : alexcrichton/rust/fix-snap, r=cmr
bors [Mon, 20 Jan 2014 23:26:27 +0000 (15:26 -0800)]
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.

10 years agoFix cross-compiled pretty tests
Alex Crichton [Mon, 20 Jan 2014 00:08:48 +0000 (16:08 -0800)]
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.

10 years agoFix a pathological const checking case
Alex Crichton [Sun, 19 Jan 2014 08:00:39 +0000 (00:00 -0800)]
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.

10 years agoauto merge of #11636 : alexcrichton/rust/purge-all-the-c, r=brson
bors [Mon, 20 Jan 2014 21:46:24 +0000 (13:46 -0800)]
auto merge of #11636 : alexcrichton/rust/purge-all-the-c, r=brson

This means we can purge even more C from src/rt!

10 years agorustuv: Re-work sockaddr glue to not use malloc
Alex Crichton [Sat, 18 Jan 2014 03:33:29 +0000 (19:33 -0800)]
rustuv: Re-work sockaddr glue to not use malloc

This means we can purge even more C from src/rt!

10 years agoDon't emit landing pads with -Z no-landing-pads
Alex Crichton [Sat, 18 Jan 2014 19:21:10 +0000 (11:21 -0800)]
Don't emit landing pads with -Z no-landing-pads

Closes #11647

10 years agoDisabled the tests for the new code blocks
Matthias Einwag [Mon, 20 Jan 2014 20:44:41 +0000 (21:44 +0100)]
Disabled the tests for the new code blocks

10 years agoauto merge of #11673 : omasanori/rust/sep-doc, r=alexcrichton
bors [Mon, 20 Jan 2014 19:41:29 +0000 (11:41 -0800)]
auto merge of #11673 : omasanori/rust/sep-doc, r=alexcrichton

10 years agoauto merge of #11664 : bjz/rust/identities, r=alexcrichton
bors [Mon, 20 Jan 2014 18:16:30 +0000 (10:16 -0800)]
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.

10 years agoScan the entire crate for exported macros
Steven Fackler [Mon, 20 Jan 2014 17:22:46 +0000 (09:22 -0800)]
Scan the entire crate for exported macros

It previously missed anything in an inner module.

10 years agoauto merge of #11670 : sfackler/rust/extctxt-span-note, r=alexcrichton
bors [Mon, 20 Jan 2014 16:41:30 +0000 (08:41 -0800)]
auto merge of #11670 : sfackler/rust/extctxt-span-note, r=alexcrichton

It was the only span_* missing.

10 years agoauto merge of #11661 : huonw/rust/fixed-length-instantiation, r=thestinger
bors [Mon, 20 Jan 2014 14:16:29 +0000 (06:16 -0800)]
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.

10 years agoauto merge of #11660 : sfackler/rust/quote-unused-sp, r=huonw
bors [Mon, 20 Jan 2014 12:11:32 +0000 (04:11 -0800)]
auto merge of #11660 : sfackler/rust/quote-unused-sp, r=huonw

The provided span isn't used in all cases (namely primitives).

10 years agoauto merge of #11657 : huonw/rust/less-lang-duplication, r=cmr
bors [Mon, 20 Jan 2014 10:31:42 +0000 (02:31 -0800)]
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.

10 years agoFix documentation typos
Flavio Percoco [Mon, 20 Jan 2014 10:16:24 +0000 (11:16 +0100)]
Fix documentation typos

10 years agoauto merge of #11656 : brson/rust/omgandroid, r=cmr
bors [Mon, 20 Jan 2014 09:11:35 +0000 (01:11 -0800)]
auto merge of #11656 : brson/rust/omgandroid, r=cmr

10 years agoauto merge of #11654 : korenchkin/rust/doc_guide-testing_format, r=cmr
bors [Mon, 20 Jan 2014 07:51:33 +0000 (23:51 -0800)]
auto merge of #11654 : korenchkin/rust/doc_guide-testing_format, r=cmr

10 years agoImprove std::num::pow implementation
Brendan Zabarauskas [Sun, 19 Jan 2014 13:39:05 +0000 (00:39 +1100)]
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.

10 years agoAdd operator trait constraints to std::num::{Zero, One} and document their appropriat...
Brendan Zabarauskas [Sat, 18 Jan 2014 06:08:23 +0000 (17:08 +1100)]
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

10 years agoauto merge of #11652 : hdima/rust/base64-padding-newlines, r=alexcrichton
bors [Mon, 20 Jan 2014 06:31:42 +0000 (22:31 -0800)]
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")
=> ["\ 1"]
```

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
>>> "\ 1".encode("base64")
'AQ==
'
```

Ruby:

```ruby
irb(main):001:0> ["\ 1"].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.

10 years agoauto merge of #11649 : FlaPer87/rust/pow, r=cmr
bors [Mon, 20 Jan 2014 03:46:35 +0000 (19:46 -0800)]
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)
```

10 years agoauto merge of #10801 : musitdev/rust/jsondoc2, r=cmr
bors [Mon, 20 Jan 2014 02:21:39 +0000 (18:21 -0800)]
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.

10 years agoauto merge of #11644 : huonw/rust/less-fatality, r=cmr
bors [Mon, 20 Jan 2014 00:56:40 +0000 (16:56 -0800)]
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.

10 years agoauto merge of #11643 : kballard/rust/path-root-path, r=erickt
bors [Sun, 19 Jan 2014 23:31:57 +0000 (15:31 -0800)]
auto merge of #11643 : kballard/rust/path-root-path, r=erickt

10 years agodocument file!
Andre Arko [Sun, 19 Jan 2014 23:15:57 +0000 (15:15 -0800)]
document file!

10 years agoFix misuse of character/byte in std::path.
OGINO Masanori [Sun, 19 Jan 2014 22:42:28 +0000 (07:42 +0900)]
Fix misuse of character/byte in std::path.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoauto merge of #11642 : erickt/rust/path, r=huonw
bors [Sun, 19 Jan 2014 21:11:37 +0000 (13:11 -0800)]
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.

10 years agoAdd span_note to ExtCtxt
Steven Fackler [Sun, 19 Jan 2014 19:24:27 +0000 (11:24 -0800)]
Add span_note to ExtCtxt

It was the only span_* missing.

10 years agoauto merge of #11639 : sfackler/rust/macro-crate-path, r=alexcrichton
bors [Sun, 19 Jan 2014 13:56:35 +0000 (05:56 -0800)]
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.

10 years agoauto merge of #11635 : thestinger/rust/zero-size-alloc, r=alexcrichton
bors [Sun, 19 Jan 2014 12:31:53 +0000 (04:31 -0800)]
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

10 years agoextra::json: add documentation and examples
musitdev [Sun, 19 Jan 2014 10:56:27 +0000 (11:56 +0100)]
extra::json: add documentation and examples

10 years agoauto merge of #11633 : chromatic/rust/master, r=alexcrichton
bors [Sun, 19 Jan 2014 10:01:49 +0000 (02:01 -0800)]
auto merge of #11633 : chromatic/rust/master, r=alexcrichton

10 years agoextra::json: add documentation and examples
musitdev [Sun, 19 Jan 2014 08:39:07 +0000 (09:39 +0100)]
extra::json: add documentation and examples

10 years agoauto merge of #11628 : alexcrichton/rust/issue-11593, r=brson
bors [Sun, 19 Jan 2014 08:36:48 +0000 (00:36 -0800)]
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

10 years agoSquashed commit of the following:
musitdev [Sun, 12 Jan 2014 17:32:57 +0000 (18:32 +0100)]
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.

10 years agorustc: check instantiability of fixed length vectors properly.
Huon Wilson [Sun, 19 Jan 2014 07:29:47 +0000 (18:29 +1100)]
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.

10 years agoauto merge of #11616 : huonw/rust/ast_map, r=pnkfelix
bors [Sun, 19 Jan 2014 07:16:33 +0000 (23:16 -0800)]
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.

10 years agoAvoid unused variable warning in quote_*!
Steven Fackler [Sun, 19 Jan 2014 07:00:50 +0000 (23:00 -0800)]
Avoid unused variable warning in quote_*!

The provided span isn't used in all cases (namely primitives).

10 years agoauto merge of #11615 : adwhit/rust/master, r=cmr
bors [Sun, 19 Jan 2014 05:56:34 +0000 (21:56 -0800)]
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.

10 years agoauto merge of #11567 : divtxt/rust/master, r=cmr
bors [Sun, 19 Jan 2014 04:31:47 +0000 (20:31 -0800)]
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.

10 years agorustc: remove the explicit count from the lang_item macro.
Huon Wilson [Sun, 19 Jan 2014 03:15:57 +0000 (14:15 +1100)]
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.

10 years agoauto merge of #11311 : hdima/rust/vim-syntax-spell-check, r=cmr
bors [Sun, 19 Jan 2014 03:06:37 +0000 (19:06 -0800)]
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

10 years agoPass the correct --target flag when type checking pretty-printed code in tests
Brian Anderson [Sun, 19 Jan 2014 02:23:46 +0000 (18:23 -0800)]
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.

10 years agosyntax: convert ast_map to use a SmallIntMap.
Huon Wilson [Fri, 17 Jan 2014 12:23:09 +0000 (23:23 +1100)]
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.

10 years agoauto merge of #11632 : brson/rust/issue-11602, r=huonw
bors [Sun, 19 Jan 2014 00:46:39 +0000 (16:46 -0800)]
auto merge of #11632 : brson/rust/issue-11602, r=huonw

10 years agoxfail more external syntax extension tests on android
Brian Anderson [Sat, 18 Jan 2014 23:22:52 +0000 (15:22 -0800)]
xfail more external syntax extension tests on android

10 years agoauto merge of #11620 : alexcrichton/rust/rustc-silent, r=brson
bors [Sat, 18 Jan 2014 22:36:41 +0000 (14:36 -0800)]
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.

10 years agoauto merge of #11607 : alexcrichton/rust/issue-9957, r=cmr
bors [Sat, 18 Jan 2014 21:01:47 +0000 (13:01 -0800)]
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

10 years agoConsistent formatting for args and attrs
korenchkin [Sat, 18 Jan 2014 11:59:57 +0000 (12:59 +0100)]
Consistent formatting for args and attrs

10 years agoauto merge of #11606 : alexcrichton/rust/issue-9259, r=brson
bors [Sat, 18 Jan 2014 19:32:06 +0000 (11:32 -0800)]
auto merge of #11606 : alexcrichton/rust/issue-9259, r=brson

This must have been fixed in some recent trans refactor/rewrite, hurray!

Closes #9259

10 years agoReplace old pow_with_uint with the new pow func
Flavio Percoco [Sat, 18 Jan 2014 17:10:17 +0000 (18:10 +0100)]
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)

10 years agoAdded benchmark for pow and pow_with_uint
Flavio Percoco [Sat, 18 Jan 2014 18:25:38 +0000 (19:25 +0100)]
Added benchmark for pow and pow_with_uint

10 years agoAdd a test for closed issue #9259
Alex Crichton [Thu, 16 Jan 2014 20:53:53 +0000 (12:53 -0800)]
Add a test for closed issue #9259

This must have been fixed in some recent trans refactor/rewrite, hurray!

Closes #9259

10 years agoDisallow implementation of cross-crate priv traits
Alex Crichton [Fri, 17 Jan 2014 23:23:19 +0000 (15:23 -0800)]
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

10 years agorustc: Clean up error reporting
Alex Crichton [Fri, 17 Jan 2014 20:12:46 +0000 (12:12 -0800)]
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.

10 years agoForbid unnecessary visibility on view items
Alex Crichton [Thu, 16 Jan 2014 21:27:27 +0000 (13:27 -0800)]
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

10 years agoIgnore all newline characters in Base64 decoder
Dmitry Vasiliev [Sat, 18 Jan 2014 18:18:44 +0000 (19:18 +0100)]
Ignore all newline characters in Base64 decoder

Ignore all newline characters in Base64 decoder to make it compatible
with other Base64 decoders.

10 years agoExpose platform independent path separators
Erick Tryzelaar [Sat, 18 Jan 2014 17:17:44 +0000 (09:17 -0800)]
Expose platform independent path separators