1. 24 7月, 2014 3 次提交
  2. 20 7月, 2014 1 次提交
    • P
      librustc: Implement lifetime elision. · 6f99a278
      Patrick Walton 提交于
      This implements RFC 39. Omitted lifetimes in return values will now be
      inferred to more useful defaults, and an error is reported if a lifetime
      in a return type is omitted and one of the two lifetime elision rules
      does not specify what it should be.
      
      This primarily breaks two uncommon code patterns. The first is this:
      
          unsafe fn get_foo_out_of_thin_air() -> &Foo {
              ...
          }
      
      This should be changed to:
      
          unsafe fn get_foo_out_of_thin_air() -> &'static Foo {
              ...
          }
      
      The second pattern that needs to be changed is this:
      
          enum MaybeBorrowed<'a> {
              Borrowed(&'a str),
              Owned(String),
          }
      
          fn foo() -> MaybeBorrowed {
              Owned(format!("hello world"))
          }
      
      Change code like this to:
      
          enum MaybeBorrowed<'a> {
              Borrowed(&'a str),
              Owned(String),
          }
      
          fn foo() -> MaybeBorrowed<'static> {
              Owned(format!("hello world"))
          }
      
      Closes #15552.
      
      [breaking-change]
      6f99a278
  3. 18 7月, 2014 1 次提交
  4. 14 7月, 2014 1 次提交
    • A
      Stabilization for `owned` (now `boxed`) and `cell` · e0ede9c6
      Aaron Turon 提交于
      This PR is the outcome of the library stabilization meeting for the
      `liballoc::owned` and `libcore::cell` modules.
      
      Aside from the stability attributes, there are a few breaking changes:
      
      * The `owned` modules is now named `boxed`, to better represent its
        contents. (`box` was unavailable, since it's a keyword.) This will
        help avoid the misconception that `Box` plays a special role wrt
        ownership.
      
      * The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move`
        method is renamed to `downcast`, in both cases to improve clarity.
      
      * The recently-added `AnySendOwnExt` extension trait is removed; it was
        not being used and is unnecessary.
      
      [breaking-change]
      e0ede9c6
  5. 09 7月, 2014 1 次提交
  6. 30 6月, 2014 1 次提交
    • S
      Implement RFC#28: Add PartialOrd::partial_cmp · 55cae0a0
      Steven Fackler 提交于
      I ended up altering the semantics of Json's PartialOrd implementation.
      It used to be the case that Null < Null, but I can't think of any reason
      for an ordering other than the default one so I just switched it over to
      using the derived implementation.
      
      This also fixes broken `PartialOrd` implementations for `Vec` and
      `TreeMap`.
      
      RFC: 0028-partial-cmp
      55cae0a0
  7. 29 6月, 2014 1 次提交
  8. 25 6月, 2014 2 次提交
  9. 10 6月, 2014 1 次提交
  10. 09 6月, 2014 2 次提交
  11. 07 6月, 2014 2 次提交
    • A
      Implement Show for DList · f1bff592
      Adolfo Ochagavía 提交于
      f1bff592
    • A
      Rename Iterator::len to count · 1bde6e3f
      Aaron Turon 提交于
      This commit carries out the request from issue #14678:
      
      > The method `Iterator::len()` is surprising, as all the other uses of
      > `len()` do not consume the value. `len()` would make more sense to be
      > called `count()`, but that would collide with the current
      > `Iterator::count(|T| -> bool) -> unit` method. That method, however, is
      > a bit redundant, and can be easily replaced with
      > `iter.filter(|x| x < 5).count()`.
      > After this change, we could then define the `len()` method
      > on `iter::ExactSize`.
      
      Closes #14678.
      
      [breaking-change]
      1bde6e3f
  12. 06 6月, 2014 2 次提交
    • A
      Fallout from the libcollections movement · 760b93ad
      Alex Crichton 提交于
      760b93ad
    • A
      std: Recreate a `collections` module · 6a585375
      Alex Crichton 提交于
      As with the previous commit with `librand`, this commit shuffles around some
      `collections` code. The new state of the world is similar to that of librand:
      
      * The libcollections crate now only depends on libcore and liballoc.
      * The standard library has a new module, `std::collections`. All functionality
        of libcollections is reexported through this module.
      
      I would like to stress that this change is purely cosmetic. There are very few
      alterations to these primitives.
      
      There are a number of notable points about the new organization:
      
      * std::{str, slice, string, vec} all moved to libcollections. There is no reason
        that these primitives shouldn't be necessarily usable in a freestanding
        context that has allocation. These are all reexported in their usual places in
        the standard library.
      
      * The `hashmap`, and transitively the `lru_cache`, modules no longer reside in
        `libcollections`, but rather in libstd. The reason for this is because the
        `HashMap::new` contructor requires access to the OSRng for initially seeding
        the hash map. Beyond this requirement, there is no reason that the hashmap
        could not move to libcollections.
      
        I do, however, have a plan to move the hash map to the collections module. The
        `HashMap::new` function could be altered to require that the `H` hasher
        parameter ascribe to the `Default` trait, allowing the entire `hashmap` module
        to live in libcollections. The key idea would be that the default hasher would
        be different in libstd. Something along the lines of:
      
            // src/libstd/collections/mod.rs
      
            pub type HashMap<K, V, H = RandomizedSipHasher> =
                  core_collections::HashMap<K, V, H>;
      
        This is not possible today because you cannot invoke static methods through
        type aliases. If we modified the compiler, however, to allow invocation of
        static methods through type aliases, then this type definition would
        essentially be switching the default hasher from `SipHasher` in libcollections
        to a libstd-defined `RandomizedSipHasher` type. This type's `Default`
        implementation would randomly seed the `SipHasher` instance, and otherwise
        perform the same as `SipHasher`.
      
        This future state doesn't seem incredibly far off, but until that time comes,
        the hashmap module will live in libstd to not compromise on functionality.
      
      * In preparation for the hashmap moving to libcollections, the `hash` module has
        moved from libstd to libcollections. A previously snapshotted commit enables a
        distinct `Writer` trait to live in the `hash` module which `Hash`
        implementations are now parameterized over.
      
        Due to using a custom trait, the `SipHasher` implementation has lost its
        specialized methods for writing integers. These can be re-added
        backwards-compatibly in the future via default methods if necessary, but the
        FNV hashing should satisfy much of the need for speedier hashing.
      
      A list of breaking changes:
      
      * HashMap::{get, get_mut} no longer fails with the key formatted into the error
        message with `{:?}`, instead, a generic message is printed. With backtraces,
        it should still be not-too-hard to track down errors.
      
      * The HashMap, HashSet, and LruCache types are now available through
        std::collections instead of the collections crate.
      
      * Manual implementations of hash should be parameterized over `hash::Writer`
        instead of just `Writer`.
      
      [breaking-change]
      6a585375
  13. 02 6月, 2014 1 次提交
    • A
      std: Drop Total from Total{Eq,Ord} · bba701c5
      Alex Crichton 提交于
      This completes the last stage of the renaming of the comparison hierarchy of
      traits. This change renames TotalEq to Eq and TotalOrd to Ord.
      
      In the future the new Eq/Ord will be filled out with their appropriate methods,
      but for now this change is purely a renaming change.
      
      [breaking-change]
      bba701c5
  14. 31 5月, 2014 1 次提交
    • A
      std: Rename {Eq,Ord} to Partial{Eq,Ord} · 748bc3ca
      Alex Crichton 提交于
      This is part of the ongoing renaming of the equality traits. See #12517 for more
      details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord}
      or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}.
      
      cc #12517
      
      [breaking-change]
      748bc3ca
  15. 30 5月, 2014 1 次提交
    • A
      std: Recreate a `rand` module · 925ff651
      Alex Crichton 提交于
      This commit shuffles around some of the `rand` code, along with some
      reorganization. The new state of the world is as follows:
      
      * The librand crate now only depends on libcore. This interface is experimental.
      * The standard library has a new module, `std::rand`. This interface will
        eventually become stable.
      
      Unfortunately, this entailed more of a breaking change than just shuffling some
      names around. The following breaking changes were made to the rand library:
      
      * Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which
        will return an infinite stream of random values. Previous behavior can be
        regained with `rng.gen_iter().take(n).collect()`
      
      * Rng::gen_ascii_str() was removed. This has been replaced with
        Rng::gen_ascii_chars() which will return an infinite stream of random ascii
        characters. Similarly to gen_iter(), previous behavior can be emulated with
        `rng.gen_ascii_chars().take(n).collect()`
      
      * {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
        relied on being able to use an OSRng for seeding, but this is no longer
        available in librand (where these types are defined). To retain the same
        functionality, these types now implement the `Rand` trait so they can be
        generated with a random seed from another random number generator. This allows
        the stdlib to use an OSRng to create seeded instances of these RNGs.
      
      * Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
        pretty rare in the codebase, and it allows for librand to not depend on
        liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
        supported.  If this is undesirable, librand can depend on liballoc and regain
        these implementations.
      
      * The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
        but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
        structure now has a lifetime associated with it.
      
      * The `sample` method on `Rng` has been moved to a top-level function in the
        `rand` module due to its dependence on `Vec`.
      
      cc #13851
      
      [breaking-change]
      925ff651
  16. 25 5月, 2014 1 次提交
  17. 23 5月, 2014 1 次提交
  18. 19 5月, 2014 1 次提交
  19. 11 5月, 2014 1 次提交
    • A
      core: Remove the cast module · f94d671b
      Alex Crichton 提交于
      This commit revisits the `cast` module in libcore and libstd, and scrutinizes
      all functions inside of it. The result was to remove the `cast` module entirely,
      folding all functionality into the `mem` module. Specifically, this is the fate
      of each function in the `cast` module.
      
      * transmute - This function was moved to `mem`, but it is now marked as
                    #[unstable]. This is due to planned changes to the `transmute`
                    function and how it can be invoked (see the #[unstable] comment).
                    For more information, see RFC 5 and #12898
      
      * transmute_copy - This function was moved to `mem`, with clarification that is
                         is not an error to invoke it with T/U that are different
                         sizes, but rather that it is strongly discouraged. This
                         function is now #[stable]
      
      * forget - This function was moved to `mem` and marked #[stable]
      
      * bump_box_refcount - This function was removed due to the deprecation of
                            managed boxes as well as its questionable utility.
      
      * transmute_mut - This function was previously deprecated, and removed as part
                        of this commit.
      
      * transmute_mut_unsafe - This function doesn't serve much of a purpose when it
                               can be achieved with an `as` in safe code, so it was
                               removed.
      
      * transmute_lifetime - This function was removed because it is likely a strong
                             indication that code is incorrect in the first place.
      
      * transmute_mut_lifetime - This function was removed for the same reasons as
                                 `transmute_lifetime`
      
      * copy_lifetime - This function was moved to `mem`, but it is marked
                        `#[unstable]` now due to the likelihood of being removed in
                        the future if it is found to not be very useful.
      
      * copy_mut_lifetime - This function was also moved to `mem`, but had the same
                            treatment as `copy_lifetime`.
      
      * copy_lifetime_vec - This function was removed because it is not used today,
                            and its existence is not necessary with DST
                            (copy_lifetime will suffice).
      
      In summary, the cast module was stripped down to these functions, and then the
      functions were moved to the `mem` module.
      
          transmute - #[unstable]
          transmute_copy - #[stable]
          forget - #[stable]
          copy_lifetime - #[unstable]
          copy_mut_lifetime - #[unstable]
      
      [breaking-change]
      f94d671b
  20. 07 5月, 2014 1 次提交
    • P
      librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except · 090040bf
      Patrick Walton 提交于
      for `~str`/`~[]`.
      
      Note that `~self` still remains, since I forgot to add support for
      `Box<self>` before the snapshot.
      
      How to update your code:
      
      * Instead of `~EXPR`, you should write `box EXPR`.
      
      * Instead of `~TYPE`, you should write `Box<Type>`.
      
      * Instead of `~PATTERN`, you should write `box PATTERN`.
      
      [breaking-change]
      090040bf
  21. 03 5月, 2014 1 次提交
  22. 29 4月, 2014 1 次提交
    • J
      Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is... · 03609e5a
      Jonathan S 提交于
      Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is provided (everywhere but treemap)
      
      This commit deprecates rev_iter, mut_rev_iter, move_rev_iter everywhere (except treemap) and also
      deprecates related functions like rsplit, rev_components, and rev_str_components. In every case,
      these functions can be replaced with the non-reversed form followed by a call to .rev(). To make this
      more concrete, a translation table for all functional changes necessary follows:
      
      * container.rev_iter() -> container.iter().rev()
      * container.mut_rev_iter() -> container.mut_iter().rev()
      * container.move_rev_iter() -> container.move_iter().rev()
      * sliceorstr.rsplit(sep) -> sliceorstr.split(sep).rev()
      * path.rev_components() -> path.components().rev()
      * path.rev_str_components() -> path.str_components().rev()
      
      In terms of the type system, this change also deprecates any specialized reversed iterator types (except
      in treemap), opting instead to use Rev directly if any type annotations are needed. However, since
      methods directly returning reversed iterators are now discouraged, the need for such annotations should
      be small. However, in those cases, the general pattern for conversion is to take whatever follows Rev in
      the original reversed name and surround it with Rev<>:
      
      * RevComponents<'a> -> Rev<Components<'a>>
      * RevStrComponents<'a> -> Rev<StrComponents<'a>>
      * RevItems<'a, T> -> Rev<Items<'a, T>>
      * etc.
      
      The reasoning behind this change is that it makes the standard API much simpler without reducing readability,
      performance, or power. The presence of functions such as rev_iter adds more boilerplate code to libraries
      (all of which simply call .iter().rev()), clutters up the documentation, and only helps code by saving two
      characters. Additionally, the numerous type synonyms that were used to make the type signatures look nice
      like RevItems add even more boilerplate and clutter up the docs even more. With this change, all that cruft
      goes away.
      
      [breaking-change]
      03609e5a
  23. 11 4月, 2014 1 次提交
  24. 09 4月, 2014 1 次提交
  25. 01 4月, 2014 1 次提交
  26. 31 3月, 2014 1 次提交
  27. 30 3月, 2014 1 次提交
  28. 26 3月, 2014 1 次提交
  29. 12 3月, 2014 1 次提交
  30. 08 3月, 2014 1 次提交
  31. 01 3月, 2014 1 次提交
    • A
      std: Change assert_eq!() to use {} instead of {:?} · 02882fbd
      Alex Crichton 提交于
      Formatting via reflection has been a little questionable for some time now, and
      it's a little unfortunate that one of the standard macros will silently use
      reflection when you weren't expecting it. This adds small bits of code bloat to
      libraries, as well as not always being necessary. In light of this information,
      this commit switches assert_eq!() to using {} in the error message instead of
      {:?}.
      
      In updating existing code, there were a few error cases that I encountered:
      
      * It's impossible to define Show for [T, ..N]. I think DST will alleviate this
        because we can define Show for [T].
      * A few types here and there just needed a #[deriving(Show)]
      * Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
      * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
        I don't think this is much of a regression though because {:?} on paths looks
        awful (it's a byte array).
      
      Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
      significant for smaller binaries.
      02882fbd
  32. 25 2月, 2014 1 次提交
  33. 20 2月, 2014 1 次提交
  34. 16 2月, 2014 1 次提交