Commit Graph

31268 Commits

Author SHA1 Message Date
Kevin Ballard
192a8a5db7 Add is_unique(), try_unwrap(), get_mut() to alloc::rc
Add a few new free functions to alloc::rc for manipulating
uniquely-owned Rc values. is_unique() can be used to test if the Rc is
uniquely-owned, try_unwrap() can remove the value from a uniquely-owned
Rc, and get_mut() can return a &mut for a uniquely-owned Rc.

These are all free functions, because smart pointers should avoid having
methods when possible. They can't be static methods because UFCS will
remove that distinction. I think we should probably change downgrade()
and make_unique() into free functions as well, but that's out of scope.
2014-08-01 01:20:20 -07:00
tinaun
42b2dc06b6 Fix API docs css reversing elements that it shouldn't
remove unneeded `pre.rust a' selector

move transform into `.test-arrow`

fixes #16138
2014-08-01 04:01:29 -04:00
bors
cd1216a054 auto merge of #16152 : tshepang/rust/patch-1, r=alexcrichton 2014-08-01 07:56:06 +00:00
Alex Crichton
4dbe3eb657 rustdoc: Use --crate-name with --test
This ensures that the name of the crate is set from the command line for tests
so the auto-injection of `extern crate <name>` in doc tests works correctly.
2014-07-31 23:01:24 -07:00
bors
9f0b91985f 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.
2014-08-01 05:41:05 +00:00
Angus Lees
17d5c64941 Change strptime::match_strs to use borrowed rather than owned strings
Also modernise a few constructs in match_strs().
2014-08-01 15:39:00 +10:00
Andrew Poelstra
dac9a1c520 libuuid: use Decoder::error() rather than failing on bad decode 2014-07-31 21:41:19 -07:00
Andrew Poelstra
5bd8edc112 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]
2014-07-31 21:41:19 -07:00
Angus Lees
4d52e436c4 Correct RFC reference in time::Tm::rfc3339 docs
Fixes #16158
2014-08-01 14:08:04 +10:00
Eduardo Bautista
c0048dec4a Be more consistent with "Hello, world!" 2014-07-31 23:02:22 -05:00
Kevin Ballard
ff3d902fcb Stop using the Show impl for ast::Name in our symbols
When generating a unique symbol for things like closures or glue_drop,
we call token::gensym() to create a crate-unique Name. Recently, Name
changed its Show impl so it no longer prints as a number. This caused
symbols like glue_drop:1542 to become glue_drop:"glue_drop"(1542), or in
mangled form, glue_drop.$x22glue_drop$x22$LP$1542$RP$.
2014-07-31 19:05:45 -07:00
bors
b495933a7f auto merge of #16141 : alexcrichton/rust/rollup, r=alexcrichton 2014-08-01 01:56:32 +00:00
Tshepang Lekhonkhobe
4dc323f019 doc: fix typos in std::num::Int 2014-08-01 02:43:51 +02:00
bors
75a39e0fb8 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)
2014-07-31 23:16:33 +00:00
Kevin Ballard
e65bcff7d5 Add some benchmarks for TLD 2014-07-31 13:14:06 -07:00
Kevin Ballard
24a62e176a 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.
2014-07-31 13:14:06 -07:00
Kevin Ballard
4b74dc167c 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)
2014-07-31 13:14:03 -07:00
Alex Crichton
ec79d368d2 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.)
2014-07-31 13:05:12 -07:00
bors
2eb3ab19ac auto merge of #16041 : treeman/rust/doc-rand, r=brson
A larger example for `std::rand`.
2014-07-31 19:36:34 +00:00
OGINO Masanori
f86184869a alloc, arena, test, url, uuid: Elide lifetimes.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-31 11:50:24 -07:00
Derek Harland
2467c6e5a7 Implement slice::Vector for Option<T> and CVec<T> 2014-07-31 11:50:24 -07:00
Luqman Aden
bc24819bb2 librustc: Don't ICE with struct exprs where the name is not a valid struct. 2014-07-31 11:50:24 -07:00
Luqman Aden
bd15854114 librustc: Don't ICE when trying to subst regions in destructor call. 2014-07-31 11:50:24 -07:00
Steve Klabnik
fd08d5fb2e Add note about production deployments.
Fixes #11511.
2014-07-31 11:50:24 -07:00
Steve Klabnik
daaa20e565 Remove incorrect example
This now works because of elision.

Fixes #16117
2014-07-31 11:50:24 -07:00
Ilya Dmitrichenko
a5e74a93c3 Deprecate fourcc. 2014-07-31 11:50:24 -07:00
Ilya Dmitrichenko
a8f58a056a Deprecate uuid. 2014-07-31 11:50:23 -07:00
Ilya Dmitrichenko
5446aed289 Deprecate semver. 2014-07-31 11:50:23 -07:00
Simon Sapin
cdb8a88717 Add a non-regression test for issue #8372 2014-07-31 11:50:23 -07:00
Simon Sapin
efd42a355d Byte literals! 2014-07-31 11:50:23 -07:00
nham
acbac845f8 Add logic to skip the doc tests on windows since these examples are unix-specific 2014-07-31 11:50:23 -07:00
nham
a0238d54aa Use byte strings throughout examples. Add an example that was missed in the last commit. 2014-07-31 11:50:23 -07:00
nham
9956aff18a Add examples for GenericPath methods. 2014-07-31 11:50:23 -07:00
Alex Crichton
c3fcc0bc51 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
2014-07-31 11:50:23 -07:00
Steve Klabnik
a74197e3f1 Guide: pointers
Not the pointer guide, but the guide section on pointers.

Adding a section about patterns for after this, as well.
2014-07-31 14:39:16 -04:00
bors
8c00357f9d 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
2014-07-31 16:41:36 +00:00
bors
9826e801be 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
2014-07-31 14:41:34 +00:00
Alex Crichton
ecac4d2e6c 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
2014-07-31 07:30:53 -07:00
Steve Klabnik
20658f7ec5 Fix heading levels in pointer guide 2014-07-31 07:30:52 -07:00
Erick Tryzelaar
fd9ad77bd2 Move SeekableMemWriter into librbml 2014-07-31 07:30:50 -07:00
Erick Tryzelaar
e1dcbefe52 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]
2014-07-31 07:30:49 -07:00
Steve Klabnik
ea1b637654 fix formatting in pointer guide table 2014-07-31 07:30:48 -07:00
Tobias Bucher
4c196c27c4 Fix deprecation commment on core::cmp::lexical_ordering 2014-07-31 07:30:45 -07:00
Brian Anderson
4562803a3d core: Fix failure doc comment 2014-07-31 07:30:17 -07:00
Brian Anderson
678814aafa core: Add #[inline(never)] to failure functions
For consistency, just because `fail_` has it.
2014-07-31 07:30:17 -07:00
Brian Anderson
4db68e644e 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
```
2014-07-31 07:30:17 -07:00
Brian Anderson
134946d06e rustrt: Make begin_unwind take a single file/line pointer
Smaller text size.
2014-07-31 07:30:17 -07:00
DJUrsus
571f6cf29a fix variable name in tutorial 2014-07-31 07:30:14 -07:00
bors
311a970621 auto merge of #16090 : epdtry/rust/doesnt-use-gc, r=alexcrichton 2014-07-31 13:01:35 +00:00
bors
8cda74c4b5 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
2014-07-31 11:16:35 +00:00