Commit graph

155651 commits

Author SHA1 Message Date
bors
55111d656f Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister
Move ICH to rustc_query_system

Based on https://github.com/rust-lang/rust/pull/89183

The StableHashingContext does not need to be in rustc_middle.

This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-05 09:45:11 +00:00
bors
074f63648b Auto merge of #89549 - Manishearth:rollup-mhkyc16, r=Manishearth
Rollup of 12 pull requests

Successful merges:

 - #87631 (os current_exe using same approach as linux to get always the full ab…)
 - #88234 (rustdoc-json: Don't ignore impls for primitive types)
 - #88651 (Use the 64b inner:monotonize() implementation not the 128b one for aarch64)
 - #88816 (Rustdoc migrate to table so the gui can handle >2k constants)
 - #89244 (refactor: VecDeques PairSlices fields to private)
 - #89364 (rustdoc-json: Encode json files with UTF-8)
 - #89423 (Fix ICE caused by non_exaustive_omitted_patterns struct lint)
 - #89426 (bootstrap: add config option for nix patching)
 - #89462 (haiku thread affinity build fix)
 - #89482 (Follow the diagnostic output style guide)
 - #89504 (Don't suggest replacing region with 'static in NLL)
 - #89535 (fix busted JavaScript in error index generator)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-05 06:56:57 +00:00
Manish Goregaokar
068683baf1
Rollup merge of #89535 - notriddle:notriddle/error-index-generator-js, r=Mark-Simulacrum
fix busted JavaScript in error index generator

The old JavaScript didn't work. It filled the browser console with "e.previousElementSibling not defined" errors, because it didn't account for the example-wrap div that a newer version of rustdoc added.

Additionally, it had copied versions of utility functions that had been optimized in rustdoc main.js. This version updates those.
2021-10-04 23:56:25 -07:00
Manish Goregaokar
bf62c6d710
Rollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakis
Don't suggest replacing region with 'static in NLL

Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.
2021-10-04 23:56:24 -07:00
Manish Goregaokar
04314a6061
Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett
Follow the diagnostic output style guide

Detected by #89455.
2021-10-04 23:56:23 -07:00
Manish Goregaokar
a23d7f01d3
Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa
haiku thread affinity build fix
2021-10-04 23:56:22 -07:00
Manish Goregaokar
94b72f4dd0
Rollup merge of #89426 - davidtwco:bootstrap-nix-toolchain-env-var, r=Mark-Simulacrum
bootstrap: add config option for nix patching

On NixOS systems, bootstrap will patch rustc used in bootstrapping after checking `/etc/os-release` (to confirm the current distribution is NixOS). However, when using Nix on a non-NixOS system, it can be desirable for bootstrap to patch rustc. In this commit, a `patch-binaries-for-nix` option is added to `config.toml`, which allows for user opt-in to bootstrap's Nix patching.

r? ``@Mark-Simulacrum``
2021-10-04 23:56:21 -07:00
Manish Goregaokar
87f782ede6
Rollup merge of #89423 - DevinR528:reachable-fields, r=Nadrieril
Fix ICE caused by non_exaustive_omitted_patterns struct lint

fixes #89382

Add check that a list of `Pat`s is non empty to prevent ICE in `FnCtxt::lint_non_exhaustive_omitted_patterns`.

Is related to #89374 and #89105
2021-10-04 23:56:20 -07:00
Manish Goregaokar
27b84a92c6
Rollup merge of #89364 - hkmatsumoto:encode-json-with-utf-8, r=Mark-Simulacrum
rustdoc-json: Encode json files with UTF-8

Currently, `check_missing_items.py` malfunctions when the index contains some letters like emojis.

Related to #89360.
2021-10-04 23:56:19 -07:00
Manish Goregaokar
eeadc9d63f
Rollup merge of #89244 - DeveloperC286:pair_slices_fields_to_private, r=joshtriplett
refactor: VecDeques PairSlices fields to private

Reducing VecDeque's PairSlices fields to private, a `from(...)` method is already used to create PairSlices.
2021-10-04 23:56:18 -07:00
Manish Goregaokar
52d3afaa0c
Rollup merge of #88816 - dns2utf8:rustdoc_test_gui_2k_constants, r=GuillaumeGomez
Rustdoc migrate to table so the gui can handle >2k constants

Closes #88545.

This PR adds a test for overlapping entries in the `item-table` https://github.com/rust-lang/rust/issues/88545
It currently includes the commit with the workaround from https://github.com/rust-lang/rust/pull/88776
2021-10-04 23:56:17 -07:00
Manish Goregaokar
dd223d5c6d
Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay
Use the 64b inner:monotonize() implementation not the 128b one for aarch64

aarch64 prior to v8.4 (FEAT_LSE2) doesn't have an instruction that guarantees
untorn 128b reads except for completing a 128b load/store exclusive pair
(ldxp/stxp) or compare-and-swap (casp) successfully. The requirement to
complete a 128b read+write atomic is actually more expensive and more unfair
than the previous implementation of monotonize() which used a Mutex on aarch64,
especially at large core counts.  For aarch64 switch to the 64b atomic
implementation which is about 13x faster for a benchmark that involves many
calls to Instant::now().
2021-10-04 23:56:17 -07:00
Manish Goregaokar
7a09755148
Rollup merge of #88234 - hkmatsumoto:rustdoc-impls-for-primitive, r=jyn514
rustdoc-json: Don't ignore impls for primitive types

Fix the issue discussed at [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.E2.9C.94.20Json.20output.20lacks.20some.20item.20which.20are.20supposed.20to.20be.20there)

r? ``@jyn514``
2021-10-04 23:56:16 -07:00
Manish Goregaokar
0fb01224dd
Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplett
os current_exe using same approach as linux to get always the full ab…

…solute path
2021-10-04 23:56:15 -07:00
bors
a804c4b112 Auto merge of #89545 - workingjubilee:rollup-ooxf3p2, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - #87993 (Stabilize try_reserve)
 - #88090 (Perform type inference in range pattern)
 - #88780 (Added abs_diff for integer types.)
 - #89270 (path.push() should work as expected on windows verbatim paths)
 - #89413 (Correctly handle supertraits for min_specialization)
 - #89456 (Update to the final LLVM 13.0.0 release)
 - #89466 (Fix bug with query modifier parsing)
 - #89473 (Fix extra `non_snake_case` warning for shorthand field bindings)
 - #89474 (rustdoc: Improve doctest pass's name and module's name)
 - #89478 (Fixed numerus of error message)
 - #89480 (Add test for issue 89118.)
 - #89487 (Try to recover from a `=>` -> `=` or `->` typo in a match arm)
 - #89494 (Deny `where` clauses on `auto` traits)
 - #89511 (⬆️ rust-analyzer)
 - #89536 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-05 04:13:35 +00:00
Jubilee
2ae8ced803
Rollup merge of #89536 - RalfJung:miri, r=RalfJung
update Miri

Let's get the recent fixes and improvements shipped.
r? ````@ghost````
2021-10-04 21:12:44 -07:00
Jubilee
92dbb69b6c
Rollup merge of #89511 - lnicola:rust-analyzer-2021-10-04, r=lnicola
⬆️ rust-analyzer
2021-10-04 21:12:43 -07:00
Jubilee
c9158db1f3
Rollup merge of #89494 - FabianWolff:issue-84075, r=davidtwco
Deny `where` clauses on `auto` traits

Fixes #84075.
2021-10-04 21:12:43 -07:00
Jubilee
90e96f9fc3
Rollup merge of #89487 - FabianWolff:issue-89396, r=petrochenkov
Try to recover from a `=>` -> `=` or `->` typo in a match arm

Fixes #89396.
2021-10-04 21:12:42 -07:00
Jubilee
25cc28ed5d
Rollup merge of #89480 - hameerabbasi:issue-89118-test, r=jackh726
Add test for issue 89118.

This PR adds a test for issue 89118.

Closes #89118.
2021-10-04 21:12:41 -07:00
Jubilee
ec4145510e
Rollup merge of #89478 - zvavybir:master, r=jyn514
Fixed numerus of error message

When there are redundant trait requirements and these are hidden, a message is generated by the following code snippet:
`format!("{} redundant requirements hidden", count)`
But if there is only a single hidden requirement, it will still print this message in plural instead of singular.
2021-10-04 21:12:40 -07:00
Jubilee
02b52ca89d
Rollup merge of #89474 - camelid:better-pass-name, r=jyn514
rustdoc: Improve doctest pass's name and module's name

As the docs at the top of the file say, it is an overloaded pass and
actually runs two lints.
2021-10-04 21:12:39 -07:00
Jubilee
c2bfe45e66
Rollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplett
Fix extra `non_snake_case` warning for shorthand field bindings

Fixes #89469. The problem is the innermost `if` condition here:
d14731cb3c/compiler/rustc_lint/src/nonstandard_style.rs (L435-L452)

This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
2021-10-04 21:12:38 -07:00
Jubilee
36f173f0a9
Rollup merge of #89466 - Mark-Simulacrum:query-macros, r=oli-obk
Fix bug with query modifier parsing

The previous macro_rules! parsers failed when an additional modifier was added
with ambiguity errors. The error is pretty unclear as to what exactly the cause
here is, but this change simplifies the argument parsing code such that the
error is avoided.

Extracted from other work, and somewhat duplicates 0358edeb5 from #85830, but
this approach seems a little simpler to me. Not technically currently necessary but seems
like a good cleanup.
2021-10-04 21:12:37 -07:00
Jubilee
a19537d43d
Rollup merge of #89456 - cuviper:llvm-13, r=nikic
Update to the final LLVM 13.0.0 release
2021-10-04 21:12:36 -07:00
Jubilee
05b4cd6789
Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis
Correctly handle supertraits for min_specialization

Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.

r? ````@nikomatsakis````
2021-10-04 21:12:35 -07:00
Jubilee
7aa9ce55b9
Rollup merge of #89270 - seanyoung:join_fold, r=m-ou-se
path.push() should work as expected on windows verbatim paths

On Windows, std::fs::canonicalize() returns an so-called UNC path.  UNC paths differ with regular paths because:

- This type of path can much longer than a non-UNC path (32k vs 260 characters).
- The prefix for a UNC path is ``Component::Prefix(Prefix::DiskVerbatim(..)))``
- No `/` is allowed
- No `.` is allowed
- No `..` is allowed

Rust has poor handling of such paths. If you join a UNC path with a path with any of the above, then this will not work.

I've implemented a new method `fn join_fold()` which joins paths and also removes any `.` and `..` from it, and replaces `/` with `\` on Windows. Using this function it is possible to use UNC paths without issue. In addition, this function is useful on Linux too; paths can be appended without having to call `canonicalize()` to remove the `.` and `..`.

This PR needs test cases, which can I add. I hope this will a start of a discussion.
2021-10-04 21:12:35 -07:00
Jubilee
234fa90878
Rollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se
Added abs_diff for integer types.

Closes https://github.com/rust-lang/rust/issues/62111.
2021-10-04 21:12:34 -07:00
Jubilee
4f6afee4e5
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
Perform type inference in range pattern

Fix #88074
2021-10-04 21:12:33 -07:00
Jubilee
99e6e3ff07
Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett
Stabilize try_reserve

Stabilization PR for the [`try_reserve` feature](https://github.com/rust-lang/rust/issues/48043#issuecomment-898040475).
2021-10-04 21:12:33 -07:00
Ralf Jung
e5d01785f8 update Miri 2021-10-04 18:13:00 -04:00
Michael Howell
ccd2be5b91 fix busted JavaScript in error index generator
The old JavaScript didn't work. It filled the browser console
with "e.previousElementSibling not defined" errors, because
it didn't account for the example-wrap div that a newer version
of rustdoc added.

Additionally, it had copied versions of utility functions that
had been optimized in rustdoc main.js. This version updates those.
2021-10-04 15:04:52 -07:00
bors
003d8d3f56 Auto merge of #89530 - workingjubilee:rollup-ua14iq6, r=workingjubilee
Rollup of 13 pull requests

Successful merges:

 - #83655 ([aarch64] add target feature outline-atomics)
 - #87091 (implement advance_(back_)_by on more iterators)
 - #88451 (Fix an ICE caused by type mismatch errors being ignored)
 - #88452 (VecDeque: improve performance for From<[T; N]>)
 - #89400 (Improve wording of `map_or_else` docs)
 - #89407 (Recommend running `cargo clean` in E0514 output)
 - #89443 (Include the length in BTree hashes)
 - #89444 (rustdoc: use slice::contains instead of open-coding it)
 - #89447 (Improve error message for missing angle brackets in `[_]::method`)
 - #89453 (Consistently use 'supertrait'.)
 - #89483 (Practice diagnostic message convention)
 - #89500 (Fix ICE with buffered lint referring to AST node deleted by everybody_loops)
 - #89508 (Stabilize `const_panic`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-04 20:58:57 +00:00
Jubilee
9866b090f4
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04 13:58:17 -07:00
Jubilee
3d4467dfcc
Rollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov
Fix ICE with buffered lint referring to AST node deleted by everybody_loops

Fixes #87308. Note the following comment:
08759c691e/compiler/rustc_lint/src/early.rs (L415-L417)

As it turns out, this is not _always_ a bug, because `-Zunpretty=everybody_loops` causes a lot of AST nodes to be deleted, and thus some buffered lints will refer to non-existent node ids. To fix this, my changes simply ignore buffered lints if `-Zunpretty=everybody_loops` is enabled, which, from my understanding, shouldn't be a big issue because it only affects pretty-printing. Of course, a more elegant solution would only ignore buffered lints that actually point at deleted node ids, but I haven't figured out an easy way of achieving this.

For the concrete example in #87308, the buffered lint is created [here](08759c691e/compiler/rustc_expand/src/mbe/macro_rules.rs (L145-L151)) with the `lint_node_id` from [here](08759c691e/compiler/rustc_expand/src/mbe/macro_rules.rs (L319)), i.e. it points at the macro _expansion_, which then gets deleted by `ReplaceBodyWithLoop` [here](08759c691e/compiler/rustc_interface/src/passes.rs (L377)).
2021-10-04 13:58:16 -07:00
Jubilee
5352e17df3
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
Practice diagnostic message convention

Detected by #89455.

r? ```@estebank```
2021-10-04 13:58:15 -07:00
Jubilee
2bc89ce0bf
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisa
Consistently use 'supertrait'.

A subset of places referred to 'super-trait', so this changes them
to all use 'supertrait'. This matches 'supertype' and some other
usages. An exception is 'auto-trait' which is consistently used
in that manner.
2021-10-04 13:58:14 -07:00
Jubilee
08dd4148f1
Rollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco
Improve error message for missing angle brackets in `[_]::method`

Fixes #89388.
2021-10-04 13:58:13 -07:00
Jubilee
b115a16956
Rollup merge of #89444 - notriddle:notriddle/contains-str, r=jyn514
rustdoc: use slice::contains instead of open-coding it
2021-10-04 13:58:12 -07:00
Jubilee
e1478d650d
Rollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay
Include the length in BTree hashes

This change makes it consistent with `Hash` for all other collections.
2021-10-04 13:58:11 -07:00
Jubilee
9381d7a898
Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco
Recommend running `cargo clean` in E0514 output

This suggestion has worked for me before. Seems to me it could help others.
2021-10-04 13:58:10 -07:00
Jubilee
9e387cf27e
Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay
Improve wording of `map_or_else` docs

Changes doc text to refer to the "default" parameter as the "default"
function.

Previously, the doc text referred to the "f" parameter as the "default" function; and the "default" parameter as the "fallback" function.
2021-10-04 13:58:09 -07:00
Jubilee
19d9a147be
Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se
VecDeque: improve performance for From<[T; N]>

Create `VecDeque` directly from the array instead of inserting items one-by-one.

Benchmark
```
./x.py bench library/alloc --test-args vec_deque::bench_from_array_1000
```

* Before
```
test vec_deque::bench_from_array_1000                    ... bench:       3,991 ns/iter (+/- 717)
```

* After
```
test vec_deque::bench_from_array_1000                    ... bench:         268 ns/iter (+/- 37)
```
2021-10-04 13:58:08 -07:00
Jubilee
a2c6075dff
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Fix an ICE caused by type mismatch errors being ignored

This PR fixes #87771. It turns out that the check on `compiler/rustc_typeck/src/check/demand.rs:148` leads to the ICE. I removed it because the early return in [`check_expr_assign`](dec7fc3ced/compiler/rustc_typeck/src/check/expr.rs (L928)) already prevents unnecessary error messages from the call to `check_expr_coercable_to_type`.
2021-10-04 13:58:07 -07:00
Jubilee
ca8a10845f
Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett
implement advance_(back_)_by on more iterators

Add more efficient, non-default implementations for `feature(iter_advance_by)` (#77404) on more iterators and adapters.

This PR only contains implementations where skipping over items doesn't elide any observable side-effects such as user-provided closures or `clone()` functions. I'll put those in a separate PR.
2021-10-04 13:58:07 -07:00
Jubilee
4e9cf04c98
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
[aarch64] add target feature outline-atomics

Enable outline-atomics by default as enabled in clang by the following commit
https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11

Performance improves by several orders of magnitude when using the LSE instructions
instead of the ARMv8.0 compatible load/store exclusive instructions.

Tested on Graviton2 aarch64-linux with
x.py build && x.py install && x.py test
2021-10-04 13:58:06 -07:00
Fabian Wolff
079c075f24 Use TokenKind::similar_tokens() 2021-10-04 22:13:00 +02:00
bors
175b8db73b Auto merge of #88834 - the8472:char-count, r=joshtriplett
optimize str::from_utf8() validation when slice contains multibyte chars and str.chars().count() in all cases

The change shows small but consistent improvements across several x86 target feature levels. I also tried to optimize counting with `slice.as_chunks` but that yielded more inconsistent results, bigger improvements for some optimization levels, lesser ones in others.

```
old, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,924 ns/iter (+/- 26)
test str::str_char_count_lorem                                  ... bench:         879 ns/iter (+/- 12)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,878 ns/iter (+/- 21)
test str::str_char_count_lorem                                  ... bench:         851 ns/iter (+/- 11)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,477 ns/iter (+/- 46)
test str::str_char_count_lorem                                  ... bench:         675 ns/iter (+/- 15)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,323 ns/iter (+/- 39)
test str::str_char_count_lorem                                  ... bench:         593 ns/iter (+/- 18)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         748 ns/iter (+/- 7)
test str::str_char_count_lorem                                  ... bench:         348 ns/iter (+/- 2)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         650 ns/iter (+/- 4)
test str::str_char_count_lorem                                  ... bench:         301 ns/iter (+/- 1)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)
```

and for the multibyte-char string validation:

```
old, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       4,606 ns/iter (+/- 64)

new, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       3,837 ns/iter (+/- 60)
```
2021-10-04 12:49:57 +00:00
bors
a4797664ba Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obk
Fix unsound optimization with explicit variant discriminants

Fixes #89485.
2021-10-04 10:09:04 +00:00
Kornel
00152d8977 Stabilize try_reserve 2021-10-04 10:29:46 +01:00