1. 06 11月, 2016 18 次提交
    • A
      Rollup merge of #37587 - ollie27:to_mut, r=alexcrichton · 5bce6ad1
      Alex Crichton 提交于
      Remove recursive call from Cow::to_mut
      
      It seems to prevent it from being inlined.
      5bce6ad1
    • A
      Rollup merge of #37586 - TimNN:fix-37559, r=alexcrichton · 78f18647
      Alex Crichton 提交于
      fix #37559: update compiler-rt
      
      Fixes #37559
      
      r? @alexcrichton
      78f18647
    • A
      Rollup merge of #37585 - leodasvacas:change_into_to_from, r=alexcrichton · 727f1d3f
      Alex Crichton 提交于
      Change `Into<Vec<u8>> for String` and `Into<OsString> for PathBuf` to From
      
      Fixes #37561. First contribution, happy with any and all feedback!
      727f1d3f
    • A
      Rollup merge of #37583 - michaelwoerister:hir-stats, r=alexcrichton · 0670d4b7
      Alex Crichton 提交于
      Add `-Z hir-stats` for collecting statistics on HIR and AST
      
      The data collected will be printed to the commandline and looks like the following:
      
      ```
      // stats for libcore
      
      PRE EXPANSION AST STATS
      
      Name                Accumulated Size         Count     Item Size
      ----------------------------------------------------------------
      TypeBinding                    2_280            57            40
      Mod                            3_560            89            40
      PathListItem                   6_516           181            36
      Variant                        7_872            82            96
      LifetimeDef                   21_280           380            56
      StructField                   22_880           260            88
      Lifetime                      23_800         1_190            20
      Local                         30_192           629            48
      ForeignItem                   31_504           179           176
      Arm                           42_880           670            64
      Mac                           46_960           587            80
      FnDecl                        57_792         1_204            48
      TraitItem                     69_504           362           192
      TyParamBound                  98_280           945           104
      Block                        108_384         2_258            48
      Stmt                         144_720         3_618            40
      ImplItem                     230_272         1_028           224
      Item                         467_456         1_826           256
      Pat                          517_776         4_623           112
      Attribute                    745_680        15_535            48
      Ty                         1_114_848         9_954           112
      PathSegment                1_218_528        16_924            72
      Expr                       3_082_408        20_279           152
      ----------------------------------------------------------------
      Total                      8_095_372
      
      POST EXPANSION AST STATS
      
      Name                Accumulated Size         Count     Item Size
      ----------------------------------------------------------------
      MacroDef                       1_056            12            88
      Mod                            3_400            85            40
      TypeBinding                    4_280           107            40
      PathListItem                   6_516           181            36
      Variant                        7_872            82            96
      StructField                   24_904           283            88
      ForeignItem                   31_504           179           176
      TraitItem                     69_504           362           192
      Local                         85_008         1_771            48
      Arm                          100_288         1_567            64
      Lifetime                     123_980         6_199            20
      LifetimeDef                  126_728         2_263            56
      TyParamBound                 297_128         2_857           104
      FnDecl                       305_856         6_372            48
      Block                        481_104        10_023            48
      Stmt                         535_120        13_378            40
      Item                       1_469_952         5_742           256
      Attribute                  1_629_840        33_955            48
      ImplItem                   1_732_864         7_736           224
      Pat                        2_360_176        21_073           112
      PathSegment                5_888_448        81_784            72
      Ty                         6_237_168        55_689           112
      Expr                      12_013_320        79_035           152
      ----------------------------------------------------------------
      Total                     33_536_016
      
      HIR STATS
      
      Name                Accumulated Size         Count     Item Size
      ----------------------------------------------------------------
      MacroDef                         864            12            72
      Mod                            2_720            85            32
      TypeBinding                    3_424           107            32
      PathListItem                   5_068           181            28
      Variant                        6_560            82            80
      StructField                   20_376           283            72
      ForeignItem                   27_208           179           152
      WherePredicate                43_776           684            64
      TraitItem                     52_128           362           144
      Decl                          68_992         2_156            32
      Local                         89_184         1_858            48
      Arm                           94_368         1_966            48
      LifetimeDef                  108_624         2_263            48
      Lifetime                     123_980         6_199            20
      Stmt                         168_000         4_200            40
      TyParamBound                 251_416         2_857            88
      FnDecl                       254_880         6_372            40
      Block                        583_968        12_166            48
      Item                       1_240_272         5_742           216
      ImplItem                   1_361_536         7_736           176
      Attribute                  1_620_480        33_760            48
      Pat                        2_073_120        21_595            96
      Path                       2_385_856        74_558            32
      Ty                         4_455_040        55_688            80
      PathSegment                5_587_904        87_311            64
      Expr                       7_588_992        79_052            96
      ----------------------------------------------------------------
      Total                     28_218_736
      ```
      0670d4b7
    • A
      Rollup merge of #37579 - liigo:defaulthasher, r=alexcrichton · 50def8ea
      Alex Crichton 提交于
      reference full path DefaultHasher
      
      Since `DefaultHasher` does not in scope, it's not obvious where to find it.
      50def8ea
    • A
      Rollup merge of #37577 - nnethercote:shrink-Expr-slightly, r=eddyb · 07cf4b41
      Alex Crichton 提交于
      Shrink `hir::Expr` slightly
      
      r? @EddyB
      07cf4b41
    • A
      Rollup merge of #37574 - ollie27:cow_add, r=alexcrichton · 638436e5
      Alex Crichton 提交于
      Fix issues with the Add/AddAssign impls for Cow<str>
      
      * Correct the stability attributes.
      * Make Add and AddAssign actually behave the same.
      * Use String::with_capacity when allocating a new string.
      * Fix the tests.
      638436e5
    • A
      Rollup merge of #37569 - jseyfried:improve_expansion_perf, r=eddyb · b9cbbe18
      Alex Crichton 提交于
      macros: improve expansion performance
      
      This PR fixes that regression, further improves performance on recursive, `tt`-heavy workloads, and makes a variety of other improvements to parsing and expansion performance.
      
      Expansion performance improvements:
      
      | Test case      | Run-time | Memory usage |
      | -------------- | -------- | ------------ |
      | libsyntax      | 8%       | 10%          |
      | librustc       | 15%      | 6%           |
      | librustc_trans | 30%      | 6%           |
      | #37074         | 20%      | 15%          |
      | #34630         | 40%      | 8%           |
      
      r? @EddyB
      b9cbbe18
    • A
      Rollup merge of #37566 - brson:env, r=alexcrichton · 9f882b99
      Alex Crichton 提交于
      Set RUSTC_BOOTSTRAP to some value.
      
      Environment variables on windows can't be empty.
      9f882b99
    • A
      Rollup merge of #37565 - mglagla:peek_use_as_ref, r=alexcrichton · b9f18bf7
      Alex Crichton 提交于
      Peekable::peek(): Use Option::as_ref()
      
      Replace the match expression in .peek() with Option::as_ref() since it's the same functionality.
      b9f18bf7
    • A
      Rollup merge of #37564 - Mark-Simulacrum:sized-ice, r=eddyb · 7c7bc2c2
      Alex Crichton 提交于
      Fix ICE when querying DefId on Def::Err.
      
      Also moves computations into check that `kind_id` is `Ok(_)`, which is in theory an optimization, though I expect it's minor.
      
      Fixes #37534.
      
      r? @EddyB.
      7c7bc2c2
    • A
      Rollup merge of #37557 - TimNN:fix-36954, r=eddyb · b4aee372
      Alex Crichton 提交于
      Use DefId's in const eval for cross-crate const fn's
      
      Fixes #36954.
      
      r? @EddyB
      
      cc @raphaelcohn
      b4aee372
    • A
      Rollup merge of #37556 - dinfuehr:main_frame_pointer, r=eddyb · ee90485e
      Alex Crichton 提交于
      set frame pointer elimination attribute for main
      
      The rustc-generated function `main` should respect the same config for
      frame pointer elimination as the rest of code.
      ee90485e
    • A
      Rollup merge of #37537 - GuillaumeGomez:error_kind_doc, r=steveklabnik · 112a4ff7
      Alex Crichton 提交于
      Add missing urls for ErrorKind's variants
      
      r? @steveklabnik
      112a4ff7
    • A
      Rollup merge of #37501 - alexcrichton:windows-subsystem, r=brson · 8a38b24d
      Alex Crichton 提交于
      rustc: Add knowledge of Windows subsystems.
      
      This commit is an implementation of [RFC 1665] which adds support for the
      `#![windows_subsystem]` attribute. This attribute allows specifying either the
      "windows" or "console" subsystems on Windows to the linker.
      
      [RFC 1665]: https://github.com/rust-lang/rfcs/blob/master/text/1665-windows-subsystem.md
      
      Previously all Rust executables were compiled as the "console" subsystem which
      meant that if you wanted a graphical application it would erroneously pop up a
      console whenever opened. When compiling an application, however, this is
      undesired behavior and the "windows" subsystem is used instead to have control
      over user interactions.
      
      This attribute is validated, but ignored on all non-Windows platforms.
      
      cc #37499
      8a38b24d
    • A
      Rollup merge of #37470 - arthurprs:sip-smaller, r=alexcrichton · 1d41d5bd
      Alex Crichton 提交于
      Don't reuse RandomState seeds
      
      cc #36481
      1d41d5bd
    • A
      Rollup merge of #37427 - nnethercote:opt-IchHasher, r=michaelwoerister · 1ff3dfd2
      Alex Crichton 提交于
      Reduce the number of bytes hashed by IchHasher.
      
      IchHasher uses blake2b hashing, which is expensive, so the fewer bytes hashed
      the better. There are two big ways to reduce the number of bytes hashed.
      - Filenames in spans account for ~66% of all bytes (for builds with debuginfo).
        The vast majority of spans have the same filename for the start of the span
        and the end of the span, so hashing the filename just once in those cases is
        a big win.
      - u32 and u64 and usize values account for ~25%--33% of all bytes (for builds
        with debuginfo). The vast majority of these are small, i.e. fit in a u8, so
        shrinking them down before hashing is also a big win.
      
      This PR implements these two optimizations. I'm certain the first one is safe.
      I'm about 90% sure that the second one is safe.
      
      Here are measurements of the number of bytes hashed when doing
      debuginfo-enabled builds of stdlib and
      rustc-benchmarks/syntex-0.42.2-incr-clean.
      
      ```
                          stdlib   syntex-incr
                          ------   -----------
      original       156,781,386   255,095,596
      half-SawSpan   106,744,403   176,345,419
      short-ints      45,890,534   118,014,227
      no-SawSpan[*]    6,831,874    45,875,714
      
      [*] don't hash the SawSpan at all. Not part of this PR, just implemented for
          comparison's sake.
      ```
      
      For debug builds of syntex-0.42.2-incr-clean, the two changes give a 1--2%
      speed-up.
      1ff3dfd2
    • A
      Rollup merge of #37422 - bluss:wrapping-offset, r=alexcrichton · 041f890c
      Alex Crichton 提交于
      Add .wrapping_offset() methods
      
      .wrapping_offset() exposes the arith_offset intrinsic in the core
      module (as methods on raw pointers, next to offset). This is the
      first step in making it possible to stabilize the interface later.
      
      `arith_offset` is a useful tool for developing iterators for two
      reasons:
      1. `arith_offset` is used by the slice's iterator, the most important
         iterator in libcore, and it is natural that Rust users need the same
         power available to implement similar iterators.
      2. It is a good way to implement raw pointer iterations with step
         greater than one.
      
      The name seems to fit the style of methods like "wrapping_add".
      041f890c
  2. 05 11月, 2016 7 次提交
    • A
      Rollup merge of #37408 - eddyb:lazy-5, r=nikomatsakis · 1a096329
      Alex Crichton 提交于
      [5/n] rustc: record the target type of every adjustment.
      
      _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37404) | [next](https://github.com/rust-lang/rust/pull/37412)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
      If any motivation is unclear, please ask for additional PR description clarifications or code comments._
      
      <hr>
      
      The first commit rearranges `tcx.tables` so that all users go through `tcx.tables()`. This in preparation for per-body `Tables` where they will be requested for a specific `DefId`. Included to minimize churn.
      
      The rest of the changes focus on adjustments, there are some renamings, but the main addition is the target type, always available in all cases (as opposed to just for unsizing where it was previously needed).
      
      Possibly the most significant effect of this change is that figuring out the final type of an expression is now _always_ just one successful `HashMap` lookup (either the adjustment or, if that doesn't exist, the node type).
      1a096329
    • A
      Rollup merge of #37317 - brson:relnotes, r=brson · 0f6a71e3
      Alex Crichton 提交于
      Add release notes for 1.12.1
      
      It completely slipped my mind that this is something I'm supposed to do as part of the release process...
      0f6a71e3
    • A
      Rollup merge of #37255 - mbrubeck:doc-edit, r=steveklabnik · c0bc35a3
      Alex Crichton 提交于
      Fix some mistakes in HRTB docs
      
      The example code for higher-ranked trait bounds on closures had an unnecessary `mut` which was confusing, and the text referred to an mutable reference which does not exist in the code (and isn't needed).  Removed the `mut`s and fixed the text to better describe the actual error for the failing example.
      
      Thanks to csd_ on IRC for pointing out these problems!
      
      r? @steveklabnik
      c0bc35a3
    • O
      Remove recursive call from Cow::to_mut · 775d399d
      Oliver Middleton 提交于
      It seems to prevent it from being inlined.
      775d399d
    • T
      fix #37559: update compiler-rt · a6cf7770
      Tim Neumann 提交于
      a6cf7770
    • L
    • B
      Auto merge of #37306 - bluss:trusted-len, r=alexcrichton · 81601cd3
      bors 提交于
      Add Iterator trait TrustedLen to enable better FromIterator / Extend
      
      This trait attempts to improve FromIterator / Extend code by enabling it to trust the iterator to produce an exact number of elements, which means that reallocation needs to happen only once and is moved out of the loop.
      
      `TrustedLen` differs from `ExactSizeIterator` in that it attempts to include _more_ iterators by allowing for the case that the iterator's len does not fit in `usize`. Consumers must check for this case (for example they could panic, since they can't allocate a collection of that size).
      
      For example, chain can be TrustedLen and all numerical ranges can be TrustedLen. All they need to do is to report an exact size if it fits in `usize`, and `None` as the upper bound otherwise.
      
      The trait describes its contract like this:
      
      ```
      An iterator that reports an accurate length using size_hint.
      
      The iterator reports a size hint where it is either exact
      (lower bound is equal to upper bound), or the upper bound is `None`.
      The upper bound must only be `None` if the actual iterator length is
      larger than `usize::MAX`.
      
      The iterator must produce exactly the number of elements it reported.
      
      This trait must only be implemented when the contract is upheld.
      Consumers of this trait must inspect `.size_hint()`’s upper bound.
      ```
      
      Fixes #37232
      81601cd3
  3. 04 11月, 2016 15 次提交
    • M
      94e655ec
    • B
      Auto merge of #37167 - nikomatsakis:jroesch-issue-18937, r=pnkfelix · ccfc38f0
      bors 提交于
      detect extra region requirements in impls
      
      The current "compare method" check fails to check for the "region obligations" that accrue in the fulfillment context. This branch switches that code to create a `FnCtxt` so that it can invoke the regionck code. Previous crater runs (I haven't done one with the latest tip) have found some small number of affected crates, so I went ahead and introduced a warning cycle. I will kick off a crater run with this branch shortly.
      
      This is a [breaking-change] because previously unsound code was accepted. The crater runs also revealed some cases where legitimate code was no longer type-checking, so the branch contains one additional (but orthogonal) change. It improves the elaborator so that we elaborate region requirements more thoroughly. In particular, if we know that `&'a T: 'b`, we now deduce that `T: 'b` and `'a: 'b`.
      
      I invested a certain amount of effort in getting a good error message. The error message looks like this:
      
      ```
      error[E0276]: impl has stricter requirements than trait
        --> traits-elaborate-projection-region.rs:33:5
         |
      21 |     fn foo() where T: 'a;
         |     --------------------- definition of `foo` from trait
      ...
      33 |     fn foo() where U: 'a { }
         |     ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a`
         |
         = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
         = note: for more information, see issue #18937 <https://github.com/rust-lang/rust/issues/18937>
      note: lint level defined here
        --> traits-elaborate-projection-region.rs:12:9
         |
      12 | #![deny(extra_requirement_in_impl)]
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^
      ```
      
      Obviously the warning only prints if this is a _new_ error (that resulted from the bugfix). But all existing errors that fit this description are updated to follow the general template. In order to get the lint to preserve the span-labels and the error code, I separate out the core `Diagnostic` type (which encapsulates the error code, message, span, and children) from the `DiagnosticBuilder` (which layers on a `Handler` that can be used to report errors). I also extended `add_lint` with an alternative `add_lint_diagnostic` that takes in a full diagnostic (cc @jonathandturner for those changes). This doesn't feel ideal but feels like it's moving in the right direction =).
      
      r? @pnkfelix
      cc @arielb1
      
      Fixes #18937
      ccfc38f0
    • B
      Auto merge of #37037 - Mark-Simulacrum:stack-error, r=alexcrichton · d2bc30b0
      bors 提交于
      Add conversions from `io:ErrorKind` to `io::Error`
      
      Filing to help with discussion around the possibility of doing this.
      
      Current changes are clearly backwards incompatible, but I think adding a new function (with a bikeshed on naming) like `Error::new_str` should be possible (or some other way of specializing the string error message case) to fix #36658.
      d2bc30b0
    • L
      reference full path `DefaultHasher` · a5f6aa1c
      Liigo Zhuang 提交于
      a5f6aa1c
    • J
      Fix fallout in tests. · 51104e5c
      Jeffrey Seyfried 提交于
      51104e5c
    • B
      Auto merge of #36306 - nagisa:mir-local-cleanup, r=eddyb · 49c36bf1
      bors 提交于
      A way to remove otherwise unused locals from MIR
      
      There is a certain amount of desire for a pass which cleans up the provably unused variables (no assignments or reads). There has been an implementation of such pass by @scottcarr, and another (two!) implementations by me in my own dataflow efforts.
      
      PR like https://github.com/rust-lang/rust/pull/35916 proves that this pass is useful even on its own, which is why I cherry-picked it out from my dataflow effort.
      
      @nikomatsakis previously expressed concerns over this pass not seeming to be very cheap to run and therefore unsuitable for regular cleanup duties. Turns out, regular cleanup of local declarations is not at all necessary, at least now, because majority of passes simply do not (or should not) care about them. That’s why it is viable to only run this pass once (perhaps a few more times in the future?) per function, right before translation.
      
      r? @EddyB or @nikomatsakis
      49c36bf1
    • N
      Shrink `Expr_::ExprStruct`. · 43452a36
      Nicholas Nethercote 提交于
      On 64-bit platforms this reduces the size of `Expr_` from  64 bytes to
      56 bytes, and reduces the size of `Expr` from 88 bytes to 80 bytes.
      43452a36
    • N
      Reorder `hir::Expr` fields. · 9366ba31
      Nicholas Nethercote 提交于
      On 64-bit platforms this reduces the size of `Expr` from 96 bytes to 88
      bytes.
      9366ba31
    • J
      Remove field `TtReader::next_tok`. · b7eed53b
      Jeffrey Seyfried 提交于
      b7eed53b
    • J
      Improve `tt`-heavy expansion performance. · 23ad6fdb
      Jeffrey Seyfried 提交于
      23ad6fdb
    • O
      Fix issues with the Add/AddAssign impls for Cow<str> · 1e40c80c
      Oliver Middleton 提交于
      * Correct the stability attributes.
      * Make Add and AddAssign actually behave the same.
      * Use String::with_capacity when allocating a new string.
      * Fix the tests.
      1e40c80c
    • U
      Link the tracking issue for TrustedLen · f0e6b907
      Ulrik Sverdrup 提交于
      f0e6b907
    • J
      Move doc comment desugaring into the parser. · 7ae08338
      Jeffrey Seyfried 提交于
      7ae08338
    • J
      e2b3fec7
    • J
      Make `ast::ExprKind` smaller. · b60bcba9
      Jeffrey Seyfried 提交于
      b60bcba9