Commit Graph

171782 Commits

Author SHA1 Message Date
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
Michael Howell
26dccbf4cf rustdoc: add test case for background color of the sidebar toggle button 2022-07-02 08:45:52 -07:00
Michael Howell
a7c0c9f2bb rustdoc: add explanatory comment to width: 100% line 2022-07-02 08:41:46 -07:00
Michael Howell
c147c0daa3 rustdoc: make source sidebar toggle a real button
This fixes tab focus, so that you can open and close the sidebar
from keyboard.
2022-07-02 08:41:45 -07:00
Ralf Jung
d31cbb5150 make AllocRef APIs more consistent 2022-07-02 11:41:16 -04:00
Ralf Jung
c36572c11e add AllocRange Debug impl; remove redundant AllocId Display impl 2022-07-02 11:41:16 -04:00
Gimgim
de9b1da22a feat: Add a documentation problem issue template 2022-07-02 20:39:20 +05:30
bors
6a10920564 Auto merge of #97235 - nbdd0121:unwind, r=Amanieu
Fix FFI-unwind unsoundness with mixed panic mode

UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926).

To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy.

For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted.

In summary:
```rust
#![warn(ffi_unwind_calls)]

mod foo {
    #[no_mangle]
    pub extern "C-unwind" fn foo() {}
}

extern "C-unwind" {
    fn foo();
}

fn main() {
    // Call to Rust function is fine regardless ABI.
    foo::foo();
    // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`.
    unsafe { foo(); }
    //~^ WARNING call to foreign function with FFI-unwind ABI
    let ptr: extern "C-unwind" fn() = foo::foo;
    // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`.
    ptr();
    //~^ WARNING call to function pointer with FFI-unwind ABI
}
```

Fix #96926

`@rustbot` label: T-compiler F-c_unwind
2022-07-02 14:06:27 +00:00
bors
0075bb4fad Auto merge of #91743 - cjgillot:enable_mir_inlining_inline_all, r=oli-obk
Enable MIR inlining

Continuation of https://github.com/rust-lang/rust/pull/82280 by `@wesleywiser.`

#82280 has shown nice compile time wins could be obtained by enabling MIR inlining.
Most of the issues in https://github.com/rust-lang/rust/issues/81567 are now fixed,
except the interaction with polymorphization which is worked around specifically.

I believe we can proceed with enabling MIR inlining in the near future
(preferably just after beta branching, in case we discover new issues).

Steps before merging:
- [x] figure out the interaction with polymorphization;
- [x] figure out how miri should deal with extern types;
- [x] silence the extra arithmetic overflow warnings;
- [x] remove the codegen fulfilment ICE;
- [x] remove the type normalization ICEs while compiling nalgebra;
- [ ] tweak the inlining threshold.
2022-07-02 11:24:17 +00:00
Guillaume Gomez
b17cf7a493 Remove unwanted trailing whitespaces for long declarations 2022-07-02 12:43:07 +02:00
bors
aedf78e56b Auto merge of #98802 - Dylan-DPC:rollup-u6mwx27, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98639 (Factor out `hir::Node::Binding`)
 - #98653 (Add regression test for #79494)
 - #98763 (bootstrap: illumos platform flags for split-debuginfo)
 - #98766 (cleanup mir visitor for `rustc::pass_by_value`)
 - #98783 (interpret: make a comment less scary)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-02 08:39:20 +00:00
Chris Denton
ee3e518291
Add #95469 to the release notes 2022-07-02 08:51:59 +01:00
Joshua Nelson
17da4e06f2 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
- Remove duplicate run-make test
2022-07-02 02:11:49 -05:00
Dylan DPC
7a4f33bec9
Rollup merge of #98783 - RalfJung:jumpscares, r=fee1-dead
interpret: make a comment less scary

This slipped past my review: "has no meaning" could be read as "is undefined behavior". That is certainly not what we mean so be more clear.
2022-07-02 12:23:42 +05:30
Dylan DPC
05aebf8f69
Rollup merge of #98766 - lcnr:mir-visit-pass_by_value, r=oli-obk
cleanup mir visitor for `rustc::pass_by_value`

by changing `& $($mutability)?` to `$(& $mutability)?`

I also did some formatting changes because I started doing them for the visit methods I changed and then couldn't get myself to stop xx, I hope that's still fairly easy to review.
2022-07-02 12:23:41 +05:30
Dylan DPC
5fe0997b54
Rollup merge of #98763 - citrus-it:illumos-split-debuginfo, r=Mark-Simulacrum
bootstrap: illumos platform flags for split-debuginfo

Bootstrap currently provides `-Zunstable-options` for platforms
when using split debuginfo - this commit adds it for the illumos
target too.
2022-07-02 12:23:40 +05:30
Dylan DPC
83dde88fbd
Rollup merge of #98653 - TaKO8Ki:add-regression-test-for-79494, r=Mark-Simulacrum
Add regression test for #79494

closes #79494
2022-07-02 12:23:39 +05:30
Dylan DPC
d287726aa0
Rollup merge of #98639 - camsteffen:no-node-binding, r=compiler-errors
Factor out `hir::Node::Binding`
2022-07-02 12:23:38 +05:30
bors
4118ad24d6 Auto merge of #98791 - cuviper:rogue-binary, r=compiler-errors
Remove the rogue ./suggest-blanket-impl-local-trait

This executable was added in #97488, presumably just a `git add` mistake.
2022-07-02 05:56:23 +00:00
Mark Rousskov
45b87fb75c Lint against executable files in the root directory
This avoids accidental introduction (such as in #97488).
2022-07-01 22:12:29 -04:00
Josh Stone
5f7aeb8f07 Remove the rogue ./suggest-blanket-impl-local-trait 2022-07-01 17:22:22 -07:00
Michael Goulet
a368830d10 Improve spans for specialization error 2022-07-01 23:56:15 +00:00
Michael Howell
b80979416d rustdoc: add test cases for :focus on sidebar details elements 2022-07-01 16:16:03 -07:00
bors
9a6fa4f118 Auto merge of #98781 - GuillaumeGomez:rollup-798kb8u, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #97249 (`<details>`/`<summary>` UI fixes)
 - #98418 (Allow macOS to build LLVM as shared library)
 - #98460 (Use CSS variables to handle theming)
 - #98497 (Improve some inference diagnostics)
 - #98708 (rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests)

Failed merges:

 - #98761 (more `need_type_info` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-01 22:55:22 +00:00
Michael Howell
180f83605a rustdoc: add spacing to the source view sidebar
https://user-images.githubusercontent.com/1593513/176974336-20cecdc3-1885-402a-a6d5-81a8dd03a45d.png
2022-07-01 15:29:47 -07:00
Mark Rousskov
d8bfae4f99 Adjust for rustfmt order change 2022-07-01 18:13:55 -04:00
Ralf Jung
65944ce522 interpret: make a comment less scary 2022-07-01 17:57:32 -04:00
Guillaume Gomez
00d68a7890
Rollup merge of #98708 - pinkforest:rustdoc-fix-98690, r=GuillaumeGomez
rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests

Closes #98690 for rustdoc panic

I changed this to do eprintln and orderly panic instead of unwrap doing unhandled panic

~/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc --test -Z unstable-options --persist-doctests /tmp/foobar main.rs
Couldn't create directory for doctest executables: Permission denied (os error 13)
2022-07-01 23:39:10 +02:00
Guillaume Gomez
b0935b1ddf
Rollup merge of #98497 - compiler-errors:span-inference-note, r=lcnr
Improve some inference diagnostics

- Properly point out point location where "type must be known at this point", or else omit the note if it's not associated with a useful span.
- Fix up some type ambiguity diagnostics, errors shouldn't say "cannot infer type for reference `&'a ()`" when the given type has no inference variables.
2022-07-01 23:39:09 +02:00