1. 05 9月, 2020 13 次提交
  2. 04 9月, 2020 27 次提交
    • L
      Change ty.kind to a method · 3e14b684
      LeSeulArtichaut 提交于
      3e14b684
    • B
      Auto merge of #75655 - nielx:fix/haiku-llvm-libz, r=Mark-Simulacrum · 80cacd77
      bors 提交于
      Disable zlib in LLVM on Haiku
      
      PR #72696 enabled the option LLVM_ENABLE_ZLIB for the LLVM builds. Like NetBSD and aarch64-apple-darwin (see PR #75500), the LLVM build system not explicitly linking to libz on these platforms cause issues. For Haiku, this meant the runtime loader complaining about undefined symbols..
      80cacd77
    • B
      Auto merge of #75207 - dylni:add-slice-check-range, r=KodrAus · ef55a0a9
      bors 提交于
      Add `slice::check_range`
      
      This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/src/librustc_data_structures/sorted_map.rs#L214) [many](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/alloc/src/vec.rs#L1299) [times](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/core/src/slice/mod.rs#L2441) in the standard library, sometimes assuming that the bounds won't be [`usize::MAX`].
      
      For example, [`Vec::drain`] creates an empty iterator when [`usize::MAX`] is used as an inclusive end bound:
      
      ```rust
      assert!(vec![1].drain(..=usize::max_value()).eq(iter::empty()));
      ```
      
      If this PR is merged, I'll create another to use it for those methods.
      
      [`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html
      [`usize::MAX`]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.MAX
      [`Vec::drain`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain
      ef55a0a9
    • B
      add track_caller to `local_def_id_to_hir_id` · cdd5d60b
      Bastian Kauschke 提交于
      cdd5d60b
    • B
      Auto merge of #76004 - richkadel:llvm-coverage-map-gen-6b.5, r=tmandry · 4ffb5c59
      bors 提交于
      Tools, tests, and experimenting with MIR-derived coverage counters
      
      Leverages the new mir_dump output file in HTML+CSS (from #76074) to visualize coverage code regions
      and the MIR features that they came from (including overlapping spans).
      
      See example below.
      
      The `run-make-fulldeps/instrument-coverage` test has been refactored to maximize test coverage and reduce code duplication. The new tests support testing with and without `-Clink-dead-code`, so Rust coverage can be tested on MSVC (which, currently, only works with `link-dead-code` _disabled_).
      
      New tests validate coverage region generation and coverage reports with multiple counters per function. Starting with a simple `if-else` branch tests, coverage tests for each additional syntax type can be added by simply dropping in a new Rust sample program.
      
      Includes a basic, MIR-block-based implementation of coverage injection,
      available via `-Zexperimental-coverage`. This implementation has known
      flaws and omissions, but is simple enough to validate the new tools and
      tests.
      
      The existing `-Zinstrument-coverage` option currently enables
      function-level coverage only, which at least appears to generate
      accurate coverage reports at that level.
      
      Experimental coverage is not accurate at this time. When branch coverage
      works as intended, the `-Zexperimental-coverage` option should be
      removed.
      
      This PR replaces the bulk of PR #75828, with the remaining parts of
      that PR distributed among other separate and indentpent PRs.
      
      This PR depends on two of those other PRs: #76002, #76003 and #76074
      
      Rust compiler MCP rust-lang/compiler-team#278
      
      Relevant issue: #34701 - Implement support for LLVMs code coverage
      instrumentation
      
      ![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
      
      r? @tmandry
      FYI: @wesleywiser
      4ffb5c59
    • B
      Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov · af3c6e73
      bors 提交于
      diagnostics: shorten paths of unique symbols
      
      This is a step towards implementing a fix for #50310, and continuation of the discussion in [Pre-RFC: Nicer Types In Diagnostics - compiler - Rust Internals](https://internals.rust-lang.org/t/pre-rfc-nicer-types-in-diagnostics/11139). Impressed upon me from previous discussion in #21934 that an RFC for this is not needed, and I should just come up with code.
      
      The recent improvements to `use` suggestions that I've contributed have given rise to this implementation. Contrary to previous suggestions, it's rather simple logic, and I believe it only reduces the amount of cognitive load that a developer would need when reading type errors.
      
      -----
      
      If a symbol name can only be imported from one place, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path to the last component.
      
      This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable from anywhere.
      af3c6e73
    • B
      Auto merge of #70793 - the8472:in-place-iter-collect, r=Amanieu · 0d0f6b11
      bors 提交于
      specialize some collection and iterator operations to run in-place
      
      This is a rebase and update of #66383 which was closed due inactivity.
      
      Recent rustc changes made the compile time regressions disappear, at least for webrender-wrench. Running a stage2 compile and the rustc-perf suite takes hours on the hardware I have at the moment, so I can't do much more than that.
      
      ![Screenshot_2020-04-05 rustc performance data](https://user-images.githubusercontent.com/1065730/78462657-5d60f100-76d4-11ea-8a0b-4f3962707c38.png)
      
      In the best case of the `vec::bench_in_place_recycle` synthetic microbenchmark these optimizations can provide a 15x speedup over the regular implementation which allocates a new vec for every benchmark iteration. [Benchmark results](https://gist.github.com/the8472/6d999b2d08a2bedf3b93f12112f96e2f). In real code the speedups are tiny, but it also depends on the allocator used, a system allocator that uses a process-wide mutex will benefit more than one with thread-local pools.
      
      ## What was changed
      
      * `SpecExtend` which covered `from_iter` and `extend` specializations was split into separate traits
      * `extend` and `from_iter` now reuse the `append_elements` if passed iterators are from slices.
      * A preexisting `vec.into_iter().collect::<Vec<_>>()` optimization that passed through the original vec has been generalized further to also cover cases where the original has been partially drained.
      * A chain of *Vec<T> / BinaryHeap<T> / Box<[T]>* `IntoIter`s  through various iterator adapters collected into *Vec<U>* and *BinaryHeap<U>* will be performed in place as long as `T` and `U` have the same alignment and size and aren't ZSTs.
      * To enable above specialization the unsafe, unstable `SourceIter` and `InPlaceIterable` traits have been added. The first allows reaching through the iterator pipeline to grab a pointer to the source memory. The latter is a marker that promises that the read pointer will advance as fast or faster than the write pointer and thus in-place operation is possible in the first place.
      * `vec::IntoIter` implements `TrustedRandomAccess` for `T: Copy` to allow in-place collection when there is a `Zip` adapter in the iterator. TRA had to be made an unstable public trait to support this.
      
      ## In-place collectible adapters
      
      * `Map`
      * `MapWhile`
      * `Filter`
      * `FilterMap`
      * `Fuse`
      * `Skip`
      * `SkipWhile`
      * `Take`
      * `TakeWhile`
      * `Enumerate`
      * `Zip` (left hand side only, `Copy` types only)
      * `Peek`
      * `Scan`
      * `Inspect`
      
      ## Concerns
      
      `vec.into_iter().filter(|_| false).collect()` will no longer return a vec with 0 capacity, instead it will return its original allocation. This avoids the cost of doing any allocation or deallocation but could lead to large allocations living longer than expected.
      If that's not acceptable some resizing policy at the end of the attempted in-place collect would be necessary, which in the worst case could result in one more memcopy than the non-specialized case.
      
      ## Possible followup work
      
      * split liballoc/vec.rs to remove `ignore-tidy-filelength`
      * try to get trivial chains such as `vec.into_iter().skip(1).collect::<Vec<)>>()` to compile to a `memmove` (currently compiles to a pile of SIMD, see #69187 )
      * improve up the traits so they can be reused by other crates, e.g. itertools. I think currently they're only good enough for internal use
      * allow iterators sourced from a `HashSet` to be in-place collected into a `Vec`
      0d0f6b11
    • T
      fix debug assertion · 2f23a0fc
      The8472 提交于
      The InPlaceIterable debug assert checks that the write pointer
      did not advance beyond the read pointer. But TrustedRandomAccess
      never advances the read pointer, thus triggering the assert.
      Skip the assert if the source pointer did not change during iteration.
      2f23a0fc
    • B
      Auto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomez · 62dad457
      bors 提交于
      rustdoc: do not use plain summary for trait impls
      
      Fixes #38386.
      Fixes #48332.
      Fixes #49430.
      Fixes #62741.
      Fixes #73474.
      
      Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy.
      
      (In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.)
      
      Ideally this could be fixed with intra-doc links ~~but it isn't working for me: I am currently investigating if it's possible to solve it this way.~~ Opened #73829.
      
      EDIT: This is now ready!
      62dad457
    • T
      improve comments and naming · 8e5fe556
      The8472 提交于
      8e5fe556
    • T
      add explanation to specialization marker · 64645865
      The8472 提交于
      64645865
    • T
      acdd441c
    • T
      remove empty Vec extend optimization · 435219dd
      The8472 提交于
      The optimization meant that every extend code path had to emit llvm
      IR for from_iter and extend spec_extend, which likely impacts
      compile times while only improving a few edge-cases
      435219dd
    • T
      please tidy · 7492f76f
      The8472 提交于
      7492f76f
    • T
      get things to work under min_specialization by leaning more heavily on... · 9aeea002
      The8472 提交于
      get things to work under min_specialization by leaning more heavily on #[rustc_unsafe_specialization_marker]
      9aeea002
    • T
      avoid applying in-place collect specialization in type-length test · 7badb7a7
      The8472 提交于
      the test was sized to match external iteration only, since
      vec's in-place collect now uses internal iteration we collect into
      a different type now.
      Note that any other try-fold based operation such as count() would also
      have exceeded the type length limit for that iterator.
      7badb7a7
    • T
      fix benchmark compile errors · a62cd1b4
      The8472 提交于
      a62cd1b4
    • T
      apply required min_specialization attributes · bec9f922
      The8472 提交于
      bec9f922
    • T
      support in-place collect for MapWhile adapters · 80638330
      The8472 提交于
      80638330
    • T
      pacify tidy · 55d1296a
      The8472 提交于
      55d1296a
    • T
      5530858a
    • T
      increase comment verbosity · fa34b39c
      The8472 提交于
      fa34b39c
    • T
    • T
    • T
      add benchmark to cover in-place extend · 6ad13344
      The8472 提交于
      6ad13344
    • T
      remove redundant cast · a7a8b52e
      The8472 提交于
      a7a8b52e
    • T
      test drops during in-place iteration · 470bf54f
      The8472 提交于
      470bf54f