Commit Graph

171939 Commits

Author SHA1 Message Date
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
Joshua Nelson
75dfd5e1c1 Fix caching bug in download-rustc = true
When moving this to rustbuild, I introduced a bug: if you had the file already downloaded, but
deleted the sysroot for whatever reason, rustbuil would fail to unpack the cached tarball.

This only affects people if they have a cached tarball, which is probably why we haven't seen an issue yet -
wiping `build/cache` would work around the issue, or just not deleting `build/$TARGET/stage2`.
2022-07-01 23:47:48 -05: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
Guillaume Gomez
bda659e873
Rollup merge of #98460 - GuillaumeGomez:css-simplification, r=jsha
Use CSS variables to handle theming

This is the start for our simplification of theming. Considering how big the diff quickly becomes, I think it's better to do it in multiple parts.

(The 3 first commits come from https://github.com/rust-lang/rust/pull/98297 so once it's merged, they'll disappear).

Normally they shouldn't be any UI changes. You can check it [here](https://rustdoc.crud.net/imperio/css-simplification/doc/foo/index.html).

cc `@notriddle`
r? `@jsha`
2022-07-01 23:39:08 +02:00
Guillaume Gomez
01aa10c2ff
Rollup merge of #98418 - topjohnwu:macos-dylib, r=jyn514
Allow macOS to build LLVM as shared library

Inspired by how [homebrew](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb) builds and distributes llvm, here we manually create a symlink with a versioned dylib path to make `llvm-config` work properly. Note, the resulting `rustc` executable and `librustc_driver-<hash>.dylib` still links to the un-versioned `libLLVM.dylib` as expected when distributed in the final output. I have confirmed this by checking `otool -L` on both binaries.

After the change, enabling `llvm.link-shared` and `llvm.thin-lto` will be possible on macOS.
2022-07-01 23:39:07 +02:00
Guillaume Gomez
194764fdc0
Rollup merge of #97249 - GuillaumeGomez:details-summary-fixes, r=notriddle
`<details>`/`<summary>` UI fixes

With images it's easier to understand:

![Screenshot from 2022-05-21 14-10-42](https://user-images.githubusercontent.com/3050060/169653038-9c58de67-589a-4986-a8ff-dbdddaf136a4.png)
![Screenshot from 2022-05-21 14-08-49](https://user-images.githubusercontent.com/3050060/169653042-56e87258-13fe-4f80-9858-4e15c318c3fb.png)

The headings in `<summary>` should not have bottom border so I removed it as well alongside the other fixes.

r? `@jsha`
2022-07-01 23:39:07 +02:00
Michael Howell
83f22885ae 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.
2022-07-01 14:33:34 -07:00
bors
46b8c23f3e Auto merge of #93967 - cjgillot:short-struct-span, r=petrochenkov
Shorten def_span for more items.

The `def_span` query only returns the signature span for functions.
Struct/enum/union definitions can also have a very long body.
This PR shortens the associated span.
2022-07-01 20:14:34 +00:00
Michael Howell
1f621fba2d rustdoc cleanup: remove unused function 2022-07-01 13:03:05 -07:00
Michael Howell
2852443f48 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.
2022-07-01 12:01:36 -07:00
Michael Goulet
6711313f76 Move Sized check before first error is created 2022-07-01 17:38:34 +00:00
Michael Goulet
12ab6bfafd Don't point at Self type if we can't find an infer variable in ambiguous trait predicate 2022-07-01 17:38:34 +00:00