]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agomacros: add diagnostic derive for lints
David Wood [Thu, 30 Jun 2022 07:57:45 +0000 (08:57 +0100)]
macros: add diagnostic derive for lints

`SessionDiagnostic` isn't suitable for use on lints as whether or not it
creates an error or a warning is decided at compile-time by the macro,
whereas lints decide this at runtime based on the location of the lint
being reported (as it will depend on the user's `allow`/`deny`
attributes, etc). Re-using most of the machinery for
`SessionDiagnostic`, this macro introduces a `LintDiagnostic` derive
which implements a `DecorateLint` trait, taking a
`LintDiagnosticBuilder` and adding to the lint according to the
diagnostic struct.

2 years agomacros: move `sess` out of builder
David Wood [Wed, 29 Jun 2022 15:22:27 +0000 (16:22 +0100)]
macros: move `sess` out of builder

`sess` field of `SessionDiagnosticDeriveBuilder` is never actually used
in the builder's member functions, so it doesn't need to be a field.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: introduce `build_field_mapping`
David Wood [Wed, 29 Jun 2022 15:13:01 +0000 (16:13 +0100)]
macros: introduce `build_field_mapping`

Move the logic for building a field mapping (which is used by the
building of format strings in `suggestion` annotations) into a helper
function.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: introduce `DecorateLint`
David Wood [Wed, 29 Jun 2022 15:07:46 +0000 (16:07 +0100)]
errors: introduce `DecorateLint`

Add a new trait to be generated by diagnostic derives which uses a
`LintDiagnosticBuilder`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agolint: `LintDiagnosticBuilder` into `rustc_errors`
David Wood [Wed, 29 Jun 2022 14:50:26 +0000 (15:50 +0100)]
lint: `LintDiagnosticBuilder` into `rustc_errors`

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: fix documentation link for diag derive
David Wood [Wed, 29 Jun 2022 14:42:12 +0000 (15:42 +0100)]
macros: fix documentation link for diag derive

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoAuto merge of #98925 - Dylan-DPC:rollup-9185c9y, r=Dylan-DPC
bors [Tue, 5 Jul 2022 12:17:26 +0000 (12:17 +0000)]
Auto merge of #98925 - Dylan-DPC:rollup-9185c9y, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97712 (ptr::copy and ptr::swap are doing untyped copies)
 - #98624 (lints: mostly translatable diagnostics)
 - #98776 (rustdoc: improve click behavior of the source code mobile full-screen "sidebar")
 - #98856 (Remove FIXME from rustdoc intra-doc test)
 - #98913 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #98913 - lnicola:rust-analyzer-2022-07-05, r=lnicola
Dylan DPC [Tue, 5 Jul 2022 10:34:35 +0000 (16:04 +0530)]
Rollup merge of #98913 - lnicola:rust-analyzer-2022-07-05, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

2 years agoRollup merge of #98856 - GuillaumeGomez:rustdoc-test-rm-fixme, r=Dylan-DPC
Dylan DPC [Tue, 5 Jul 2022 10:34:34 +0000 (16:04 +0530)]
Rollup merge of #98856 - GuillaumeGomez:rustdoc-test-rm-fixme, r=Dylan-DPC

Remove FIXME from rustdoc intra-doc test

Removed the FIXME.

For the `extern crate`, even if `pub` exported, its documentation wasn't rendered so there is no point in keeping it.

r? ``@notriddle``

2 years agoRollup merge of #98776 - notriddle:notriddle/mobile-sidebar-auto-close, r=GuillaumeGomez
Dylan DPC [Tue, 5 Jul 2022 10:34:33 +0000 (16:04 +0530)]
Rollup merge of #98776 - notriddle:notriddle/mobile-sidebar-auto-close, r=GuillaumeGomez

rustdoc: improve click behavior of the source code mobile full-screen "sidebar"

On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it.

Split out separately from #98772

2 years agoRollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors
Dylan DPC [Tue, 5 Jul 2022 10:34:32 +0000 (16:04 +0530)]
Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors

lints: mostly translatable diagnostics

As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway).

r? ``@compiler-errors``

2 years agoRollup merge of #97712 - RalfJung:untyped, r=scottmcm
Dylan DPC [Tue, 5 Jul 2022 10:34:31 +0000 (16:04 +0530)]
Rollup merge of #97712 - RalfJung:untyped, r=scottmcm

ptr::copy and ptr::swap are doing untyped copies

The consensus in https://github.com/rust-lang/rust/issues/63159 seemed to be that these operations should be "untyped", i.e., they should treat the data as raw bytes, should work when these bytes violate the validity invariant of `T`, and should exactly preserve the initialization state of the bytes that are being copied. This is already somewhat implied by the description of "copying/swapping size*N bytes" (rather than "N instances of `T`").

The implementations mostly already work that way (well, for LLVM's intrinsics the documentation is not precise enough to say what exactly happens to poison, but if this ever gets clarified to something that would *not* perfectly preserve poison, then I strongly assume there will be some way to make a copy that *does* perfectly preserve poison). However, I had to adjust `swap_nonoverlapping`; after ``@scottmcm's`` [recent changes](https://github.com/rust-lang/rust/pull/94212), that one (sometimes) made a typed copy. (Note that `mem::swap`, which works on mutable references, is unchanged. It is documented as "swapping the values at two mutable locations", which to me strongly indicates that it is indeed typed. It is also safe and can rely on `&mut T` pointing to a valid `T` as part of its safety invariant.)

On top of adding a test (that will be run by Miri), this PR then also adjusts the documentation to indeed stably promise the untyped semantics. I assume this means the PR has to go through t-libs (and maybe t-lang?) FCP.

Fixes https://github.com/rust-lang/rust/issues/63159

2 years agoAuto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJung
bors [Tue, 5 Jul 2022 09:36:29 +0000 (09:36 +0000)]
Auto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJung

Change enum->int casts to not go through MIR casts.

follow-up to https://github.com/rust-lang/rust/pull/96814

this simplifies all backends and even gives LLVM more information about the return value of `Rvalue::Discriminant`, enabling optimizations in more cases.

2 years agoPrefer trace level instrumentation for the new noisy instrument attributes
Oli Scherer [Tue, 5 Jul 2022 09:27:06 +0000 (09:27 +0000)]
Prefer trace level instrumentation for the new noisy instrument attributes

2 years agoAdd a helper method with an explicit name instead of hand rolling a match 3x
Oli Scherer [Tue, 5 Jul 2022 09:26:45 +0000 (09:26 +0000)]
Add a helper method with an explicit name instead of hand rolling a match 3x

2 years agoAuto merge of #98910 - Dylan-DPC:rollup-9x82wdg, r=Dylan-DPC
bors [Tue, 5 Jul 2022 06:44:49 +0000 (06:44 +0000)]
Auto merge of #98910 - Dylan-DPC:rollup-9x82wdg, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #97300 (Implement `FusedIterator` for `std::net::[Into]Incoming`)
 - #98761 (more `need_type_info` improvements)
 - #98811 (Interpret: AllocRange Debug impl, and use it more consistently)
 - #98847 (fix interpreter validity check on Box)
 - #98854 (clean up the borrowing in rustc_hir_pretty)
 - #98873 (Suggest `#[derive(Default)]` to enums with `#[default]`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 5 Jul 2022 06:29:11 +0000 (09:29 +0300)]
:arrow_up: rust-analyzer

2 years agoRollup merge of #98873 - TaKO8Ki:suggest-default-derive-to-enum-with-default-attribut...
Dylan DPC [Tue, 5 Jul 2022 05:12:59 +0000 (10:42 +0530)]
Rollup merge of #98873 - TaKO8Ki:suggest-default-derive-to-enum-with-default-attribute, r=fee1-dead

Suggest `#[derive(Default)]` to enums with `#[default]`

fixes #95226

2 years agoRollup merge of #98854 - kadiwa4:rustc_hir_pretty_clean_up_borrowing, r=oli-obk
Dylan DPC [Tue, 5 Jul 2022 05:12:58 +0000 (10:42 +0530)]
Rollup merge of #98854 - kadiwa4:rustc_hir_pretty_clean_up_borrowing, r=oli-obk

clean up the borrowing in rustc_hir_pretty

A whole lot of the `&`s and `ref`s were redundant. I hope doing this in one big commit is fine, because all of the changes are pretty self-contained.

`@rustbot` label: +C-cleanup

2 years agoRollup merge of #98847 - RalfJung:box-is-special, r=oli-obk
Dylan DPC [Tue, 5 Jul 2022 05:12:57 +0000 (10:42 +0530)]
Rollup merge of #98847 - RalfJung:box-is-special, r=oli-obk

fix interpreter validity check on Box

Follow-up to https://github.com/rust-lang/rust/pull/98554: avoid walking over parts of the value twice.

And then move all that logic into the general visitor so not each visitor implementation has to deal with it...

2 years agoRollup merge of #98811 - RalfJung:interpret-alloc-range, r=oli-obk
Dylan DPC [Tue, 5 Jul 2022 05:12:55 +0000 (10:42 +0530)]
Rollup merge of #98811 - RalfJung:interpret-alloc-range, r=oli-obk

Interpret: AllocRange Debug impl, and use it more consistently

The two commits are pretty independent but it did not seem worth having two PRs for them.
r? ``@oli-obk``

2 years agoRollup merge of #98761 - lcnr:need_type_info-cont, r=estebank
Dylan DPC [Tue, 5 Jul 2022 05:12:54 +0000 (10:42 +0530)]
Rollup merge of #98761 - lcnr:need_type_info-cont, r=estebank

more `need_type_info` improvements

this now deals with macros in suggestions and the source cost computation does what I want for `channel` :tada:

r? ``@estebank``

2 years agoRollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnay
Dylan DPC [Tue, 5 Jul 2022 05:12:52 +0000 (10:42 +0530)]
Rollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnay

Implement `FusedIterator` for `std::net::[Into]Incoming`

They never return `None`, so they trivially fulfill the contract.

What should I put for the stability attribute of `Incoming`?

2 years agoAuto merge of #98872 - JakobDegen:no-invalidate, r=davidtwco
bors [Tue, 5 Jul 2022 04:04:04 +0000 (04:04 +0000)]
Auto merge of #98872 - JakobDegen:no-invalidate, r=davidtwco

Add method to mutate MIR body without invalidating CFG caches.

In addition to adding this method, a handful of passes are updated to use it. There's still quite a few passes that could in principle make use of this as well, but do not at the moment because they use `VisitorMut` or `MirPatch`, which needs additional support for this.

The method name is slightly unwieldy, but I don't expect anyone to be writing it a lot, and at least it says what it does. If anyone has a suggestion for a better name though, would be happy to rename.

r? rust-lang/mir-opt

2 years agoAuto merge of #98846 - RalfJung:alignment-is-a-type-thing, r=oli-obk
bors [Tue, 5 Jul 2022 01:23:09 +0000 (01:23 +0000)]
Auto merge of #98846 - RalfJung:alignment-is-a-type-thing, r=oli-obk

interpret: track place alignment together with the type, not the value

This matches how I handle alignment in [MiniRust](https://github.com/RalfJung/minirust). I think it makes conceptually a lot more sense.
Fixes https://github.com/rust-lang/rust/issues/63085

r? `@oli-obk`

2 years agoAuto merge of #98904 - matthiaskrgr:rollup-05owsx7, r=matthiaskrgr
bors [Mon, 4 Jul 2022 22:42:15 +0000 (22:42 +0000)]
Auto merge of #98904 - matthiaskrgr:rollup-05owsx7, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #98738 (Clarify MIR semantics of checked binary operations)
 - #98782 (Improve spans for specialization error)
 - #98793 (Lint against executable files in the root directory)
 - #98814 (rustdoc: Censor certain complex unevaluated const exprs)
 - #98878 (add more `rustc_pass_by_value`)
 - #98879 (Fix "wrap closure in parenthesis" suggestion for `async` closure)
 - #98886 (incr.comp.: Make split-dwarf commandline options [TRACKED].)
 - #98898 (Add "no-div-regex" eslint rule)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #98898 - GuillaumeGomez:new-eslint-rul, r=Dylan-DPC
Matthias Krüger [Mon, 4 Jul 2022 21:11:15 +0000 (23:11 +0200)]
Rollup merge of #98898 - GuillaumeGomez:new-eslint-rul, r=Dylan-DPC

Add "no-div-regex" eslint rule

r? `@Dylan-DPC`

2 years agoRollup merge of #98886 - michaelwoerister:tracked-split-dwarf-kind, r=davidtwco
Matthias Krüger [Mon, 4 Jul 2022 21:11:14 +0000 (23:11 +0200)]
Rollup merge of #98886 - michaelwoerister:tracked-split-dwarf-kind, r=davidtwco

incr.comp.: Make split-dwarf commandline options [TRACKED].

This commandline options have an influence on the contents of object files (and .dwo files), so they need to be `[TRACKED]`.

r? `@davidtwco`

2 years agoRollup merge of #98879 - compiler-errors:async-closure-wrap-parens, r=oli-obk
Matthias Krüger [Mon, 4 Jul 2022 21:11:13 +0000 (23:11 +0200)]
Rollup merge of #98879 - compiler-errors:async-closure-wrap-parens, r=oli-obk

Fix "wrap closure in parenthesis" suggestion for `async` closure

Fixes #98023

2 years agoRollup merge of #98878 - lcnr:more-rustc_pass_by_value, r=oli-obk
Matthias Krüger [Mon, 4 Jul 2022 21:11:12 +0000 (23:11 +0200)]
Rollup merge of #98878 - lcnr:more-rustc_pass_by_value, r=oli-obk

add more `rustc_pass_by_value`

r? ```@oli-obk``` cc #98766

2 years agoRollup merge of #98814 - fmease:minimal-fix-for-issue-97933, r=GuillaumeGomez
Matthias Krüger [Mon, 4 Jul 2022 21:11:11 +0000 (23:11 +0200)]
Rollup merge of #98814 - fmease:minimal-fix-for-issue-97933, r=GuillaumeGomez

rustdoc: Censor certain complex unevaluated const exprs

Fixes #97933.

This is more of a hotfix for the aforementioned issue. By that, I mean that my proposed patch is
not the best solution but one that does not change as much existing code.
It treats symptoms rather than the root cause.

This PR “censors” certain complex unevaluated constant expressions like `match`es, blocks, function calls, struct literals etc. by pretty-printing them as `_` / `{ _ }` (number and string literals, paths and `()` are still printed as one would expect).
Resorting to this placeholder is preferable to printing the full expression verbatim since
they can be quite large and verbose resulting in an unreadable mess in the generated documentation.
Further, mindlessly printing the const would leak private and `doc(hidden)` struct fields (#97933), at least in the current
stable & nightly implementations which rely on `span_to_snippet` (!) and `rustc_hir_pretty::id_to_string`.

The censoring of _verbose_ expressions is probably going to stay longer term.
However, in regards to private and `doc(hidden)` struct fields, I have a more proper fix in mind
which I have already partially implemented locally and for which I am going to open a separate PR sometime soon.
For that, I was already in contact with `@GuillaumeGomez.`
The proper fix involves rustdoc not falling back on pretty-printing unevaluated consts so easily (what this PR is concerned about)
and instead preferring to print evaluated consts which contain more information allowing it to selectively hide private and `doc(hidden)` fields, create hyperlinks etc. generally making the output more granular and precise (compared to the brutal `_` placeholder).

Unfortunately, I was a bit too late and the issue just hit stable (1.62).
Should this be backported to beta or even a potential 1.62.1?

r? `@GuillaumeGomez`

2 years agoRollup merge of #98793 - Mark-Simulacrum:fix-tidy-bins, r=jyn514
Matthias Krüger [Mon, 4 Jul 2022 21:11:10 +0000 (23:11 +0200)]
Rollup merge of #98793 - Mark-Simulacrum:fix-tidy-bins, r=jyn514

Lint against executable files in the root directory

This avoids accidental introduction (such as in #97488) of executable files into the root directory, not just under library/, src/ or compiler/.

Resolves #98792

2 years agoRollup merge of #98782 - compiler-errors:specialization-error-span, r=oli-obk
Matthias Krüger [Mon, 4 Jul 2022 21:11:09 +0000 (23:11 +0200)]
Rollup merge of #98782 - compiler-errors:specialization-error-span, r=oli-obk

Improve spans for specialization error

Fixes #98777

2 years agoRollup merge of #98738 - tmiasko:checked-binop, r=oli-obk
Matthias Krüger [Mon, 4 Jul 2022 21:11:07 +0000 (23:11 +0200)]
Rollup merge of #98738 - tmiasko:checked-binop, r=oli-obk

Clarify MIR semantics of checked binary operations

2 years agoAuto merge of #98627 - RalfJung:interpret-arith, r=lcnr
bors [Mon, 4 Jul 2022 20:00:41 +0000 (20:00 +0000)]
Auto merge of #98627 - RalfJung:interpret-arith, r=lcnr

interpret: don't rely on ScalarPair for overflowed arithmetic

This is for https://github.com/rust-lang/rust/pull/97861.
Cc `@eddyb`

I would like to avoid making this depend on `dest.layout.abi` to avoid a branch that we are not usually covering both sides of. Though OTOH this seems like fairly straight-forward code. But let's benchmark this option first to see how bad that extra `force_allocation` really is.

2 years agorustdoc: censor certain complex unevaluated const exprs
León Orell Valerian Liehr [Thu, 23 Jun 2022 15:19:56 +0000 (17:19 +0200)]
rustdoc: censor certain complex unevaluated const exprs

2 years agoAuto merge of #98573 - krasimirgg:nlmb-llvm-nm, r=nikic
bors [Mon, 4 Jul 2022 15:59:44 +0000 (15:59 +0000)]
Auto merge of #98573 - krasimirgg:nlmb-llvm-nm, r=nikic

adapt native-link-modifier-bundle test to use llvm-nm

No functional changes intended.

This updates the test case to use `llvm-nm` as an alternative to https://github.com/rust-lang/rust/pull/98424.

This fixes a test failure over at the experimental build of rustc with HEAD LLVM:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/11144#01814d0f-a46a-4c19-91cf-41e720edb6f9/684-691.

The issue is that this test uses the system nm, which may not be recent
enough to understand the bitcode produced by rustc when compiled against HEAD LLVM.

Similar to what we did for another test in https://github.com/rust-lang/rust/pull/94023.

2 years agoAdd "no-div-regex" eslint rule
Guillaume Gomez [Mon, 4 Jul 2022 15:50:19 +0000 (17:50 +0200)]
Add "no-div-regex" eslint rule

2 years agoextra assertion, extra sure
Ralf Jung [Mon, 4 Jul 2022 13:12:22 +0000 (09:12 -0400)]
extra assertion, extra sure

2 years agoclarify comment
Ralf Jung [Mon, 4 Jul 2022 13:05:23 +0000 (09:05 -0400)]
clarify comment

2 years agoadapt native-link-modifier-bundle test to use llvm-nm
Krasimir Georgiev [Wed, 29 Jun 2022 08:41:32 +0000 (08:41 +0000)]
adapt native-link-modifier-bundle test to use llvm-nm

2 years agoAuto merge of #98817 - the8472:dont-optimize-ui-tests, r=Mark-Simulacrum
bors [Mon, 4 Jul 2022 12:32:39 +0000 (12:32 +0000)]
Auto merge of #98817 - the8472:dont-optimize-ui-tests, r=Mark-Simulacrum

Only obey optimize-tests flag on UI tests that are run-pass

stage1 UI tests walltime on my machine:

```
optimize-tests = false, master
25.98s

optimize-tests = true, master
34.69s

optimize-tests = true, patched
28.79s
```

Effects:

- faster UI tests
- llvm asserts get exercised less on build-pass tests
- the difference between opt and nopt builds shrinks a bit
- aux libs don't get optimized since they don't have a pass mode and almost never have explicit compile flags

2 years agoincr.comp.: Make split-dwarf commandline options [TRACKED].
Michael Woerister [Mon, 4 Jul 2022 12:04:35 +0000 (14:04 +0200)]
incr.comp.: Make split-dwarf commandline options [TRACKED].

2 years ago`InferSource::GenericArg`, check for contains
lcnr [Fri, 1 Jul 2022 13:49:05 +0000 (15:49 +0200)]
`InferSource::GenericArg`, check for contains

2 years agoresolve vars in node substs
lcnr [Fri, 1 Jul 2022 13:20:38 +0000 (15:20 +0200)]
resolve vars in node substs

2 years agostop suggesting things inside of macros
lcnr [Fri, 1 Jul 2022 12:34:00 +0000 (14:34 +0200)]
stop suggesting things inside of macros

2 years agoupdate infer cost computation for types
lcnr [Fri, 1 Jul 2022 12:09:33 +0000 (14:09 +0200)]
update infer cost computation for types

2 years agoremove unused function argument
lcnr [Fri, 1 Jul 2022 11:36:49 +0000 (13:36 +0200)]
remove unused function argument

2 years agosuggest `#[derive(Default)]` to enums with `#[default]`
Takayuki Maeda [Mon, 4 Jul 2022 11:46:59 +0000 (20:46 +0900)]
suggest `#[derive(Default)]` to enums with `#[default]`

2 years agoAuto merge of #98641 - lcnr:mir-dropck, r=oli-obk
bors [Mon, 4 Jul 2022 09:23:01 +0000 (09:23 +0000)]
Auto merge of #98641 - lcnr:mir-dropck, r=oli-obk

fully move dropck to mir

r? `@oli-obk`

2 years agofully move dropck to mir
lcnr [Tue, 28 Jun 2022 20:56:32 +0000 (22:56 +0200)]
fully move dropck to mir

2 years agoFix wrap parenthesis suggestion for async closure
Michael Goulet [Mon, 4 Jul 2022 08:07:12 +0000 (08:07 +0000)]
Fix wrap parenthesis suggestion for async closure

2 years agomore `rustc_pass_by_value`
lcnr [Mon, 4 Jul 2022 07:40:58 +0000 (09:40 +0200)]
more `rustc_pass_by_value`

2 years agoAuto merge of #98874 - matthiaskrgr:rollup-0u4hm54, r=matthiaskrgr
bors [Mon, 4 Jul 2022 06:35:29 +0000 (06:35 +0000)]
Auto merge of #98874 - matthiaskrgr:rollup-0u4hm54, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #98501 (rustc_passes/src/entry.rs: De-duplicate more code with `fn throw_attr_err()`)
 - #98774 (rustdoc: make source sidebar toggle a real button)
 - #98806 (Fix long declaration trailing whitespace)
 - #98823 (Fix rust-call ICE in mir-inliner)
 - #98870 (Add regression test for #86784)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoAdd method to mutate MIR body without invalidating CFG caches.
Jakob Degen [Mon, 4 Jul 2022 02:55:45 +0000 (19:55 -0700)]
Add method to mutate MIR body without invalidating CFG caches.

In addition to adding this method, a handful of passes are updated to use it.

2 years agoRollup merge of #98870 - TaKO8Ki:add-regression-test-for-86784, r=compiler-errors
Matthias Krüger [Mon, 4 Jul 2022 04:08:11 +0000 (06:08 +0200)]
Rollup merge of #98870 - TaKO8Ki:add-regression-test-for-86784, r=compiler-errors

Add regression test for #86784

closes #86784

2 years agoRollup merge of #98823 - compiler-errors:rust-call-mir-inline, r=cjgillot
Matthias Krüger [Mon, 4 Jul 2022 04:08:10 +0000 (06:08 +0200)]
Rollup merge of #98823 - compiler-errors:rust-call-mir-inline, r=cjgillot

Fix rust-call ICE in mir-inliner

Fixes #98821
r? ``@cjgillot``

2 years agoRollup merge of #98806 - GuillaumeGomez:decl-trailing-whitespace, r=notriddle
Matthias Krüger [Mon, 4 Jul 2022 04:08:09 +0000 (06:08 +0200)]
Rollup merge of #98806 - GuillaumeGomez:decl-trailing-whitespace, r=notriddle

Fix long declaration trailing whitespace

Fixes https://github.com/rust-lang/rust/issues/98803.

Interestingly enough, it even simplifies the code a bit.

r? `@notriddle`

2 years agoRollup merge of #98774 - notriddle:notriddle/source-code-sidebar-button, r=GuillaumeGomez
Matthias Krüger [Mon, 4 Jul 2022 04:08:08 +0000 (06:08 +0200)]
Rollup merge of #98774 - notriddle:notriddle/source-code-sidebar-button, r=GuillaumeGomez

rustdoc: make source sidebar toggle a real button

This fixes tab focus, so that you can open and close the sidebar from keyboard.

This should cause no visible change in appearance at all. The only way you'd know anything different is if you tried to use keyboard controls to open the source code file navigation sidebar.

Separated out from #98772

2 years agoRollup merge of #98501 - Enselic:err_if_attr_found, r=compiler-errors
Matthias Krüger [Mon, 4 Jul 2022 04:08:07 +0000 (06:08 +0200)]
Rollup merge of #98501 - Enselic:err_if_attr_found, r=compiler-errors

rustc_passes/src/entry.rs: De-duplicate more code with `fn throw_attr_err()`

So we can more easily re-use the code for other attributes later. More specifically [`#[unix_sigpipe]`](https://github.com/rust-lang/rust/pull/97802). This refactoring is covered by this test:
https://github.com/rust-lang/rust/blob/8aab472d52ba7314dc193c73abcd384e2586123c/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs#L120
(Well, only `#[start]`, but the code for `#[rustc_main]` is identical.)

2 years agoAuto merge of #98731 - InfRandomness:fix-#98728, r=Mark-Simulacrum
bors [Mon, 4 Jul 2022 03:54:47 +0000 (03:54 +0000)]
Auto merge of #98731 - InfRandomness:fix-#98728, r=Mark-Simulacrum

Revert #95993 fix

This reverts the temporary fix implemented by https://github.com/rust-lang/rust/pull/95993 since a permanent fix has been implemented by https://github.com/rust-lang/cargo/pull/10594

Fixes https://github.com/rust-lang/rust/issues/98728

2 years agomove Box mess handling into general visitor
Ralf Jung [Mon, 4 Jul 2022 02:55:25 +0000 (22:55 -0400)]
move Box mess handling into general visitor

2 years agofix interpreter validity check on Box
Ralf Jung [Sun, 3 Jul 2022 15:29:49 +0000 (11:29 -0400)]
fix interpreter validity check on Box

2 years agoadd regression test for #86784
Takayuki Maeda [Mon, 4 Jul 2022 02:07:13 +0000 (11:07 +0900)]
add regression test for #86784

2 years agoAuto merge of #98446 - nnethercote:derive-no-match-destructuring, r=scottmcm
bors [Mon, 4 Jul 2022 01:06:54 +0000 (01:06 +0000)]
Auto merge of #98446 - nnethercote:derive-no-match-destructuring, r=scottmcm

Don't use match-destructuring for derived ops on structs.

r? `@scottmcm`

2 years agoDon't use match-destructuring for derived ops on structs.
Nicholas Nethercote [Fri, 24 Jun 2022 00:20:54 +0000 (10:20 +1000)]
Don't use match-destructuring for derived ops on structs.

All derive ops currently use match-destructuring to access fields. This
is reasonable for enums, but sub-optimal for structs. E.g.:
```
fn eq(&self, other: &Point) -> bool {
    match *other {
Self { x: ref __self_1_0, y: ref __self_1_1 } =>
    match *self {
Self { x: ref __self_0_0, y: ref __self_0_1 } =>
    (*__self_0_0) == (*__self_1_0) &&
(*__self_0_1) == (*__self_1_1),
    },
    }
}
```
This commit changes derive ops on structs to use field access instead, e.g.:
```
fn eq(&self, other: &Point) -> bool {
    self.x == other.x && self.y == other.y
}
```
This is faster to compile, results in smaller binaries, and is simpler to
generate. Unfortunately, we have to keep the old pattern generating code around
for `repr(packed)` structs because something like `&self.x` (which doesn't show
up in `PartialEq` ops, but does show up in `Debug` and `Hash` ops) isn't
allowed. But this commit at least changes those cases to use let-destructuring
instead of match-destructuring, e.g.:
```
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
    {
let Self(ref __self_0_0) = *self;
{ ::core::hash::Hash::hash(&(*__self_0_0), state) }
    }
}
```
There are some unnecessary blocks remaining in the generated code, but I
will fix them in a follow-up PR.

2 years agoComment fixes.
Nicholas Nethercote [Thu, 23 Jun 2022 22:31:00 +0000 (08:31 +1000)]
Comment fixes.

Remove an out-of-date sentence, and fix a typo.

2 years agoAdd an interesting case to the `deriving-all-codegen.rs` test.
Nicholas Nethercote [Fri, 24 Jun 2022 04:06:35 +0000 (14:06 +1000)]
Add an interesting case to the `deriving-all-codegen.rs` test.

2 years agoAuto merge of #98864 - RalfJung:rollup-ptzklyc, r=RalfJung
bors [Sun, 3 Jul 2022 22:20:10 +0000 (22:20 +0000)]
Auto merge of #98864 - RalfJung:rollup-ptzklyc, r=RalfJung

Rollup of 4 pull requests

Successful merges:

 - #94831 (Link to stabilization section in std-dev-guide for library tracking issue template)
 - #98764 (add Miri to the nightly docs)
 - #98773 (rustdoc: use <details> tag for the source code sidebar)
 - #98799 (Fix bug in `rustdoc -Whelp`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #98799 - jyn514:rustdoc-lint-help, r=GuillaumeGomez
Ralf Jung [Sun, 3 Jul 2022 20:41:57 +0000 (16:41 -0400)]
Rollup merge of #98799 - jyn514:rustdoc-lint-help, r=GuillaumeGomez

Fix bug in `rustdoc -Whelp`

Previously, this printed the debugging options, not the lint options,
and only handled `-Whelp`, not `-A/-D/-F`.

This also fixes a few other misc issues:
- Fix `// check-stdout` for UI tests; previously it only worked for run-fail and compile-fail tests
- Add lint headers for tool lints, not just builtin lints

https://github.com/rust-lang/rust/pull/98533#issuecomment-1172004197

r? ```@GuillaumeGomez```

2 years agoRollup merge of #98773 - notriddle:notriddle/source-sidebar-details, r=GuillaumeGomez
Ralf Jung [Sun, 3 Jul 2022 20:41:56 +0000 (16:41 -0400)]
Rollup merge of #98773 - notriddle:notriddle/source-sidebar-details, r=GuillaumeGomez

rustdoc: use <details> tag for the source code sidebar

This fixes the extremely poor accessibility of the old system, making it possible to navigate the sidebar by keyboard, and also implicitly gives the sidebar items the correct ARIA roles.

Split out separately from #98772

2 years agoRollup merge of #98764 - InfRandomness:miri-rustdoc, r=jyn514
Ralf Jung [Sun, 3 Jul 2022 20:41:54 +0000 (16:41 -0400)]
Rollup merge of #98764 - InfRandomness:miri-rustdoc, r=jyn514

add Miri to the nightly docs

This is a follow-up to https://github.com/rust-lang/rust/pull/97773 and to https://github.com/rust-lang/rust/pull/98714

It adds miri to the doc.rust-lang.org/nightly/nightly-rustc](https://doc.rust-lang.org/nightly/nightly-rustc/

2 years agoRollup merge of #94831 - yaahc:lib-tracking-issue-template-update, r=JohnTitor
Ralf Jung [Sun, 3 Jul 2022 20:41:53 +0000 (16:41 -0400)]
Rollup merge of #94831 - yaahc:lib-tracking-issue-template-update, r=JohnTitor

Link to stabilization section in std-dev-guide for library tracking issue template

This shouldn't land until https://github.com/rust-lang/std-dev-guide/pull/32 is merged.

2 years agoignore rustdoc failures for out-of-tree tools
Ralf Jung [Thu, 30 Jun 2022 14:41:04 +0000 (10:41 -0400)]
ignore rustdoc failures for out-of-tree tools

2 years agoAdd in_tree macro literal
InfRandomness [Mon, 6 Jun 2022 15:21:39 +0000 (17:21 +0200)]
Add in_tree macro literal

Signed-off-by: InfRandomness <infrandomness@gmail.com>
2 years agoAdd miri to the rustc docs.rs page
InfRandomness [Sun, 5 Jun 2022 21:33:39 +0000 (23:33 +0200)]
Add miri to the rustc docs.rs page

This adds miri to https://doc.rust-lang.org/nightly/nightly-rustc/

Signed-off-by: InfRandomness <infrandomness@gmail.com>
2 years agoAuto merge of #98439 - ehuss:cleanup-ci-script, r=Mark-Simulacrum
bors [Sun, 3 Jul 2022 19:39:28 +0000 (19:39 +0000)]
Auto merge of #98439 - ehuss:cleanup-ci-script, r=Mark-Simulacrum

Clean up submodule checkout scripts

This is just some small cleanup:

* Removed unused CACHE_DIR stuff
* Removed duplicate fetch_github_commit_archive function which is no longer used
* Combined init_repo.sh and checkout-submodules.sh, as checkout-submodules.sh was doing nothing but calling init_repo.sh

2 years agoRemove redundant pseudo-class
Michael Howell [Sun, 3 Jul 2022 18:42:44 +0000 (11:42 -0700)]
Remove redundant pseudo-class

2 years agoAdd test for trailing whitespace in long declaration
Guillaume Gomez [Sat, 2 Jul 2022 10:43:33 +0000 (12:43 +0200)]
Add test for trailing whitespace in long declaration

2 years agoRemove FIXME from rustdoc intra-doc test
Guillaume Gomez [Sun, 3 Jul 2022 18:23:30 +0000 (20:23 +0200)]
Remove FIXME from rustdoc intra-doc test

2 years agoclean up the borrowing in rustc_hir_pretty
KaDiWa [Sun, 3 Jul 2022 16:51:14 +0000 (18:51 +0200)]
clean up the borrowing in rustc_hir_pretty

a lot of the `&`s and `ref`s were redundant

2 years agoAuto merge of #98373 - joshtriplett:bootstrap-locking, r=jyn514
bors [Sun, 3 Jul 2022 16:29:09 +0000 (16:29 +0000)]
Auto merge of #98373 - joshtriplett:bootstrap-locking, r=jyn514

Move locking from bootstrap.py to rust bootstrap, using fd-lock

Helps with https://github.com/rust-lang/rust/issues/94829.

2 years agointerpret: track place alignment together with the type, not the value
Ralf Jung [Sun, 3 Jul 2022 14:21:47 +0000 (10:21 -0400)]
interpret: track place alignment together with the type, not the value

2 years agointerpret: don't rely on ScalarPair for overflowed arithmetic
Ralf Jung [Tue, 28 Jun 2022 15:39:22 +0000 (11:39 -0400)]
interpret: don't rely on ScalarPair for overflowed arithmetic

2 years agoAuto merge of #97437 - jyn514:impl-asrawfd-arc, r=dtolnay
bors [Sun, 3 Jul 2022 12:17:19 +0000 (12:17 +0000)]
Auto merge of #97437 - jyn514:impl-asrawfd-arc, r=dtolnay

`impl<T: AsRawFd> AsRawFd for {Arc,Box}<T>`

This allows implementing traits that require a raw FD on Arc and Box.

Previously, you'd have to add the function to the trait itself:

```rust
trait MyTrait {
    fn as_raw_fd(&self) -> RawFd;
}

impl<T: MyTrait> MyTrait for Arc<T> {
    fn as_raw_fd(&self) -> RawFd {
        (**self).as_raw_fd()
    }
}
```

In particular, this leads to lots of "multiple applicable items in scope" errors because you have to disambiguate `MyTrait::as_raw_fd` from `AsRawFd::as_raw_fd` at each call site. In generic contexts, when passing the type to a function that takes `impl AsRawFd` it's also sometimes required to use `T: MyTrait + AsRawFd`, which wouldn't be necessary if I could write `MyTrait: AsRawFd`.

After this PR, the code can be simpler:
```rust
trait MyTrait: AsRawFd {}

impl<T: MyTrait> MyTrait for Arc<T> {}
```

2 years agoAuto merge of #98755 - nnethercote:faster-vec-insert, r=cuviper
bors [Sun, 3 Jul 2022 09:36:37 +0000 (09:36 +0000)]
Auto merge of #98755 - nnethercote:faster-vec-insert, r=cuviper

Optimize `Vec::insert` for the case where `index == len`.

By skipping the call to `copy` with a zero length. This makes it closer
to `push`.

I did this recently for `SmallVec`
(https://github.com/servo/rust-smallvec/pull/282) and it was a big perf win in
one case. Although I don't have a specific use case in mind, it seems
worth doing it for `Vec` as well.

Things to note:
- In the `index < len` case, the number of conditions checked is
  unchanged.
- In the `index == len` case, the number of conditions checked increases
  by one, but the more expensive zero-length copy is avoided.
- In the `index > len` case the code now reserves space for the extra
  element before panicking. This seems like an unimportant change.

r? `@cuviper`

2 years agoAuto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
bors [Sun, 3 Jul 2022 06:55:50 +0000 (06:55 +0000)]
Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum

Bump bootstrap compiler

r? `@Mark-Simulacrum`

2 years agoAuto merge of #98570 - SparrowLii:deadlock, r=cjgillot
bors [Sun, 3 Jul 2022 02:05:14 +0000 (02:05 +0000)]
Auto merge of #98570 - SparrowLii:deadlock, r=cjgillot

get rid of `tcx` in deadlock handler when parallel compilation

This is a very obscure and hard-to-trace problem that affects thread scheduling. If we copy `tcx` to the deadlock handler thread, it will perform unpredictable behavior and cause very weird problems when executing `try_collect_active_jobs`(For example, the deadlock handler thread suddenly preempts the content of the blocked worker thread and executes the unknown judgment branch, like #94654).
Fortunately we can avoid this behavior by precomputing `query_map`. This change fixes the following ui tests failure on my environment when set `parallel-compiler = true`:
```
    [ui] src/test\ui\async-await\no-const-async.rs
    [ui] src/test\ui\infinite\infinite-struct.rs
    [ui] src/test\ui\infinite\infinite-tag-type-recursion.rs
    [ui] src/test\ui\issues\issue-3008-1.rs
    [ui] src/test\ui\issues\issue-3008-2.rs
    [ui] src/test\ui\issues\issue-32326.rs
    [ui] src/test\ui\issues\issue-57271.rs
    [ui] src/test\ui\issues\issue-72554.rs
    [ui] src/test\ui\parser\fn-header-semantic-fail.rs
    [ui] src/test\ui\union\union-nonrepresentable.rs
```

Updates #75760
Fixes #94654

2 years agoAuto merge of #98569 - nnethercote:finalize_resolutions_id, r=cjgillot
bors [Sat, 2 Jul 2022 23:38:08 +0000 (23:38 +0000)]
Auto merge of #98569 - nnethercote:finalize_resolutions_id, r=cjgillot

Avoid unnecessary work in `finalize_resolutions_in`.

If `module.opt_def_id()` returns `None`, we can skip most of the work.

r? `@lqd`

2 years agoFix rust-call ICE in mir-inliner
Michael Goulet [Sat, 2 Jul 2022 21:40:33 +0000 (21:40 +0000)]
Fix rust-call ICE in mir-inliner

2 years agomove optimize-tests flag handling from bootstrap to compiletest
The 8472 [Sat, 2 Jul 2022 20:19:49 +0000 (22:19 +0200)]
move optimize-tests flag handling from bootstrap to compiletest

2 years agoAuto merge of #98820 - RalfJung:rollup-i3mip9a, r=RalfJung
bors [Sat, 2 Jul 2022 19:46:01 +0000 (19:46 +0000)]
Auto merge of #98820 - RalfJung:rollup-i3mip9a, r=RalfJung

Rollup of 6 pull requests

Successful merges:

 - #98701 (Add regression test for #50439)
 - #98715 (add ice test for #97047)
 - #98753 (Fix `x dist rust-dev` on a fresh checkout)
 - #98805 (Add #95469 to the release notes)
 - #98812 (feat: Add a documentation problem issue template)
 - #98819 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #98819 - RalfJung:miri, r=RalfJung
Ralf Jung [Sat, 2 Jul 2022 19:21:21 +0000 (15:21 -0400)]
Rollup merge of #98819 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/98779
r? `@ghost`

2 years agoRollup merge of #98812 - gimbles:docs-template, r=Mark-Simulacrum
Ralf Jung [Sat, 2 Jul 2022 19:21:20 +0000 (15:21 -0400)]
Rollup merge of #98812 - gimbles:docs-template, r=Mark-Simulacrum

feat: Add a documentation problem issue template

Fixes #98722 :)

2 years agoRollup merge of #98805 - ChrisDenton:rel-notes, r=Dylan-DPC
Ralf Jung [Sat, 2 Jul 2022 19:21:19 +0000 (15:21 -0400)]
Rollup merge of #98805 - ChrisDenton:rel-notes, r=Dylan-DPC

Add #95469 to the release notes

#95469 may break programs using async file handles so it should've been noted in compatibility notes (sorry).

2 years agoRollup merge of #98753 - jyn514:dist-rust-dev, r=Mark-Simulacrum
Ralf Jung [Sat, 2 Jul 2022 19:21:18 +0000 (15:21 -0400)]
Rollup merge of #98753 - jyn514:dist-rust-dev, r=Mark-Simulacrum

Fix `x dist rust-dev` on a fresh checkout

Previously, it required you to manually run `x build` first, because it
assumed the LLVM binaries were already present.

2 years agoRollup merge of #98715 - matthiaskrgr:test_97047, r=Mark-Simulacrum
Ralf Jung [Sat, 2 Jul 2022 19:21:17 +0000 (15:21 -0400)]
Rollup merge of #98715 - matthiaskrgr:test_97047, r=Mark-Simulacrum

add ice test for #97047

Fixes #97047

2 years agoRollup merge of #98701 - TaKO8Ki:add-regression-test-for-50439, r=Mark-Simulacrum
Ralf Jung [Sat, 2 Jul 2022 19:21:16 +0000 (15:21 -0400)]
Rollup merge of #98701 - TaKO8Ki:add-regression-test-for-50439, r=Mark-Simulacrum

Add regression test for #50439

closes #50439

2 years agoupdate Miri
Ralf Jung [Sat, 2 Jul 2022 19:15:56 +0000 (15:15 -0400)]
update Miri

2 years agoOnly obey optimize-tests flag on UI tests that are run-pass
The 8472 [Sat, 2 Jul 2022 18:50:55 +0000 (20:50 +0200)]
Only obey optimize-tests flag on UI tests that are run-pass

```
optimize-tests = false, master
25.98s

optimize-tests = true, master
34.69s

optimize-tests = true, patched
28.79s
```

Effects:

- faster UI tests
- llvm asserts get exercised less on build-pass tests
- the difference between opt and nopt builds shrinks a bit
- aux libs don't get optimized since they don't have a pass mode and almost never have explicit compile flags