Permalink
Commits on Aug 2, 2014
  1. auto merge of #16175 : EduardoBautista/rust/fix-guessing-game-appeari…

    …ng-early, r=steveklabnik
    
    Solves: rust-lang#16162
    bors committed Aug 2, 2014
  2. auto merge of #16165 : tinaun/rust/newcss, r=alexcrichton

    remove unneeded `pre.rust a' selector
    
    move transform into `.test-arrow`
    
    fixes #16138
    bors committed Aug 2, 2014
  3. auto merge of #16163 : anguslees/rust/strptime-str, r=alexcrichton

    Also modernise a few constructs in match_strs().
    bors committed Aug 2, 2014
  4. auto merge of #16160 : EduardoBautista/rust/use-bang-at-end-of-hello-…

    …world, r=alexcrichton
    
    Further into the guide "Hello, world!" is used instead of "Hello, world".
    bors committed Aug 2, 2014
  5. auto merge of #16128 : steveklabnik/rust/speed_faq, r=brson

    Fixes #11174.
    
    I'm open to revising this text, but I figured it gets across the basics.
    bors committed Aug 2, 2014
  6. auto merge of #16119 : steveklabnik/rust/guide_pointers, r=brson

    This is the next section of the guide, and it's on pointers. It's not done yet, as I need to write the section on ownership and borrowing, but I figured I'd share the rest now, to get feedback on the rest of it while I take some time to get that right.
    bors committed Aug 2, 2014
Commits on Aug 1, 2014
  1. auto merge of #15995 : Ryman/rust/sync_spsc_peek, r=alexcrichton

    The current spsc implementation doesn't enforce single-producer
    single-consumer usage and also allows unsafe memory use through
    peek & pop.
    
    For safer usage, `new` now returns a pair of owned objects which
    only allow consumer or producer behaviors through an `Arc`.
    Through restricting the mutability of the receiver to `mut` the
    peek and pop behavior becomes safe again, with the compiler
    complaining about usage which could lead to problems.
    
    To fix code broken from this, update:
    Queue::new(x) -> unsafe { Queue::unchecked_new(x) }
    
    [breaking-change]
    
    For an example of broken behavior, check the added test which uses the unchecked constructor.
    bors committed Aug 1, 2014
  2. auto merge of #15992 : steveklabnik/rust/guide_testing, r=brson

    The start of a testing guide. This PR relies on the crates and modules one because I shuffled some stuff around, so sorry about that.
    
    I got stuck with how to import this name with cargo. @wycats and @alexcrichton , any ideas?
    bors committed Aug 1, 2014
  3. libsync: Add safer abstraction for SPSC queue.

    The current spsc implementation doesn't enforce single-producer
    single-consumer usage and also allows unsafe memory use through
    peek & pop.
    
    For safer usage, `spsc_queue::queue` now returns a pair of owned objects which
    only allow consumer or producer behaviours through an `Arc`.
    Through restricting the mutability of the receiver to `mut` the
    peek and pop behaviour becomes safe again, with the compiler
    complaining about usage which could lead to problems.
    
    To fix code broken from this, update:
    Queue::new(x) -> unsafe { Queue::new(x) }
    
    [breaking-change]
    Ryman committed Jul 25, 2014
  4. auto merge of #16102 : zwarich/rust/borrowck-unboxed, r=pcwalton

    This removes the ability of the borrow checker to determine that repeated dereferences of a Box<T> refer to the same memory object.
    bors committed Aug 1, 2014
  5. auto merge of #16053 : pcwalton/rust/at-pattern-bindings, r=pnkfelix

    This is an alternative to upgrading the way rvalues are handled in the
    borrow check. Making rvalues handled more like lvalues in the borrow
    check caused numerous problems related to double mutable borrows and
    rvalue scopes. Rather than come up with more borrow check rules to try
    to solve these problems, I decided to just forbid pattern bindings after
    `@`. This affected fewer than 10 lines of code in the compiler and
    libraries.
    
    This breaks code like:
    
        match x {
            y @ z => { ... }
        }
    
        match a {
            b @ Some(c) => { ... }
        }
    
    Change this code to use nested `match` or `let` expressions. For
    example:
    
        match x {
            y => {
                let z = y;
                ...
            }
        }
    
        match a {
            Some(c) => {
                let b = Some(c);
                ...
            }
        }
    
    Closes #14587.
    
    [breaking-change]
    
    May need discussion at the meeting, but r? @nikomatsakis anyway
    bors committed Aug 1, 2014
  6. librustc: Forbid pattern bindings after `@`s, for memory safety.

    This is an alternative to upgrading the way rvalues are handled in the
    borrow check. Making rvalues handled more like lvalues in the borrow
    check caused numerous problems related to double mutable borrows and
    rvalue scopes. Rather than come up with more borrow check rules to try
    to solve these problems, I decided to just forbid pattern bindings after
    `@`. This affected fewer than 10 lines of code in the compiler and
    libraries.
    
    This breaks code like:
    
        match x {
            y @ z => { ... }
        }
    
        match a {
            b @ Some(c) => { ... }
        }
    
    Change this code to use nested `match` or `let` expressions. For
    example:
    
        match x {
            y => {
                let z = y;
                ...
            }
        }
    
        match a {
            Some(c) => {
                let b = Some(c);
                ...
            }
        }
    
    Closes #14587.
    
    [breaking-change]
    pcwalton committed Jul 28, 2014
  7. auto merge of #16157 : alexcrichton/rust/rustdoc-tests, r=huonw

    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.
    bors committed Aug 1, 2014
  8. auto merge of #16153 : kballard/rust/fix_gensym_symbols, r=luqmana

    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$.
    bors committed Aug 1, 2014
  9. auto merge of #16101 : kballard/rust/rc_unique_ownership, r=aturon

    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.
    bors committed Aug 1, 2014
  10. 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.
    kballard committed Jul 3, 2014
  11. Fix API docs css reversing elements that it shouldn't

    remove unneeded `pre.rust a' selector
    
    move transform into `.test-arrow`
    
    fixes #16138
    tinaun committed Aug 1, 2014
  12. 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.
    alexcrichton committed Aug 1, 2014
  13. 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.
    bors committed Aug 1, 2014
  14. Change strptime::match_strs to use borrowed rather than owned strings

    Also modernise a few constructs in match_strs().
    anguslees committed Aug 1, 2014
  15. 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]
    apoelstra committed Jul 31, 2014
  16. 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$.
    kballard committed Aug 1, 2014
Commits on Jul 31, 2014
  1. 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)
    bors committed Jul 31, 2014
  2. Add some benchmarks for TLD

    kballard committed Jul 4, 2014
  3. 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.
    kballard committed Jul 4, 2014
  4. 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)
    kballard committed Jul 3, 2014