Commit graph

171760 commits

Author SHA1 Message Date
Matthias Krüger
f236b6853a
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`
2022-07-04 06:08:09 +02:00
Matthias Krüger
47456ad4ef
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
2022-07-04 06:08:08 +02:00
Matthias Krüger
7352c7b6cd
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:
8aab472d52/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.)
2022-07-04 06:08:07 +02:00
bors
a5c6a48aee 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
2022-07-04 03:54:47 +00:00
Ralf Jung
d7edf66a5a move Box mess handling into general visitor 2022-07-03 22:55:25 -04:00
Ralf Jung
7fc77806d4 fix interpreter validity check on Box 2022-07-03 22:42:50 -04:00
Takayuki Maeda
15a86f7f2e add regression test for #86784 2022-07-04 11:07:13 +09:00
bors
d46c728bcd Auto merge of #98446 - nnethercote:derive-no-match-destructuring, r=scottmcm
Don't use match-destructuring for derived ops on structs.

r? `@scottmcm`
2022-07-04 01:06:54 +00:00
Nicholas Nethercote
ecc6e95ed4 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:#️⃣:Hasher>(&self, state: &mut __H) -> () {
    {
	let Self(ref __self_0_0) = *self;
	{ ::core:#️⃣: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.
2022-07-04 10:48:15 +10:00
Nicholas Nethercote
528343f93b Comment fixes.
Remove an out-of-date sentence, and fix a typo.
2022-07-04 10:48:15 +10:00
Nicholas Nethercote
18f8495677 Add an interesting case to the deriving-all-codegen.rs test. 2022-07-04 10:48:15 +10:00
bors
2557603f32 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
2022-07-03 22:20:10 +00:00
Ralf Jung
ce76d7312f
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```
2022-07-03 16:41:57 -04:00
Ralf Jung
87df0f1fbe
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
2022-07-03 16:41:56 -04:00
Ralf Jung
b0d831a486
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/
2022-07-03 16:41:54 -04:00
Ralf Jung
ff5e5ec71f
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.
2022-07-03 16:41:53 -04:00
Ralf Jung
ed92d88ff4
ignore rustdoc failures for out-of-tree tools 2022-07-03 22:30:31 +02:00
InfRandomness
45a69cc215
Add in_tree macro literal
Signed-off-by: InfRandomness <infrandomness@gmail.com>
2022-07-03 22:30:31 +02:00
InfRandomness
dbe77e856a
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>
2022-07-03 22:30:30 +02:00
bors
495b216696 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
2022-07-03 19:39:28 +00:00
Michael Howell
9938d56d8c
Remove redundant pseudo-class 2022-07-03 11:42:44 -07:00
Guillaume Gomez
69f7a6216e Add test for trailing whitespace in long declaration 2022-07-03 20:28:47 +02:00
Guillaume Gomez
ce9e834b6b Remove FIXME from rustdoc intra-doc test 2022-07-03 20:23:30 +02:00
KaDiWa
46ccde4408
clean up the borrowing in rustc_hir_pretty
a lot of the `&`s and `ref`s were redundant
2022-07-03 18:51:14 +02:00
bors
0e21a27075 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.
2022-07-03 16:29:09 +00:00
Ralf Jung
8955686e05 interpret: track place alignment together with the type, not the value 2022-07-03 10:22:37 -04:00
Ralf Jung
595dd976bd interpret: don't rely on ScalarPair for overflowed arithmetic 2022-07-03 09:56:31 -04:00
bors
b04bfb4aea 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> {}
```
2022-07-03 12:17:19 +00:00
bors
f99f9e48ed 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`
2022-07-03 09:36:37 +00:00
bors
ada8c80bed Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Bump bootstrap compiler

r? `@Mark-Simulacrum`
2022-07-03 06:55:50 +00:00
bors
8c52a83c45 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
2022-07-03 02:05:14 +00:00
Joshua Nelson
d0011b0c05 Allow building single crates for the compiler and standard library
- Add `Interned<Vec<String>>` and use it for tail args
- Refactor `cache.rs` not to need a separate impl for each internable type
2022-07-02 19:29:39 -05:00
Joshua Nelson
0566ade0b1 Use generics for interned types rather than copy-pasting impls
This makes it much simpler to add new interned types, rather than having
to add 4+ impl blocks for each type.
2022-07-02 19:29:39 -05:00
bors
5f98537eb7 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`
2022-07-02 23:38:08 +00:00
Michael Goulet
34063199d8 Fix rust-call ICE in mir-inliner 2022-07-02 21:40:33 +00:00
The 8472
f719239424 move optimize-tests flag handling from bootstrap to compiletest 2022-07-02 22:48:48 +02:00
bors
f2d93935ff 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
2022-07-02 19:46:01 +00:00
Ralf Jung
434ce766fb
Rollup merge of #98819 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/98779
r? `@ghost`
2022-07-02 15:21:21 -04:00
Ralf Jung
2dbbf8cf3c
Rollup merge of #98812 - gimbles:docs-template, r=Mark-Simulacrum
feat: Add a documentation problem issue template

Fixes #98722 :)
2022-07-02 15:21:20 -04:00
Ralf Jung
435733b5ba
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).
2022-07-02 15:21:19 -04:00
Ralf Jung
283430dfb0
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.
2022-07-02 15:21:18 -04:00
Ralf Jung
9bf7355446
Rollup merge of #98715 - matthiaskrgr:test_97047, r=Mark-Simulacrum
add ice test for #97047

Fixes #97047
2022-07-02 15:21:17 -04:00
Ralf Jung
27983d3498
Rollup merge of #98701 - TaKO8Ki:add-regression-test-for-50439, r=Mark-Simulacrum
Add regression test for #50439

closes #50439
2022-07-02 15:21:16 -04:00
Ralf Jung
8e26f43f83 update Miri 2022-07-02 15:15:56 -04:00
The 8472
125f33aa4c 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
2022-07-02 20:58:16 +02:00
David Tolnay
76c0429d86
Bump std::net::Incoming FusedIterator impl to Rust 1.64 2022-07-02 11:02:54 -07:00
Michael Howell
6e2c49f7ed rustdoc: add gui test case ensuring source sidebar doesn't spontaneously open 2022-07-02 10:41:46 -07:00
Ralf Jung
0832d1d022
more use of format! variable capture
Co-authored-by: Joe ST <joe@fbstj.net>
2022-07-02 13:37:24 -04:00
bors
750d6f8545 Auto merge of #97585 - lqd:const-alloc-intern, r=RalfJung
CTFE interning: don't walk allocations that don't need it

The interning of const allocations visits the mplace looking for references to intern. Walking big aggregates like big static arrays can be costly, so we only do it if the allocation we're interning contains references or interior mutability.

Walking ZSTs was avoided before, and this optimization is now applied to cases where there are no references/relocations either.

---

While initially looking at this in the context of #93215, I've been testing with smaller allocations than the 16GB one in that issue, and with different init/uninit patterns (esp. via padding).

In that example, by default, `eval_to_allocation_raw` is the heaviest query followed by `incr_comp_serialize_result_cache`. So I'll show numbers when incremental compilation is disabled, to focus on the const allocations themselves at 95% of the compilation time, at bigger array sizes on these minimal examples like `static ARRAY: [u64; LEN] = [0; LEN];`.

That is a close construction to parts of the `ctfe-stress-test-5` benchmark, which has const allocations in the megabytes, while most crates usually have way smaller ones. This PR will have the most impact in these situations, as the walk during the interning starts to dominate the runtime.

Unicode crates (some of which are present in our benchmarks) like `ucd`, `encoding_rs`, etc come to mind as having bigger than usual allocations as well, because of big tables of code points (in the hundreds of KB, so still an order of magnitude or 2 less than the stress test).

In a check build, for a single static array shown above, from 100 to 10^9 u64s (for lengths in powers of ten), the constant factors are lowered:

(log scales for easier comparisons)
![plot_log](https://user-images.githubusercontent.com/247183/171422958-16f1ea19-3ed4-4643-812c-1c7c60a97e19.png)

(linear scale for absolute diff at higher Ns)
![plot_linear](https://user-images.githubusercontent.com/247183/171401886-2a869a4d-5cd5-47d3-9a5f-8ce34b7a6917.png)

For one of the alternatives of that issue
```rust
const ROWS: usize = 100_000;
const COLS: usize = 10_000;

static TWODARRAY: [[u128; COLS]; ROWS] = [[0; COLS]; ROWS];
```

we can see a similar reduction of around 3x (from 38s to 12s or so).

For the same size, the slowest case IIRC is when there are uninitialized bytes e.g. via padding

```rust
const ROWS: usize = 100_000;
const COLS: usize = 10_000;

static TWODARRAY: [[(u64, u8); COLS]; ROWS] = [[(0, 0); COLS]; ROWS];
```
then interning/walking does not dominate anymore (but means there is likely still some interesting work left to do here).

Compile times in this case rise up quite a bit, and avoiding interning walks has less impact: around 23%, from 730s on master to 568s with this PR.
2022-07-02 17:05:13 +00:00
Michael Howell
e710ac12fa rustdoc: add test case for source sidebar spacing 2022-07-02 09:42:49 -07:00