1. 16 9月, 2016 14 次提交
    • B
      Auto merge of #36353 - arielb1:union-drops, r=pnkfelix · c6673db5
      bors 提交于
      a few move-checker improvements
      
      This fixes moves out of unions and prohibits moves out of slices (see the individual commits).
      
      r? @pnkfelix
      c6673db5
    • A
      fix test fallout · 5c5f7522
      Ariel Ben-Yehuda 提交于
      5c5f7522
    • A
      fix dynamic drop for unions · eeedc144
      Ariel Ben-Yehuda 提交于
      Moving out of a union is now treated like moving out of its parent type.
      
      Fixes #36246
      eeedc144
    • A
      forbid moves out of slices · 7b25e886
      Ariel Ben-Yehuda 提交于
      The wording of RFC #495 enables moves out of slices. Unfortuantely, non-zeroing
      moves out of slices introduce a very annoying complication: as slices can
      vary in their length, indexes from the start and end may or may not overlap
      depending on the slice's exact length, which prevents assigning a particular
      drop flag for each individual element.
      
      For example, in the code
      
      ```Rust
      fn foo<T>(a: Box<[Box<[T]>]>, c: bool) -> T {
          match (a, c) {
              (box [box [t, ..], ..], true) => t,
              (box [.., box [.., t]], false) => t,
              _ => panic!()
          }
      }
      ```
      
      If the condition is false, we have to drop the first element
      of `a`, unless `a` has size 1 in which case we drop all the elements
      of it but the last.
      
      If someone comes with a nice way of handling it, we can always re-allow
      moves out of slices.
      
      This is a [breaking-change], but it is behind the `slice_patterns` feature
      gate and was not allowed until recently.
      7b25e886
    • A
      groundwork refactoring of `gather_moves` · eb19cd65
      Ariel Ben-Yehuda 提交于
      eb19cd65
    • B
      Auto merge of #36441 - alexcrichton:rustbuild-target, r=brson · 8394685b
      bors 提交于
      rustbuild: Fix cross-compiles to MinGW on Linux
      
      Closes #36290
      Closes #36291
      8394685b
    • B
      Auto merge of #36338 - estebank:primitive-shadow, r=jseyfried · 89500e93
      bors 提交于
      Be more specific when type parameter shadows primitive type
      
      When a type parameter shadows a primitive type, the error message
      was non obvious. For example, given the file `file.rs`:
      
      ```rust
      trait Parser<T> {
          fn parse(text: &str) -> Option<T>;
      }
      
      impl<bool> Parser<bool> for bool {
          fn parse(text: &str) -> Option<bool> {
              Some(true)
          }
      }
      
      fn main() {
          println!("{}", bool::parse("ok").unwrap_or(false));
      }
      ```
      
      The output was:
      
      ```bash
      % rustc file.rs
      error[E0308]: mismatched types
       --> file.rs:7:14
        |
      7 |         Some(true)
        |              ^^^^ expected type parameter, found bool a
        |
        = note: expected type `bool`
        = note:    found type `bool`
      
      error: aborting due to previous error
      ```
      
      We now show extra information about the type:
      
      ```bash
      % rustc file.rs
      error[E0308]: mismatched types
       --> file.rs:7:14
        |
      7 |         Some(true)
        |              ^^^^ expected type parameter, found bool a
        |
        = note: expected type `bool` (type parameter)
        = note:    found type `bool` (bool)
      
      error: aborting due to previous error
      ```
      
      Fixes #35030
      89500e93
    • B
      Auto merge of #36213 - josephDunne:dist_version, r=brson · a36e0692
      bors 提交于
      Add rustc version info (git hash + date) to dist tarball
      
      a fix for #32444
      a36e0692
    • E
      Specify when type parameter shadows primitive type · 68e8624d
      Esteban Küber 提交于
      When a type parameter shadows a primitive type, the error message
      was non obvious. For example, given the file `file.rs`:
      
      ```rust
      trait Parser<T> {
          fn parse(text: &str) -> Option<T>;
      }
      
      impl<bool> Parser<bool> for bool {
          fn parse(text: &str) -> Option<bool> {
              Some(true)
          }
      }
      
      fn main() {
          println!("{}", bool::parse("ok").unwrap_or(false));
      }
      ```
      
      The output was:
      
      ```bash
      % rustc file.rs
      error[E0308]: mismatched types
       --> file.rs:7:14
        |
      7 |         Some(true)
        |              ^^^^ expected type parameter, found bool
        |
        = note: expected type `bool`
        = note:    found type `bool`
      
      error: aborting due to previous error
      ```
      
      We now show extra information about the type:
      
      ```bash
      % rustc file.rs
      error[E0308]: mismatched types
       --> file.rs:7:14
        |
      7 |         Some(true)
        |              ^^^^ expected type parameter, found bool
        |
        = note: expected type `bool` (type parameter)
        = note:    found type `bool` (bool)
      
      error: aborting due to previous error
      ```
      
      Fixes #35030
      68e8624d
    • B
      Auto merge of #36439 - alexcrichton:fix-rustbuild, r=japaric · 5511a93c
      bors 提交于
      rustbuild: Fix dependency tracking with new Cargo
      
      The recent Cargo update changed filenames, which broke a lot of incremental
      rustbuild builds. What it thought were the output files were indeed no longer
      the output files! (wreaking havoc).
      
      This commit updates this to stop guessing filenames of Cargo and just manage
      stamp files instead.
      5511a93c
    • B
      Auto merge of #36393 - petrochenkov:ancient, r=eddyb · 1265cbf4
      bors 提交于
      Remove some obsolete code from the compiler
      1265cbf4
    • B
      Auto merge of #35992 - SimonSapin:rc-arc-ptr-eq, r=alexcrichton · d1acabea
      bors 提交于
      Add `pub fn ptr_eq(this: &Self, other: &Self) -> bool` to Rc and Arc
      
      Servo and Kuchiki have had helper functions doing this for some time.
      d1acabea
    • S
    • S
      Add `pub fn ptr_eq(this: &Self, other: &Self) -> bool` to `Rc` and `Arc`. · eba2270a
      Simon Sapin 提交于
      Servo and Kuchiki have had helper functions doing this for some time.
      eba2270a
  2. 15 9月, 2016 17 次提交
    • B
      Auto merge of #36491 - Manishearth:rollup, r=Manishearth · dc75933a
      bors 提交于
      Rollup of 9 pull requests
      
      - Successful merges: #36384, #36405, #36425, #36429, #36438, #36454, #36459, #36461, #36463
      - Failed merges: #36444
      dc75933a
    • M
      Rollup merge of #36463 - eugene-bulkin:duration-checked-ops, r=alexcrichton · ec081288
      Manish Goregaokar 提交于
      Add checked operation methods to Duration
      
      Addresses #35774.
      ec081288
    • M
      Rollup merge of #36461 - nikomatsakis:issue-36053, r=arielb1 · 0c9dc539
      Manish Goregaokar 提交于
      clear obligations-added flag with nested fulfillcx
      
      This flag is a debugging measure designed to detect cases where we start
      a snapshot, create type variables, register obligations involving those
      type variables in the fulfillment cx, and then have to unroll the
      snapshot, leaving "dangling type variables" behind.  HOWEVER, in some
      cases the flag is wrong. In particular, we sometimes create a
      "mini-fulfilment-cx" in which we enroll obligations. As long as this
      fulfillment cx is fully drained before we return, this is not a problem,
      as there won't be any escaping obligations in the main cx. So we add a
      fn to save/restore the flag.
      
      Fixes #36053.
      
      r? @arielb1
      0c9dc539
    • M
      Rollup merge of #36459 - nikomatsakis:issue-35546, r=eddyb · 959f764f
      Manish Goregaokar 提交于
      invoke drop glue with a ptr to (data, meta)
      
      This is done by creating a little space on the stack. Hokey, but it's the simplest fix I can see, and I am in "kill regressions" mode right now.
      
      Fixes #35546
      
      r? @EddyB
      959f764f
    • M
      Rollup merge of #36454 - bluss:slice-primitive-index, r=alexcrichton · 69a7f92a
      Manish Goregaokar 提交于
      Use primitive indexing in slice's Index/IndexMut
      
      [T]'s Index implementation is normally not used for indexing, instead
      the compiler supplied indexing is used.
      
      Use the compiler supplied version in Index/IndexMut.
      
      This removes an inconsistency:
      
      Compiler supplied bound check failures look like this:
      
      thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4'
      
      If you convince Rust to use the Index impl for slices, bounds check
      failure looks like this instead:
      
      thread 'main' panicked at 'assertion failed: index < self.len()'
      
      The latter is used if you for example use Index generically:
      
      ```rust
      use std::ops::Index;
      fn foo<T: ?Sized>(x: &T) where T: Index<usize> { &x[4]; }
      
      foo(&[1, 2, 3][..])
      ```
      69a7f92a
    • M
      Rollup merge of #36438 - jseyfried:node_ids_in_expansion, r=nrc · bab9238a
      Manish Goregaokar 提交于
      Assign node ids during macro expansion
      
      After this PR,
       - The `ExtCtxt` can access `resolve`'s `Resolver` through the trait object `ext::base::Resolver`.
        - The `Resolver` trait object can load macros and replaces today's `MacroLoader` trait object.
        - The macro expander uses the `Resolver` trait object to resolve macro invocations.
       - The macro expander assigns node ids and builds the `Resolver`'s `macros_at_scope` map.
         - This is groundwork for merging import resolution and expansion.
       - Performance of expansion together with node id assignment improves by ~5%.
      
      **EDIT:** Since Github is reordering the commits, here is `git log`:
       - b54e1e39: Differentiate between monotonic and non-monotonic expansion and only assign node ids during monotonic expansion.
       - 78c00398: Expand generated test harnesses and macro registries.
       - f3c2dca3: Remove scope placeholders from the crate root.
       - c86c8d41: Perform node id assignment and `macros_at_scope` construction during the `InvocationCollector` and `PlaceholderExpander` folds.
       - 72a63697: Move macro resolution into `librustc_resolve`.
       - 20b43b23: Rewrite the unit tests in `ext/expand.rs` as a `compile-fail` test.
       - a9821e16: Refactor `ExtCtxt` to use a `Resolver` instead of a `MacroLoader`.
       - 60440b22: Refactor `noop_fold_stmt_kind` out of `noop_fold_stmt`.
       - 50f94f6c: Avoid needless reexpansions.
      
      r? @nrc
      bab9238a
    • M
      Rollup merge of #36429 - durka:patch-30, r=nagisa · 23e0c24c
      Manish Goregaokar 提交于
      fix "X is not a member of trait Y" span labels
      
      Fixes #36428.
      23e0c24c
    • M
      Rollup merge of #36425 - michaelwoerister:stable-projection-bounds, r=eddyb · 7494bc7c
      Manish Goregaokar 提交于
      Fix indeterminism in ty::TraitObject representation.
      
      Make sure that projection bounds in `ty::TraitObject` are sorted in a way that is stable across compilation sessions and crate boundaries.
      
      This PR
      +  moves `DefPathHashes` up into `librustc` so it can be used there to create a stable sort key for `DefId`s,
      + changes `PolyExistentialProjection::sort_key()` to take advantage of the above,
      + and removes the unused `PolyProjectionPredicate::sort_key()` and `ProjectionTy::sort_key()` methods.
      
      Fixes #36155
      7494bc7c
    • M
      Rollup merge of #36405 - solson:typo, r=eddyb · ebef6ad0
      Manish Goregaokar 提交于
      Delete stray ` character in error message.
      ebef6ad0
    • M
      Rollup merge of #36384 - petrochenkov:derclone, r=alexcrichton · 72685017
      Manish Goregaokar 提交于
      Improve shallow `Clone` deriving
      
      `Copy` unions now support `#[derive(Clone)]`.
      Less code is generated for `#[derive(Clone, Copy)]`.
      +
      Unions now support `#[derive(Eq)]`.
      Less code is generated for `#[derive(Eq)]`.
      
      ---
      Example of code reduction:
      ```
      enum E {
      	A { a: u8, b: u16 },
      	B { c: [u8; 100] },
      }
      ```
      Before:
      ```
      fn clone(&self) -> E {
          match (&*self,) {
              (&E::A { a: ref __self_0, b: ref __self_1 },) => {
                  ::std::clone::assert_receiver_is_clone(&(*__self_0));
                  ::std::clone::assert_receiver_is_clone(&(*__self_1));
                  *self
              }
              (&E::B { c: ref __self_0 },) => {
                  ::std::clone::assert_receiver_is_clone(&(*__self_0));
                  *self
              }
          }
      }
      ```
      After:
      ```
      fn clone(&self) -> E {
          {
              let _: ::std::clone::AssertParamIsClone<u8>;
              let _: ::std::clone::AssertParamIsClone<u16>;
              let _: ::std::clone::AssertParamIsClone<[u8; 100]>;
              *self
          }
      }
      ```
      
      All the matches are removed, bound assertions are more lightweight.
      `let _: Checker<CheckMe>;`, unlike `checker(&check_me);`, doesn't have to be translated by rustc_trans and then inlined by LLVM, it doesn't even exist in MIR, this means faster compilation.
      
      ---
      Union impls are generated like this:
      ```
      union U {
      	a: u8,
      	b: u16,
      	c: [u8; 100],
      }
      ```
      ```
      fn clone(&self) -> U {
          {
              let _: ::std::clone::AssertParamIsCopy<Self>;
              *self
          }
      }
      ```
      
      Fixes https://github.com/rust-lang/rust/issues/36043
      cc @durka
      r? @alexcrichton
      72685017
    • B
      Auto merge of #36372 - sfackler:sum-prod-overflow, r=alexcrichton · e2c64d16
      bors 提交于
      Inherit overflow checks for sum and product
      
      We have previously documented the fact that these will panic on overflow, but I think this behavior is what people actually want/expect. `#[rustc_inherit_overflow_checks]` didn't exist when we discussed these for stabilization.
      
      r? @alexcrichton
      
      Closes #35807
      e2c64d16
    • B
      Auto merge of #36347 - knight42:str-replacen, r=alexcrichton · 16ff9e22
      bors 提交于
      Implement std::str::replacen
      
      Replaces first N matches of a pattern with another string.
      
      ```
      assert_eq!("acaaa".replacen(a, "b", 3), "bcbba")
      ```
      16ff9e22
    • E
      b6321bd1
    • E
      Fix doc-tests for Duration · f2eb4f11
      Eugene Bulkin 提交于
      f2eb4f11
    • B
      6ffdda1b
    • B
      Auto merge of #36270 - petrochenkov:pipwarnagain, r=nikomatsakis · 5bdf79bf
      bors 提交于
      Make `private_in_public` compatibility lint warn-by-default again
      
      More details: https://internals.rust-lang.org/t/regression-report-stable-2016-08-16-vs-beta-2016-08-26/3930/10
      
      r? @nikomatsakis
      5bdf79bf
    • U
      core: Use primitive indexing in slice's Index/IndexMut · a4ee9c6e
      Ulrik Sverdrup 提交于
      [T]'s Index implementation is normally not used for indexing, instead
      the compiler supplied indexing is used.
      
      Use the compiler supplied version in Index/IndexMut.
      
      This removes an inconsistency:
      
      Compiler supplied bound check failures look like this:
      
      thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4'
      
      If you convince Rust to use the Index impl for slices, bounds check
      failure looks like this instead:
      
      thread 'main' panicked at 'assertion failed: index < self.len()'
      
      The latter is used if you for example use Index generically::
      
         use std::ops::Index;
         fn foo<T: ?Sized>(x: &T) where T: Index<usize> { &x[4]; }
      
         foo(&[1, 2, 3][..])
      a4ee9c6e
  3. 14 9月, 2016 9 次提交