Commit graph

126670 commits

Author SHA1 Message Date
bors 7d289aeade Auto merge of #76376 - Dylan-DPC:rollup-8chsbw9, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #75695 (Add a regression test for issue-72793)
 - #75741 (Refactor byteorder to std in rustc_middle)
 - #75954 (Unstable Book: add links to tracking issues for FFI features)
 - #75994 (`impl Rc::new_cyclic`)
 - #76060 (Link vec doc to & reference)
 - #76078 (Remove disambiguators from intra doc link text)
 - #76082 (Fix intra-doc links on pub re-exports)
 - #76254 (Fold length constant in Rvalue::Repeat)
 - #76258 (x.py check checks tests/examples/benches)
 - #76263 (inliner: Check for codegen fn attributes compatibility)
 - #76285 (Move jointness censoring to proc_macro)

Failed merges:

r? @ghost
2020-09-05 14:59:32 +00:00
Dylan DPC 85cee57fd7
Rollup merge of #76285 - matklad:censor-spacing, r=petrochenkov
Move jointness censoring to proc_macro

Proc-macro API currently exposes jointness in `Punct` tokens. That is,
`+` in `+one` is **non** joint.

Our lexer produces jointness info for all tokens, so we need to censor
it *somewhere*

Previously we did this in a lexer, but it makes more sense to do this
in a proc-macro server.

r? @petrochenkov
2020-09-05 16:28:36 +02:00
Dylan DPC b4d3873024
Rollup merge of #76263 - tmiasko:inline-codegen-fn-attrs, r=ecstatic-morse
inliner: Check for codegen fn attributes compatibility

* Check for target features compatibility
* Check for no_sanitize attribute compatibility

Fixes #76259.
2020-09-05 16:28:34 +02:00
Dylan DPC 45bdee8fde
Rollup merge of #76258 - Mark-Simulacrum:check-tests, r=ehuss
x.py check checks tests/examples/benches

This also adds a check for bootstrap to x.py.

r? @ehuss
2020-09-05 16:28:32 +02:00
Dylan DPC 79b8f59185
Rollup merge of #76254 - tmiasko:fold-len, r=wesleywiser
Fold length constant in Rvalue::Repeat

Fixes #76248.
2020-09-05 16:28:30 +02:00
Dylan DPC f1eb5f800f
Rollup merge of #76082 - jyn514:top-level-links, r=ollie27,GuillaumeGomez
Fix intra-doc links on pub re-exports

Partial fix for https://github.com/rust-lang/rust/issues/76073 - This removes the incorrect error, but doesn't show the documentation anywhere.
r? @GuillaumeGomez
2020-09-05 16:28:28 +02:00
Dylan DPC ed39e6d60a
Rollup merge of #76078 - jyn514:no-disambiguator, r=manishearth
Remove disambiguators from intra doc link text

Closes https://github.com/rust-lang/rust/issues/65354.
r? @Manishearth

The commits are mostly atomic, but there might be some mix between them here and there. I recommend reading 'refactor ItemLink' and 'refactor RenderedLink' on their own though, lots of churn without any logic changes.
2020-09-05 16:28:26 +02:00
Dylan DPC 86cf7976e2
Rollup merge of #76060 - pickfire:patch-12, r=jyn514
Link vec doc to & reference

It is not always obvious that people could see the docs for `&`
especially for beginners, it also helps learnability.
2020-09-05 16:28:24 +02:00
Dylan DPC 4bd3f266b0
Rollup merge of #75994 - mental32:impl-rc-new-cyclic, r=KodrAus
`impl Rc::new_cyclic`

References #75861

r? @Dylan-DPC
2020-09-05 16:28:22 +02:00
Dylan DPC c3a09fba84
Rollup merge of #75954 - ArekPiekarz:unstable_book_ffi_tracking_issues, r=steveklabnik
Unstable Book: add links to tracking issues for FFI features
2020-09-05 16:28:20 +02:00
Dylan DPC e160d2b3e0
Rollup merge of #75741 - workingjubilee:refactor-byteorder, r=matthewjasper
Refactor byteorder to std in rustc_middle

Use std::io::{Read, Write} and {to, from}_{le, be}_bytes methods in
order to remove byteorder from librustc_middle's dependency graph.
2020-09-05 16:28:17 +02:00
Dylan DPC cb33a15c3e
Rollup merge of #75695 - JohnTitor:regression-test, r=Dylan-DPC
Add a regression test for issue-72793

Adds a regression test for #72793, which is fixed by #75443. Note that this won't close the issue as the snippet still shows ICE with `-Zmir-opt-level=2`. But it makes sense to add a test anyway.
2020-09-05 16:28:16 +02:00
bors 81a769f261 Auto merge of #75584 - RalfJung:union-no-deref, r=matthewjasper
do not apply DerefMut on union field

This implements the part of [RFC 2514](https://github.com/rust-lang/rfcs/blob/master/text/2514-union-initialization-and-drop.md) about `DerefMut`. Unlike described in the RFC, we only apply this warning specifically when doing `DerefMut` of a `ManuallyDrop` field; that is really the case we are worried about here.

@matthewjasper suggested I patch `convert_place_derefs_to_mutable` and `convert_place_op_to_mutable` for this, but I could not find anything to do in `convert_place_op_to_mutable` and this is sufficient to make the test pass. However, maybe there are some other cases this misses? I have no familiarity with this code.

This is a breaking change *in theory*, if someone used `ManuallyDrop<T>` in a union field and relied on automatic `DerefMut`. But on stable this means `T: Copy`, so the `ManuallyDrop` is rather pointless.

Cc https://github.com/rust-lang/rust/issues/55149
2020-09-05 11:47:01 +00:00
bors 02fe30971e Auto merge of #75888 - GuillaumeGomez:trait-impl-assoc-const-doc-alias, r=ollie27
Add check for doc alias on assoc const in trait impl

Fixes #73721.

r? @ollie27
2020-09-05 09:35:17 +00:00
Jubilee Young 2df552b406 Fix big endian read/write
Co-authored-by: matthewjasper <mjjasper1@gmail.com>
2020-09-04 21:51:29 -07:00
Jubilee Young dc00efff9f Explain contract of {read, write}_target_uint 2020-09-04 21:51:28 -07:00
Jubilee fe2a867125 Be explicit that we're handling bytes
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-09-04 21:51:28 -07:00
Jubilee Young 74b4eea64d Remove reference to byteorder limits 2020-09-04 21:51:28 -07:00
Jubilee Young b97d4131fe Refactor byteorder to std in rustc_middle
Use std::io::{Read, Write} and {to, from}_{le, be}_bytes methods in
order to remove byteorder from librustc_middle's dependency graph.
2020-09-04 21:51:17 -07:00
bors c3364780d2 Auto merge of #75173 - jackh726:chalk-0.21, r=nikomatsakis
Upgrade Chalk to 0.21

Two commits here. First commit actually does the upgrade. Second commit has some changes to make more tests in compare-mode=chalk pass.

The `PlaceholdersCollector` and `RegionsSubstitutor` bits are bit a hacky, but only insomuch as `ParamsSubstitutor` is. These won't be needed eventually.

r? @nikomatsakis
2020-09-05 02:24:05 +00:00
Jack Huey 0aa215305a kind -> kind() 2020-09-04 19:17:57 -04:00
bors 70c5f6efc4 Auto merge of #75200 - ssomers:btree_valmut, r=Mark-Simulacrum
BTreeMap: introduce marker::ValMut and reserve Mut for unique access

The mutable BTreeMap iterators (apart from `DrainFilter`) are double-ended, meaning they have to rely on a front and a back handle that each represent a reference into the tree. Reserve a type category `marker::ValMut` for them, so that we guarantee that they cannot reach operations on handles with borrow type `marker::Mut`and that these operations can assume unique access to the tree.

Including #75195, benchmarks report no genuine change:
```
benchcmp old new --threshold 5
 name                                 old ns/iter  new ns/iter  diff ns/iter   diff %  speedup
 btree::map::iter_100                 3,333        3,023                -310   -9.30%   x 1.10
 btree::map::range_unbounded_vs_iter  36,624       31,569             -5,055  -13.80%   x 1.16
```

r? @Mark-Simulacrum
2020-09-04 23:16:23 +00:00
Jack Huey 3a9a4e8b2d Bless changed test output 2020-09-04 19:12:54 -04:00
Jack Huey f690569465 Review comments 2020-09-04 19:12:54 -04:00
Jack Huey 76c728901e More chalk work 2020-09-04 19:12:54 -04:00
Jack Huey d66452c3e5 Upgrade chalk to 0.21 2020-09-04 19:12:54 -04:00
bors c59199efca Auto merge of #76292 - Aaron1011:fix/proc-macro-panic-hide, r=petrochenkov
Respect `-Z proc-macro-backtrace` flag for panics inside libproc_macro

Fixes #76270

Previously, any panic occuring during a call to a libproc_macro method
(e.g. calling `Ident::new` with an invalid identifier) would always
cause an ICE message to be printed.
2020-09-04 20:58:37 +00:00
bors 42d896afbd Auto merge of #76315 - lcnr:map-track-caller, r=Mark-Simulacrum
add `#[track_caller]` to `local_def_id_to_hir_id`

Improves one of the more frequent ICE
2020-09-04 19:05:20 +00:00
bors d2454643e1 Auto merge of #75077 - LeSeulArtichaut:tys-kind, r=nikomatsakis
Refractor ty.kind -> ty.kind() and ty.flags -> ty.flags()

First step for the ["shared library to represent Rust types"](https://rust-lang.github.io/compiler-team/minutes/design-meeting/2020-03-12-shared-library-for-types/) work (rust-lang/wg-traits#16).

This PR makes the `TyS::kind` field private and adds a `kind()` method to access it.
As noted [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/Looking.20to.20contribute/near/205185412), this refractoring might require a MCP. I am perfectly fine with having to wait until MCP is accepted and resolving the conflicts that pop up afterwards.

r? @nikomatsakis
2020-09-04 17:07:39 +00:00
LeSeulArtichaut 4d28a82c59 ty.flags -> ty.flags() 2020-09-04 18:28:20 +02:00
LeSeulArtichaut 085e417087 ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
LeSeulArtichaut 3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
bors 80cacd7795 Auto merge of #75655 - nielx:fix/haiku-llvm-libz, r=Mark-Simulacrum
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..
2020-09-04 14:32:33 +00:00
Joshua Nelson 18c14fde0d Misc cleanup
- Preserve suffixes when displaying
- Rename test file to match `intra-link*`
- Remove unnecessary .clone()s
- Improve comments and naming
- Fix more bugs and add tests
- Escape intra-doc link example in public documentation
2020-09-04 08:27:56 -04:00
bors ef55a0a92f Auto merge of #75207 - dylni:add-slice-check-range, r=KodrAus
Add `slice::check_range`

This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](22ee68dc58/src/librustc_data_structures/sorted_map.rs (L214)) [many](22ee68dc58/library/alloc/src/vec.rs (L1299)) [times](22ee68dc58/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
2020-09-04 12:21:43 +00:00
Bastian Kauschke cdd5d60b47 add track_caller to local_def_id_to_hir_id 2020-09-04 09:24:44 +02:00
Ivan Tham 85146b9db7
Add slice primitive link to vec 2020-09-04 09:50:50 +08:00
bors 4ffb5c5954 Auto merge of #76004 - richkadel:llvm-coverage-map-gen-6b.5, r=tmandry
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
2020-09-04 01:31:07 +00:00
Tomasz Miąsko c23151bdb1 inliner: Add mir-opt tests for codegen attributes compatibility 2020-09-04 00:00:00 +00:00
Tomasz Miąsko 326b772609 inliner: Check for no_sanitize attribute compatibility 2020-09-04 20:01:15 +02:00
Tomasz Miąsko cbc396fdfb inliner: Check for target features compatibility 2020-09-04 19:36:45 +02:00
bors af3c6e733a Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov
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.
2020-09-03 23:27:45 +00:00
Aleksey Kladov 09d3db2e59 Optimize Cursor::look_ahead
Cloning a tt is cheap, but not free (there's Arc inside).
2020-09-03 23:28:22 +02:00
bors 0d0f6b1130 Auto merge of #70793 - the8472:in-place-iter-collect, r=Amanieu
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`
2020-09-03 21:20:21 +00:00
The8472 2f23a0fcca fix debug assertion
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.
2020-09-03 22:15:47 +02:00
Guillaume Gomez b61eab5d51 Add test for doc alias on associated const in trait impls 2020-09-03 22:11:29 +02:00
Guillaume Gomez 6e43ff5cea Add check for doc alias on associated const in trait impls 2020-09-03 22:11:29 +02:00
Mark Rousskov af133382f2 Check test/example/benchmark on x.py check
Often when modifying compiler code you'll miss that you've changed an API used
by unit tests, since x.py check didn't previously catch that.

It's also useful to have this for editing with rust-analyzer and similar tooling
where editing tests previously didn't notify you of errors in test files.
2020-09-03 15:16:53 -04:00
bors 62dad457bc Auto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomez
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!
2020-09-03 19:07:38 +00:00
The8472 8e5fe5569b improve comments and naming 2020-09-03 20:59:37 +02:00