]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoFix API docs css reversing elements that it shouldn't
tinaun [Fri, 1 Aug 2014 07:45:53 +0000 (03:45 -0400)]
Fix API docs css reversing elements that it shouldn't

remove unneeded `pre.rust a' selector

move transform into `.test-arrow`

fixes #16138

9 years agoauto merge of #16130 : apoelstra/rust/decode-error, r=alexcrichton
bors [Fri, 1 Aug 2014 05:41:05 +0000 (05:41 +0000)]
auto merge of #16130 : apoelstra/rust/decode-error, r=alexcrichton

A quick and dirty fix for #15036 until we get serious decoder reform.

Right now it is impossible for a `Decodable` to signal a decode error, for example if it has only finitely many allowed values, is a string which must be encoded a certain way, needs a valid checksum, etc. For example in the `libuuid` implementation of `Decodable` an `Option` is unwrapped, meaning that a decode of a malformed UUID will cause the task to fail.

9 years agolibuuid: use `Decoder::error()` rather than failing on bad decode
Andrew Poelstra [Thu, 31 Jul 2014 02:36:24 +0000 (19:36 -0700)]
libuuid: use `Decoder::error()` rather than failing on bad decode

9 years agolibserialize: add `error()` to `Decoder`
Andrew Poelstra [Thu, 31 Jul 2014 02:35:32 +0000 (19:35 -0700)]
libserialize: add `error()` to `Decoder`

A quick and dirty fix for #15036 until we get serious decoder reform.

Right now it is impossible for a Decodable to signal a decode error,
for example if it has only finitely many allowed values, is a string
which must be encoded a certain way, needs a valid checksum, etc. For
example in the libuuid implementation of Decodable an Option is
unwrapped, meaning that a decode of a malformed UUID will cause the
task to fail.

Since this adds a method to the `Decoder` trait, all users will need
to update their implementations to add it. The strategy used for the
current implementations for JSON and EBML is to add a new entry to
the error enum `ApplicationError(String)` which stores the string
provided to `.error()`.

[breaking-change]

9 years agoauto merge of #16141 : alexcrichton/rust/rollup, r=alexcrichton
bors [Fri, 1 Aug 2014 01:56:32 +0000 (01:56 +0000)]
auto merge of #16141 : alexcrichton/rust/rollup, r=alexcrichton

9 years agoauto merge of #15399 : kballard/rust/rewrite_local_data, r=alexcrichton
bors [Thu, 31 Jul 2014 23:16:33 +0000 (23:16 +0000)]
auto merge of #15399 : kballard/rust/rewrite_local_data, r=alexcrichton

This was motivated by a desire to remove allocation in the common
pattern of

    let old = key.replace(None)
    do_something();
    key.replace(old);

This also switched the map representation from a Vec to a TreeMap. A Vec
may be reasonable if there's only a couple TLD keys, but a TreeMap
provides better behavior as the number of keys increases.

Like the Vec, this TreeMap implementation does not shrink the container
when a value is removed. Unlike Vec, this TreeMap implementation cannot
reuse an empty node for a different key. Therefore any key that has been
inserted into the TLD at least once will continue to take up space in
the Map until the task ends. The expectation is that the majority of
keys that are inserted into TLD will be expected to have a value for
most of the rest of the task's lifetime. If this assumption is wrong,
there are two reasonable ways to fix this that could be implemented in
the future:

1. Provide an API call to either remove a specific key from the TLD and
   destruct its node (e.g. `remove()`), or instead to explicitly clean
   up all currently-empty nodes in the map (e.g. `compact()`). This is
   simple, but requires the user to explicitly call it.
2. Keep track of the number of empty nodes in the map and when the map
   is mutated (via `replace()`), if the number of empty nodes passes
   some threshold, compact it automatically. Alternatively, whenever a
   new key is inserted that hasn't been used before, compact the map at
   that point.

---

Benchmarks:

I ran 3 benchmarks. tld_replace_none just replaces the tld key with None
repeatedly. tld_replace_some replaces it with Some repeatedly. And
tld_replace_none_some simulates the common behavior of replacing with
None, then replacing with the previous value again (which was a Some).

Old implementation:

    test tld_replace_none      ... bench:        20 ns/iter (+/- 0)
    test tld_replace_none_some ... bench:        77 ns/iter (+/- 4)
    test tld_replace_some      ... bench:        57 ns/iter (+/- 2)

New implementation:

    test tld_replace_none      ... bench:        11 ns/iter (+/- 0)
    test tld_replace_none_some ... bench:        23 ns/iter (+/- 0)
    test tld_replace_some      ... bench:        12 ns/iter (+/- 0)

9 years agoAdd some benchmarks for TLD
Kevin Ballard [Fri, 4 Jul 2014 07:15:18 +0000 (00:15 -0700)]
Add some benchmarks for TLD

9 years agoTweak error reporting in io::net::tcp tests
Kevin Ballard [Fri, 4 Jul 2014 04:36:51 +0000 (21:36 -0700)]
Tweak error reporting in io::net::tcp tests

Errors can be printed with {}, printing with {:?} does not work very
well.

Not actually related to this PR, but it came up when running the tests
and now is as good a time to fix it as any.

9 years agoRewrite the local_data implementation
Kevin Ballard [Thu, 3 Jul 2014 18:35:34 +0000 (11:35 -0700)]
Rewrite the local_data implementation

This was motivated by a desire to remove allocation in the common
pattern of

    let old = key.replace(None)
    do_something();
    key.replace(old);

This also switched the map representation from a Vec to a TreeMap. A Vec
may be reasonable if there's only a couple TLD keys, but a TreeMap
provides better behavior as the number of keys increases.

Like the Vec, this TreeMap implementation does not shrink the container
when a value is removed. Unlike Vec, this TreeMap implementation cannot
reuse an empty node for a different key. Therefore any key that has been
inserted into the TLD at least once will continue to take up space in
the Map until the task ends. The expectation is that the majority of
keys that are inserted into TLD will be expected to have a value for
most of the rest of the task's lifetime. If this assumption is wrong,
there are two reasonable ways to fix this that could be implemented in
the future:

1. Provide an API call to either remove a specific key from the TLD and
   destruct its node (e.g. `remove()`), or instead to explicitly clean
   up all currently-empty nodes in the map (e.g. `compact()`). This is
   simple, but requires the user to explicitly call it.
2. Keep track of the number of empty nodes in the map and when the map
   is mutated (via `replace()`), if the number of empty nodes passes
   some threshold, compact it automatically. Alternatively, whenever a
   new key is inserted that hasn't been used before, compact the map at
   that point.

---

Benchmarks:

I ran 3 benchmarks. tld_replace_none just replaces the tld key with None
repeatedly. tld_replace_some replaces it with Some repeatedly. And
tld_replace_none_some simulates the common behavior of replacing with
None, then replacing with the previous value again (which was a Some).

Old implementation:

    test tld_replace_none      ... bench:        20 ns/iter (+/- 0)
    test tld_replace_none_some ... bench:        77 ns/iter (+/- 4)
    test tld_replace_some      ... bench:        57 ns/iter (+/- 2)

New implementation:

    test tld_replace_none      ... bench:        11 ns/iter (+/- 0)
    test tld_replace_none_some ... bench:        23 ns/iter (+/- 0)
    test tld_replace_some      ... bench:        12 ns/iter (+/- 0)

9 years agoTest fixes from the rollup
Alex Crichton [Thu, 31 Jul 2014 15:13:25 +0000 (08:13 -0700)]
Test fixes from the rollup

Closes #16097 (fix variable name in tutorial)
Closes #16100 (More defailbloating)
Closes #16104 (Fix deprecation commment on `core::cmp::lexical_ordering`)
Closes #16105 (fix formatting in pointer guide table)
Closes #16107 (remove serialize::ebml, add librbml)
Closes #16108 (Fix heading levels in pointer guide)
Closes #16109 (rustrt: Don't conditionally init the at_exit QUEUE)
Closes #16111 (hexfloat: Deprecate to move out of the repo)
Closes #16113 (Add examples for GenericPath methods.)
Closes #16115 (Byte literals!)
Closes #16116 (Add a non-regression test for issue #8372)
Closes #16120 (Deprecate semver)
Closes #16124 (Deprecate uuid)
Closes #16126 (Deprecate fourcc)
Closes #16127 (Remove incorrect example)
Closes #16129 (Add note about production deployments.)
Closes #16131 (librustc: Don't ICE when trying to subst regions in destructor call.)
Closes #16133 (librustc: Don't ICE with struct exprs where the name is not a valid struct.)
Closes #16136 (Implement slice::Vector for Option<T> and CVec<T>)
Closes #16137 (alloc, arena, test, url, uuid: Elide lifetimes.)

9 years agoauto merge of #16041 : treeman/rust/doc-rand, r=brson
bors [Thu, 31 Jul 2014 19:36:34 +0000 (19:36 +0000)]
auto merge of #16041 : treeman/rust/doc-rand, r=brson

A larger example for `std::rand`.

9 years agoalloc, arena, test, url, uuid: Elide lifetimes.
OGINO Masanori [Wed, 30 Jul 2014 22:56:39 +0000 (07:56 +0900)]
alloc, arena, test, url, uuid: Elide lifetimes.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
9 years agoImplement slice::Vector for Option<T> and CVec<T>
Derek Harland [Thu, 31 Jul 2014 03:57:29 +0000 (15:57 +1200)]
Implement slice::Vector for Option<T> and CVec<T>

9 years agolibrustc: Don't ICE with struct exprs where the name is not a valid struct.
Luqman Aden [Thu, 31 Jul 2014 01:43:55 +0000 (18:43 -0700)]
librustc: Don't ICE with struct exprs where the name is not a valid struct.

9 years agolibrustc: Don't ICE when trying to subst regions in destructor call.
Luqman Aden [Thu, 31 Jul 2014 00:47:54 +0000 (17:47 -0700)]
librustc: Don't ICE when trying to subst regions in destructor call.

9 years agoAdd note about production deployments.
Steve Klabnik [Wed, 30 Jul 2014 23:17:47 +0000 (19:17 -0400)]
Add note about production deployments.

Fixes #11511.

9 years agoRemove incorrect example
Steve Klabnik [Wed, 30 Jul 2014 22:35:02 +0000 (18:35 -0400)]
Remove incorrect example

This now works because of elision.

Fixes #16117

9 years agoDeprecate fourcc.
Ilya Dmitrichenko [Wed, 30 Jul 2014 22:32:02 +0000 (23:32 +0100)]
Deprecate fourcc.

9 years agoDeprecate uuid.
Ilya Dmitrichenko [Wed, 30 Jul 2014 22:30:48 +0000 (23:30 +0100)]
Deprecate uuid.

9 years agoDeprecate semver.
Ilya Dmitrichenko [Wed, 30 Jul 2014 20:57:58 +0000 (21:57 +0100)]
Deprecate semver.

9 years agoAdd a non-regression test for issue #8372
Simon Sapin [Wed, 30 Jul 2014 19:20:01 +0000 (20:20 +0100)]
Add a non-regression test for issue #8372

9 years agoByte literals!
Simon Sapin [Wed, 30 Jul 2014 18:14:43 +0000 (19:14 +0100)]
Byte literals!

9 years agoAdd logic to skip the doc tests on windows since these examples are unix-specific
nham [Wed, 30 Jul 2014 19:21:55 +0000 (15:21 -0400)]
Add logic to skip the doc tests on windows since these examples are unix-specific

9 years agoUse byte strings throughout examples. Add an example that was missed in the last...
nham [Wed, 30 Jul 2014 18:19:47 +0000 (14:19 -0400)]
Use byte strings throughout examples. Add an example that was missed in the last commit.

9 years agoAdd examples for GenericPath methods.
nham [Wed, 30 Jul 2014 15:35:20 +0000 (11:35 -0400)]
Add examples for GenericPath methods.

9 years agohexfloat: Deprecate to move out of the repo
Alex Crichton [Wed, 30 Jul 2014 15:36:44 +0000 (08:36 -0700)]
hexfloat: Deprecate to move out of the repo

This deprecates the hexfloat library as it is now located in the rust-lang
organization as a cargo package

9 years agoauto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
bors [Thu, 31 Jul 2014 16:41:36 +0000 (16:41 +0000)]
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis

Note: This PR is motivated by an attempt to write an custom syntax extension that tried to use `syntax::fold`, and that could only do so by fixing bugs in it and copying out private functions.

---

Refactored `syntax::fold`

Prior to this, the code there had a few issues:

- Default implementations inconsistenly either had the prefix `noop_` or
  not.
- Some default methods where implemented in terms of a public noop function
  for user code to call, others where implemented directly on the trait
  and did not allow users of the trait to reuse the code.
- Some of the default implementations where private, and thus not reusable
  for other implementors.
- There where some bugs where default implemntations called other default
  implementations directly, rather than to the underlying Folder, with the
  result of some ast nodes never being visted even if the user implemented that
  method. (For example, the current Folder never folded struct fields)

This commit solves this situation somewhat radically by making __all__
`fold_...` functions in the module into Folder methods, and implementing
them all in terms of public `noop_...` functions for other implementors to
call out to.

Some public functions had to be renamed to fit the new system, so this is a
breaking change.

---

Also added a few trait implementations to `ast` types

9 years agoauto merge of #16073 : mneumann/rust/dragonfly2, r=alexcrichton
bors [Thu, 31 Jul 2014 14:41:34 +0000 (14:41 +0000)]
auto merge of #16073 : mneumann/rust/dragonfly2, r=alexcrichton

Not included are two required patches:

* LLVM: segmented stack support for DragonFly [1]

* jemalloc: simple configure patches

[1]: http://reviews.llvm.org/D4705

9 years agorustrt: Don't conditionally init the at_exit QUEUE
Alex Crichton [Wed, 30 Jul 2014 14:08:42 +0000 (07:08 -0700)]
rustrt: Don't conditionally init the at_exit QUEUE

This initialization should happen unconditionally, but the rtassert! macro is
gated on the ENFORCE_SANITY define

Closes #16106

9 years agoFix heading levels in pointer guide
Steve Klabnik [Wed, 30 Jul 2014 14:09:03 +0000 (10:09 -0400)]
Fix heading levels in pointer guide

9 years agoMove SeekableMemWriter into librbml
Erick Tryzelaar [Wed, 30 Jul 2014 01:27:28 +0000 (18:27 -0700)]
Move SeekableMemWriter into librbml

9 years agoremove serialize::ebml, add librbml
Erick Tryzelaar [Wed, 30 Jul 2014 00:06:37 +0000 (17:06 -0700)]
remove serialize::ebml, add librbml

Our implementation of ebml has diverged from the standard in order
to better serve the needs of the compiler, so it doesn't make much
sense to call what we have ebml anyore. Furthermore, our implementation
is pretty crufty, and should eventually be rewritten into a format
that better suits the needs of the compiler. This patch factors out
serialize::ebml into librbml, otherwise known as the Really Bad
Markup Language. This is a stopgap library that shouldn't be used
by end users, and will eventually be replaced by something better.

[breaking-change]

9 years agofix formatting in pointer guide table
Steve Klabnik [Wed, 30 Jul 2014 13:41:05 +0000 (09:41 -0400)]
fix formatting in pointer guide table

9 years agoFix deprecation commment on `core::cmp::lexical_ordering`
Tobias Bucher [Wed, 30 Jul 2014 11:17:12 +0000 (13:17 +0200)]
Fix deprecation commment on `core::cmp::lexical_ordering`

9 years agocore: Fix failure doc comment
Brian Anderson [Wed, 30 Jul 2014 06:19:36 +0000 (23:19 -0700)]
core: Fix failure doc comment

9 years agocore: Add #[inline(never)] to failure functions
Brian Anderson [Wed, 30 Jul 2014 06:18:31 +0000 (23:18 -0700)]
core: Add #[inline(never)] to failure functions

For consistency, just because `fail_` has it.

9 years agoModify failure lang items to take less pointers.
Brian Anderson [Tue, 29 Jul 2014 23:40:59 +0000 (16:40 -0700)]
Modify failure lang items to take less pointers.

Divide-by-zero before:

```
        leaq    "str\"str\"(1762)"(%rip), %rax
        movq    %rax, 16(%rsp)
        movq    $27, 24(%rsp)
        leaq    "str\"str\"(1542)"(%rip), %rax
        movq    %rax, (%rsp)
        movq    $19, 8(%rsp)
        leaq    16(%rsp), %rdi
        leaq    (%rsp), %rsi
        movl    $32, %edx
        callq   _ZN7failure5fail_20hc04408f955ce60aaqWjE@PLT
```

After:

```
        leaq    .Lconst(%rip), %rdi
        callq   _ZN7failure5fail_20haf918a97c8f7f2bfqWjE@PLT
```

Bounds check before:

```
        leaq    "str\"str\"(1542)"(%rip), %rax
        movq    %rax, 8(%rsp)
        movq    $19, 16(%rsp)
        leaq    8(%rsp), %rdi
        movl    $38, %esi
        movl    $1, %edx
        movl    $1, %ecx
        callq   _ZN7failure17fail_bounds_check20hf4bc3c69e96caf41RXjE@PLT
```

Bounds check after:

```
        leaq    .Lconst2(%rip), %rdi
        movl    $1, %esi
        movl    $1, %edx
        callq   _ZN7failure17fail_bounds_check20h5267276a537a7de22XjE@PLT
```

Size before:

21277995 librustc-4e7c5e5c.s

```
text       data
12554881   6089335
```

Size after:

21247617 librustc-4e7c5e5c.so

```
text       data
12518497   6095748
```

9 years agorustrt: Make begin_unwind take a single file/line pointer
Brian Anderson [Tue, 29 Jul 2014 04:26:21 +0000 (21:26 -0700)]
rustrt: Make begin_unwind take a single file/line pointer

Smaller text size.

9 years agofix variable name in tutorial
DJUrsus [Sat, 5 Jul 2014 21:05:15 +0000 (14:05 -0700)]
fix variable name in tutorial

9 years agoauto merge of #16090 : epdtry/rust/doesnt-use-gc, r=alexcrichton
bors [Thu, 31 Jul 2014 13:01:35 +0000 (13:01 +0000)]
auto merge of #16090 : epdtry/rust/doesnt-use-gc, r=alexcrichton

9 years agoauto merge of #16076 : SimonSapin/rust/deprecate-url, r=alexcrichton
bors [Thu, 31 Jul 2014 11:16:35 +0000 (11:16 +0000)]
auto merge of #16076 : SimonSapin/rust/deprecate-url, r=alexcrichton

The replacement is [rust-url](https://github.com/servo/rust-url), which can be used with Cargo.

Fix #15874
Fix #10707
Close #10706
Close #10705
Close #8486

9 years agoauto merge of #16074 : nham/rust/bitflags_traits, r=alexcrichton
bors [Thu, 31 Jul 2014 09:31:37 +0000 (09:31 +0000)]
auto merge of #16074 : nham/rust/bitflags_traits, r=alexcrichton

I wanted to add an implementation of `Default` inside the bitflags macro, but `Default` isn't in the prelude, which means anyone who wants to use `bitflags!` needs to import it. This seems not nice, so I've just implemented for `FilePermission` instead.

9 years agoauto merge of #15385 : jroweboy/rust/master, r=brson
bors [Thu, 31 Jul 2014 07:51:38 +0000 (07:51 +0000)]
auto merge of #15385 : jroweboy/rust/master, r=brson

This enables the docs search function to be more forgiving for spelling mistakes. The algorithm works as a dynamic programming algorithm to detect the minimum number of changes required to the search parameter string in order to match any string in the search index. If the number of changes is less then a threshold (currently defined as 3), then the search parameter will be included as it is a possible misspelling of the word. Any results returned by the algorithm are sorted by distance and are ranked lower than results that are partial or exact matches (aka the matches returned by the original search algorithm). Additionally, the increment in the for loops in this file were using one of three different ways to increment (`i += 1` `i++` and `++i`) so I just standardized it to `++i`.

As an example, consider searching for the word `String` and accidentally typing in `Strnig`. The old system would return no results because it is a misspelling, but the Levenshtein distance between these two inputs is only two, which means that this will return `String` as a result. Additionally, it will return a few other results such as `strong`, and `StdRng` because these are also similar to `Strnig`. Because of the ranking system though, this change should be unobtrusive to anyone that spells the words correctly, as those are still ranked first before any Levenshtein results.

9 years agoFix test suite for DragonFly
Michael Neumann [Thu, 31 Jul 2014 00:23:35 +0000 (02:23 +0200)]
Fix test suite for DragonFly

9 years agoFix trailing whitespace
Michael Neumann [Thu, 31 Jul 2014 00:01:16 +0000 (02:01 +0200)]
Fix trailing whitespace

9 years agoDeprecate the url crate.
Simon Sapin [Tue, 29 Jul 2014 13:07:09 +0000 (14:07 +0100)]
Deprecate the url crate.

The replacement is [rust-url](https://github.com/servo/rust-url),
which can be used with Cargo.

Fix #15874
Fix #10707
Close #10706
Close #10705
Close #8486

9 years agoauto merge of #16059 : epdtry/rust/mono-item-dedup, r=alexcrichton
bors [Wed, 30 Jul 2014 20:51:22 +0000 (20:51 +0000)]
auto merge of #16059 : epdtry/rust/mono-item-dedup, r=alexcrichton

Currently, each time a function is monomorphized, all items within that function are translated.  This is unnecessary work because the inner items already get translated when the function declaration is visited by `trans_item`.  This patch adds a flag to the `FunctionContext` to prevent translation of items during monomorphization.

9 years agoImplement Default for std::io::FilePermission
nham [Wed, 30 Jul 2014 20:05:24 +0000 (16:05 -0400)]
Implement Default for std::io::FilePermission

9 years agoDerive PartialOrd, Ord and Hash for bitflags types.
nham [Wed, 30 Jul 2014 19:53:40 +0000 (15:53 -0400)]
Derive PartialOrd, Ord and Hash for bitflags types.

In order to prevent users from having to manually implement Hash and Ord for
bitflags types, this commit derives these traits automatically.

This breaks code that has manually implemented any of these traits for types
created by the bitflags! macro. Change this code by removing implementations
of these traits.

[breaking-change]

9 years agoavoid redundant translation of items during monomorphization
Stuart Pernsteiner [Fri, 25 Jul 2014 16:41:09 +0000 (09:41 -0700)]
avoid redundant translation of items during monomorphization

9 years agoUpdate docs for TLS -> TLD
Kevin Ballard [Wed, 2 Jul 2014 21:18:39 +0000 (14:18 -0700)]
Update docs for TLS -> TLD

The correct terminology is Task-Local Data, or TLD. Task-Local Storage,
or TLS, is the old terminology that was abandoned because of the
confusion with Thread-Local Storage (TLS).

9 years agoauto merge of #15944 : alexcrichton/rust/task-dont-die, r=brson
bors [Wed, 30 Jul 2014 17:06:18 +0000 (17:06 +0000)]
auto merge of #15944 : alexcrichton/rust/task-dont-die, r=brson

Previously both spawning mechanisms were not resilient to task failures which were initiated from the task spawning infrastructure.

Closes #15895

9 years agogreen: Prevent runtime corruption on spawn failure
Alex Crichton [Thu, 24 Jul 2014 14:32:14 +0000 (07:32 -0700)]
green: Prevent runtime corruption on spawn failure

Like with libnative, when a green task failed to spawn it would leave the world
in a corrupt state where the local scheduler had been dropped as well as the
local task. Also like libnative, this patch sets up a "bomb" which when it goes
off will restore the state of the world.

9 years agoauto merge of #15915 : erickt/rust/master, r=alexcrichton
bors [Wed, 30 Jul 2014 14:41:18 +0000 (14:41 +0000)]
auto merge of #15915 : erickt/rust/master, r=alexcrichton

std: rename MemWriter to SeekableMemWriter, add seekless MemWriter

Not all users of MemWriter need to seek, but having MemWriter seekable adds between 3-29% in overhead in certain circumstances. This fixes that performance gap by making a non-seekable MemWriter, and creating a new SeekableMemWriter for those circumstances when that functionality is actually needed.

```
test io::mem::test::bench_buf_reader                        ... bench:       682 ns/iter (+/- 85)
test io::mem::test::bench_buf_writer                        ... bench:       580 ns/iter (+/- 57)
test io::mem::test::bench_mem_reader                        ... bench:       793 ns/iter (+/- 99)
test io::mem::test::bench_mem_writer_001_0000               ... bench:        48 ns/iter (+/- 27)
test io::mem::test::bench_mem_writer_001_0010               ... bench:        65 ns/iter (+/- 27) = 153 MB/s
test io::mem::test::bench_mem_writer_001_0100               ... bench:       132 ns/iter (+/- 12) = 757 MB/s
test io::mem::test::bench_mem_writer_001_1000               ... bench:       802 ns/iter (+/- 151) = 1246 MB/s
test io::mem::test::bench_mem_writer_100_0000               ... bench:       481 ns/iter (+/- 28)
test io::mem::test::bench_mem_writer_100_0010               ... bench:      1957 ns/iter (+/- 126) = 510 MB/s
test io::mem::test::bench_mem_writer_100_0100               ... bench:      8222 ns/iter (+/- 434) = 1216 MB/s
test io::mem::test::bench_mem_writer_100_1000               ... bench:     82496 ns/iter (+/- 11191) = 1212 MB/s
test io::mem::test::bench_seekable_mem_writer_001_0000      ... bench:        48 ns/iter (+/- 2)
test io::mem::test::bench_seekable_mem_writer_001_0010      ... bench:        64 ns/iter (+/- 2) = 156 MB/s
test io::mem::test::bench_seekable_mem_writer_001_0100      ... bench:       129 ns/iter (+/- 7) = 775 MB/s
test io::mem::test::bench_seekable_mem_writer_001_1000      ... bench:       801 ns/iter (+/- 159) = 1248 MB/s
test io::mem::test::bench_seekable_mem_writer_100_0000      ... bench:       711 ns/iter (+/- 51)
test io::mem::test::bench_seekable_mem_writer_100_0010      ... bench:      2532 ns/iter (+/- 227) = 394 MB/s
test io::mem::test::bench_seekable_mem_writer_100_0100      ... bench:      8962 ns/iter (+/- 947) = 1115 MB/s
test io::mem::test::bench_seekable_mem_writer_100_1000      ... bench:     85086 ns/iter (+/- 11555) = 1175 MB/s
```

9 years agonative: Don't deadlock the runtime on spawn failure
Alex Crichton [Thu, 24 Jul 2014 05:49:19 +0000 (22:49 -0700)]
native: Don't deadlock the runtime on spawn failure

Previously, the call to bookkeeping::increment() was never paired with a
decrement when the spawn failed (due to unwinding). This fixes the problem by
returning a "bomb" from increment() which will decrement on drop, and then
moving the bomb into the child task's procedure which will be dropped naturally.

9 years agorustrt: Allow dropping a brand-new Task
Alex Crichton [Thu, 24 Jul 2014 05:48:04 +0000 (22:48 -0700)]
rustrt: Allow dropping a brand-new Task

When a new task fails to spawn, it triggers a task failure of the spawning task.
This ends up causing runtime aborts today because of the destructor bomb in the
Task structure. The bomb doesn't actually need to go off until *after* the task
has run at least once.

This now prevents a runtime abort when a native thread fails to spawn.

9 years agoauto merge of #16037 : erickt/rust/quote_arm, r=acrichto
bors [Wed, 30 Jul 2014 13:01:10 +0000 (13:01 +0000)]
auto merge of #16037 : erickt/rust/quote_arm, r=acrichto

This adds support for `quote_arm!(cx, $pat => $expr)`, and `macro_rules!(($a:arm) => (...))`. It also fixes a bug in pretty printing, where this would generate invalid code:

```
match { 5i } {
    1 => 2,
    _ => 3,
}
```

It would generate this code:

```
match { 5i } {
    1 => 2
    _ => 3
}
```

Finally, it adds a couple helper methods to `ExtCtxt`.

9 years agoauto merge of #15777 : SimonSapin/rust/pub-ascii-maps, r=alexcrichton
bors [Wed, 30 Jul 2014 10:31:11 +0000 (10:31 +0000)]
auto merge of #15777 : SimonSapin/rust/pub-ascii-maps, r=alexcrichton

When dealing with HTTP request or responses, many tokens are case-insensitive in the ASCII range but the bytes from the network are not necessarily valid UTF-8.

**[breaking-change]** Rather than adding new very similar traits, this re-uses the `std::ascii::OwnedStrAsciiExt` and `std::ascii::StrAsciiExt` traits, but rename to remove `Str` since that does not apply for bytes.

This PR also makes `std::ascii::ASCII_UPPER_MAP` and `std::ascii::ASCII_LOWER_MAP`, the lookup table all these methods are based on, public. In case there is something else related to ASCII case we haven’t thought of yet, that can be implemented outside of libstd without duplicating the tables.

Although this is a breaking change, I thought this could do without an RFC since the relevant traits are not in the prelude.

r? @alexcrichton

9 years agoauto merge of #15670 : epdtry/rust/fast-archive-builder, r=alexcrichton
bors [Wed, 30 Jul 2014 07:41:11 +0000 (07:41 +0000)]
auto merge of #15670 : epdtry/rust/fast-archive-builder, r=alexcrichton

When rustc produces an rlib, it includes the contents of each static library required by the crate.  Currently each static library is added individually, by extracting the library with `ar x` and adding the objects to the rlib using `ar r`.  Each `ar r` has significant overhead - it appears to scan through the full contents of the rlib before adding the new files.  This patch avoids most of the overhead by adding all library objects (and other rlib components) at once using a single `ar r`.

When building `librustc` (on Linux, using GNU ar), this patch gives a 60-80% reduction in linking time, from 90s to 10s one machine I tried and 25s to 8s on another.  (Though `librustc` is a bit of a special case - it's a very large crate, so the rlib is large to begin with, and it also relies on a total of 45 static libraries due to the way LLVM is organized.)  More reasonable crates such as `libstd` and `libcore` also get a small reduction in linking time (just from adding metadata, bitcode, and object code in one `ar` invocation instead of three), but this is not very noticeable since the time there is small to begin with (around 1s).

9 years agoauto merge of #16092 : alexcrichton/rust/rollup, r=alexcrichton
bors [Wed, 30 Jul 2014 05:06:41 +0000 (05:06 +0000)]
auto merge of #16092 : alexcrichton/rust/rollup, r=alexcrichton

9 years agostd: Make MemWriter clonable
Erick Tryzelaar [Tue, 29 Jul 2014 23:32:07 +0000 (16:32 -0700)]
std: Make MemWriter clonable

9 years agoremove seek from std::io::MemWriter, add SeekableMemWriter to librustc
Erick Tryzelaar [Tue, 29 Jul 2014 23:31:39 +0000 (16:31 -0700)]
remove seek from std::io::MemWriter, add SeekableMemWriter to librustc

Not all users of MemWriter need to seek, but having MemWriter
seekable adds between 3-29% in overhead in certain circumstances.
This fixes that performance gap by making a non-seekable MemWriter,
and creating a new SeekableMemWriter for those circumstances when
that functionality is actually needed.

```
test io::mem::test::bench_buf_reader                        ... bench:       682 ns/iter (+/- 85)
test io::mem::test::bench_buf_writer                        ... bench:       580 ns/iter (+/- 57)
test io::mem::test::bench_mem_reader                        ... bench:       793 ns/iter (+/- 99)
test io::mem::test::bench_mem_writer_001_0000               ... bench:        48 ns/iter (+/- 27)
test io::mem::test::bench_mem_writer_001_0010               ... bench:        65 ns/iter (+/- 27) = 153 MB/s
test io::mem::test::bench_mem_writer_001_0100               ... bench:       132 ns/iter (+/- 12) = 757 MB/s
test io::mem::test::bench_mem_writer_001_1000               ... bench:       802 ns/iter (+/- 151) = 1246 MB/s
test io::mem::test::bench_mem_writer_100_0000               ... bench:       481 ns/iter (+/- 28)
test io::mem::test::bench_mem_writer_100_0010               ... bench:      1957 ns/iter (+/- 126) = 510 MB/s
test io::mem::test::bench_mem_writer_100_0100               ... bench:      8222 ns/iter (+/- 434) = 1216 MB/s
test io::mem::test::bench_mem_writer_100_1000               ... bench:     82496 ns/iter (+/- 11191) = 1212 MB/s
test io::mem::test::bench_seekable_mem_writer_001_0000      ... bench:        48 ns/iter (+/- 2)
test io::mem::test::bench_seekable_mem_writer_001_0010      ... bench:        64 ns/iter (+/- 2) = 156 MB/s
test io::mem::test::bench_seekable_mem_writer_001_0100      ... bench:       129 ns/iter (+/- 7) = 775 MB/s
test io::mem::test::bench_seekable_mem_writer_001_1000      ... bench:       801 ns/iter (+/- 159) = 1248 MB/s
test io::mem::test::bench_seekable_mem_writer_100_0000      ... bench:       711 ns/iter (+/- 51)
test io::mem::test::bench_seekable_mem_writer_100_0010      ... bench:      2532 ns/iter (+/- 227) = 394 MB/s
test io::mem::test::bench_seekable_mem_writer_100_0100      ... bench:      8962 ns/iter (+/- 947) = 1115 MB/s
test io::mem::test::bench_seekable_mem_writer_100_1000      ... bench:     85086 ns/iter (+/- 11555) = 1175 MB/s
```

[breaking-change]

9 years agoTest fixes from the rollup
Alex Crichton [Tue, 29 Jul 2014 23:28:46 +0000 (16:28 -0700)]
Test fixes from the rollup

Closes #15296 (Update disclaimer to improve clarity and intent)
Closes #15804 (Don't ICE when dealing with the count expr for fixed array types in various places.)
Closes #15893 (lint: Improve ffi-unsafe enum lint warning)
Closes #16045 (Rename Integer divides to is_multiple_of.)
Closes #16055 (manual: update list of feature gates, add phase attribute)
Closes #16056 (Improve documentation of rounding functions)
Closes #16061 (Remove references to non-existant functions in the std::path documentation)
Closes #16062 (Fix documentation error in MutableVectorAllocating::move_from)
Closes #16063 (adding discuss.rust-lang to community)
Closes #16064 (rustc: Switch dsymutil status => output)
Closes #16066 (making raw source display better)
Closes #16079 (doc: add missing word)
Closes #16080 (Update LLVM to fix miscompilations due to wrongfully removed lifetime intrinsics)
Closes #16084 (Elide lifetimes around Arc<T>.)
Closes #16085 (Gedit/gtksourceview language spec: add raw strings)
Closes #16086 (Implement Hash for DList)

9 years agosyntax: add support for quoting arms
Erick Tryzelaar [Tue, 29 Jul 2014 00:32:51 +0000 (17:32 -0700)]
syntax: add support for quoting arms

9 years agoAdd deprecated aliases for the old {Owned,}StrAsciiExt trait names.
Simon Sapin [Fri, 18 Jul 2014 15:49:05 +0000 (16:49 +0100)]
Add deprecated aliases for the old {Owned,}StrAsciiExt trait names.

The deprecation warning does not seem to be emitted right now, but hopefully that’ll be fixed.

9 years agoRename the std::ascii::{Owned,}StrAsciiExt traits to {Owned,}AsciiExt
Simon Sapin [Fri, 18 Jul 2014 13:53:29 +0000 (14:53 +0100)]
Rename the std::ascii::{Owned,}StrAsciiExt traits to {Owned,}AsciiExt

… and implement them on Vec<u8> / &[u8].

[breaking-change]

9 years agoMake std::ascii::ASCII_{UPPER,LOWER}_MAP public.
Simon Sapin [Fri, 18 Jul 2014 13:16:23 +0000 (14:16 +0100)]
Make std::ascii::ASCII_{UPPER,LOWER}_MAP public.

9 years agoUse byte literals in std::ascii::ASCII_{UPPER,LOWER}_MAP for readability.
Simon Sapin [Fri, 18 Jul 2014 13:11:40 +0000 (14:11 +0100)]
Use byte literals in std::ascii::ASCII_{UPPER,LOWER}_MAP for readability.

9 years agoFix a bug pretty printing `match { 5i } { _ => { } }`
Erick Tryzelaar [Mon, 28 Jul 2014 01:05:07 +0000 (18:05 -0700)]
Fix a bug pretty printing `match { 5i } { _ => { } }`

This also always puts a trailing comma on the last non-block expr.

9 years agosyntax: promote a comment on PatEnum into a docstring
Erick Tryzelaar [Sun, 27 Jul 2014 22:23:01 +0000 (15:23 -0700)]
syntax: promote a comment on PatEnum into a docstring

9 years agosyntax: allow quasiquoter to inline `Vec<Stmt>`s
Erick Tryzelaar [Sun, 27 Jul 2014 22:11:42 +0000 (15:11 -0700)]
syntax: allow quasiquoter to inline `Vec<Stmt>`s

9 years agosyntax: add some more extension helper methods
Erick Tryzelaar [Sun, 27 Jul 2014 22:11:02 +0000 (15:11 -0700)]
syntax: add some more extension helper methods

9 years agoserialize: fix a warning
Erick Tryzelaar [Fri, 25 Jul 2014 14:20:55 +0000 (07:20 -0700)]
serialize: fix a warning

9 years agoFix a whitespace typo
Erick Tryzelaar [Thu, 17 Jul 2014 02:52:04 +0000 (19:52 -0700)]
Fix a whitespace typo

9 years agoImplement Hash for DList
nham [Tue, 29 Jul 2014 20:24:06 +0000 (16:24 -0400)]
Implement Hash for DList

9 years agoGedit/gtksourceview language spec: add raw strings
Simon Sapin [Tue, 29 Jul 2014 21:05:37 +0000 (22:05 +0100)]
Gedit/gtksourceview language spec: add raw strings

… and color (raw) strings as such in attributes.
This fixes cases where a string contains ] inside an attribute:
that ] used to incorrectly end the attribute coloring.

For large (many lines) doc comments, I’ve found preferable to use
`#![doc = r#"..."#]` to avoid prefixing every line with `//!`.

9 years agoElide lifetimes around Arc<T>.
OGINO Masanori [Tue, 29 Jul 2014 20:53:40 +0000 (05:53 +0900)]
Elide lifetimes around Arc<T>.

It's a small step forward in application of RFC 39 to the code base
itself.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
9 years agoUpdate LLVM to fix miscompilations due to wrongfully removed lifetime intrinsics
Björn Steinbrink [Tue, 29 Jul 2014 18:28:33 +0000 (20:28 +0200)]
Update LLVM to fix miscompilations due to wrongfully removed lifetime intrinsics

Fixes #15972 and #16011.

9 years agodoc: add missing word
Tshepang Lekhonkhobe [Tue, 29 Jul 2014 17:47:58 +0000 (19:47 +0200)]
doc: add missing word

9 years agomaking raw source display better
Alexis Beingessner [Tue, 29 Jul 2014 02:33:43 +0000 (22:33 -0400)]
making raw source display better

* Make the code fill up the full width of the page (no massive whitespace on the left)
* Move the code down to make it not intersect the logo
* Set a min-width and remove the max-width so that the code doesn't scroll internally, but instead scrolls the page, meaning horizontal scroll bars are always available
* Set overflow to actually overflow, just to be sure

Fixes #15891

9 years agorustc: Switch dsymutil status => output
Alex Crichton [Tue, 29 Jul 2014 01:14:56 +0000 (18:14 -0700)]
rustc: Switch dsymutil status => output

Sometimes dsymutil writes to stdout/stderr which rust isn't reading, which may
cause a deadlock.

Closes #16060

9 years agoadding discuss.rust-lang to community
Alexis Beingessner [Tue, 29 Jul 2014 01:15:12 +0000 (21:15 -0400)]
adding discuss.rust-lang to community

9 years agoFix documentation error in MutableVectorAllocating::move_from
donkopotamus [Mon, 28 Jul 2014 23:52:16 +0000 (11:52 +1200)]
Fix documentation error in MutableVectorAllocating::move_from

Correct `str` to `src`

9 years agoRemove references to non-existant functions in the std::path documentation
nham [Mon, 28 Jul 2014 23:32:47 +0000 (19:32 -0400)]
Remove references to non-existant functions in the std::path documentation

9 years agoImprove documentation of rounding functions
Piotr Jawniak [Mon, 28 Jul 2014 19:24:38 +0000 (21:24 +0200)]
Improve documentation of rounding functions

9 years agomanual: update list of feature gates, add phase attribute
Corey Richardson [Mon, 28 Jul 2014 21:31:46 +0000 (14:31 -0700)]
manual: update list of feature gates, add phase attribute

9 years agoRename Integer trait `divides` to `is_multiple_of`.
Jonas Hietala [Mon, 28 Jul 2014 14:03:01 +0000 (16:03 +0200)]
Rename Integer trait `divides` to `is_multiple_of`.

It is being changed because the previous wording was ambiguous.
`a.divides(b)` implied `a % b == 0` but it sounds like the other way
around. `9.divides(&3) == true` but we might read that as
"does 9 divide 3?".  It has been renamed to sidestep the ambiguity.

Work around the change by using `is_multiple_of` instead.

[breaking-change]

9 years agolint: Improve ffi-unsafe enum lint warning
Anton Lofgren [Tue, 22 Jul 2014 06:33:03 +0000 (08:33 +0200)]
lint: Improve ffi-unsafe enum lint warning

I think this is an improvement of the previous warning message, which
- like the comment that I removed implies - is in need of some
improvement.
I've opted to point the user in the right direction w.r.t how to fix the
problem, which I think is good form.

Not being familiar with the repr(...) attribute, I personally had to
check the lint rules myself to figure out what was wrong. Hopefully,
this will save he next person some time and headache.

Signed-off-by: Anton Lofgren <alofgren@op5.com>
9 years agoAdd pretty=typed test support to compiletest and add a test for fixed size arrays.
Luqman Aden [Tue, 22 Jul 2014 23:39:10 +0000 (16:39 -0700)]
Add pretty=typed test support to compiletest and add a test for fixed size arrays.

9 years agolibsyntax: Don't ICE on macro invocation in count expr of fixed array type.
Luqman Aden [Sat, 19 Jul 2014 07:06:43 +0000 (00:06 -0700)]
libsyntax: Don't ICE on macro invocation in count expr of fixed array type.

9 years agolibrustc: Typeck & record the count expr in TyFixedLengthVec.
Luqman Aden [Sat, 19 Jul 2014 06:54:57 +0000 (23:54 -0700)]
librustc: Typeck & record the count expr in TyFixedLengthVec.

9 years agoUpdate disclaimer to improve clarity and intent
Hugo Jobling [Tue, 1 Jul 2014 08:50:55 +0000 (09:50 +0100)]
Update disclaimer to improve clarity and intent

9 years agoauto merge of #15956 : steveklabnik/rust/guide_crates, r=pcwalton
bors [Tue, 29 Jul 2014 21:16:50 +0000 (21:16 +0000)]
auto merge of #15956 : steveklabnik/rust/guide_crates, r=pcwalton

Also fixes a couple of filesystem references that I forgot to change. :sweat_smile:

9 years agospeed up static linking by combining `ar` invocations
Stuart Pernsteiner [Thu, 3 Jul 2014 23:03:26 +0000 (16:03 -0700)]
speed up static linking by combining `ar` invocations

9 years agoauto merge of #16046 : dotdash/rust/call_ignore_alloca, r=pcwalton
bors [Tue, 29 Jul 2014 19:31:44 +0000 (19:31 +0000)]
auto merge of #16046 : dotdash/rust/call_ignore_alloca, r=pcwalton

9 years agoauto merge of #15989 : pcwalton/rust/borrowck-pattern-guards, r=pnkfelix
bors [Tue, 29 Jul 2014 17:41:41 +0000 (17:41 +0000)]
auto merge of #15989 : pcwalton/rust/borrowck-pattern-guards, r=pnkfelix

the CFG for match statements.

There were two bugs in issue #14684. One was simply that the borrow
check didn't know about the correct CFG for match statements: the
pattern must be a predecessor of the guard. This disallows the bad
behavior if there are bindings in the pattern. But it isn't enough to
prevent the memory safety problem, because of wildcards; thus, this
patch introduces a more restrictive rule, which disallows assignments
and mutable borrows inside guards outright.

I discussed this with Niko and we decided this was the best plan of
action.

This breaks code that performs mutable borrows in pattern guards. Most
commonly, the code looks like this:

    impl Foo {
        fn f(&mut self, ...) {}
        fn g(&mut self, ...) {
            match bar {
                Baz if self.f(...) => { ... }
                _ => { ... }
            }
        }
    }

Change this code to not use a guard. For example:

    impl Foo {
        fn f(&mut self, ...) {}
        fn g(&mut self, ...) {
            match bar {
                Baz => {
                    if self.f(...) {
                        ...
                    } else {
                        ...
                    }
                }
                _ => { ... }
            }
        }
    }

Sometimes this can result in code duplication, but often it illustrates
a hidden memory safety problem.

Closes #14684.

[breaking-change]

r? @pnkfelix

9 years agoNew Guide: crates and modules
Steve Klabnik [Thu, 24 Jul 2014 19:00:34 +0000 (15:00 -0400)]
New Guide: crates and modules

9 years agoauto merge of #16054 : tshepang/rust/patch-1, r=brson
bors [Tue, 29 Jul 2014 15:57:01 +0000 (15:57 +0000)]
auto merge of #16054 : tshepang/rust/patch-1, r=brson

9 years agoPort Rust to DragonFlyBSD
Michael Neumann [Tue, 29 Jul 2014 14:44:39 +0000 (16:44 +0200)]
Port Rust to DragonFlyBSD

Not included are two required patches:

* LLVM: segmented stack support for DragonFly [1]

* jemalloc: simple configure patches

[1]: http://reviews.llvm.org/D4705

9 years agoauto merge of #16052 : nham/rust/fs_docs, r=brson
bors [Tue, 29 Jul 2014 14:11:37 +0000 (14:11 +0000)]
auto merge of #16052 : nham/rust/fs_docs, r=brson

Some of the fixes include:

 - fixing mismatch between the documentation and the function parameters. (i.e. documentation references `path` parameter, but it's actually called `from`, or vice versa)
 - A few Error sections were missing an "if" on the middle clause. For example, they used to be: "This function will return an error if [Thing], [Another Thing], or if [Yet Another Thing]." I added an "if" so it becomes "This function will return an error if [Thing], if [Another Thing], or if [Yet Another Thing]"
 - The error sections previously started off with 3 different phrases:

     - "This function will return an error if ..."
     - "Will return an error if ..."
     - "This call will return an error if ..."

  I've standardized on the first phrase.