Commit Graph

134880 Commits

Author SHA1 Message Date
Guillaume Gomez
bfe49a0aa3
Rollup merge of #79796 - GuillaumeGomez:hide-associated-const-when-collapsing, r=jyn514
Hide associated constants too when collapsing implementation

Fixes #71849.

r? `@jyn514`
2020-12-15 16:43:21 +01:00
Guillaume Gomez
275599daa5
Rollup merge of #79379 - GuillaumeGomez:no-js-not-hidden, r=Nemo157
Show hidden elements by default when JS is disabled

Fixes  #79301.

A lot of things are hidden by default which shouldn't when JS is disabled. This PR fixes it.

Before:

![Screenshot from 2020-11-24 14-10-16](https://user-images.githubusercontent.com/3050060/100099361-a16d5580-2e5f-11eb-891b-a4c005aeb1d0.png)

After:

![after](https://user-images.githubusercontent.com/3050060/100099382-a6caa000-2e5f-11eb-8190-14f330aff9a2.png)

r? `@jyn514`
2020-12-15 16:43:13 +01:00
bors
99baddb57c Auto merge of #78068 - RalfJung:union-safe-assign, r=nikomatsakis
consider assignments of union field of ManuallyDrop type safe

Assigning to `Copy` union fields is safe because that assignment will never drop anything. However, with https://github.com/rust-lang/rust/pull/77547, unions may also have `ManuallyDrop` fields, and their assignments are currently still unsafe. That seems unnecessary though, as assigning `ManuallyDrop` does not drop anything either, and is thus safe even for union fields.

I assume this will at least require FCP.
2020-12-15 11:31:03 +00:00
bors
e99a89c7c0 Auto merge of #73210 - wesleywiser:consts_in_debuginfo, r=oli-obk
[mir-opt] Allow debuginfo to be generated for a constant or a Place

Prior to this commit, debuginfo was always generated by mapping a name
to a Place. This has the side-effect that `SimplifyLocals` cannot remove
locals that are only used for debuginfo because their other uses have
been const-propagated.

To allow these locals to be removed, we now allow debuginfo to point to
a constant value. The `ConstProp` pass detects when debuginfo points to
a local with a known constant value and replaces it with the value. This
allows the later `SimplifyLocals` pass to remove the local.
2020-12-15 08:46:00 +00:00
bors
e261649593 Auto merge of #78682 - glandium:issue78471, r=lcnr
Do not inline finish_grow

Fixes #78471.

Looking at libgkrust.a in Firefox, the sizes for the `gkrust.*.o` file is:
- 18584816 (text) 582418 (data) with unmodified master
- 17937659 (text) 582554 (data) with #72227 reverted
- 17968228 (text) 582858 (data) with `#[inline(never)]` on `grow_amortized` and `grow_exact`, but that has some performance consequences
- 17927760 (text) 582322 (data) with this change

So in terms of size, at least in the case of Firefox, this patch more than undoes the regression. I don't think it should affect performance, but we'll see.
2020-12-15 06:32:10 +00:00
bors
e1cce06e4f Auto merge of #77700 - bugadani:rustdoc-link-cache, r=jyn514
Rustdoc: Cache resolved links in current module

A step towards #77681
2020-12-15 04:06:51 +00:00
bors
5d77fc8d0d Auto merge of #79922 - tmiasko:lower-discriminant, r=nagisa
Lower `discriminant_value` intrinsic

This allows const propagation to evaluate comparisons involving
field-less enums using derived implementations of `PartialEq` (after
inlining `eq`).
2020-12-15 01:56:25 +00:00
Wesley Wiser
0b18ed833c Disable the constant debuginfo promotion pass by default
It doesn't work correctly on *-pc-windows-gnu
2020-12-14 19:56:10 -05:00
bors
8b3ee82eb6 Auto merge of #79938 - tmiasko:stdarch, r=Amanieu
Update stdarch submodule

Changes included:

* Use a bootstrap guard for modules with new target features
* Avoid calling intrinsics with invalid const arguments
* Avx512bw
* Avx512cd
* Add AVX512BITALG
* Add GFNI Intrinsics
* Add AVX512VPOPCNTDQ Intrinsics
* Add VPCLMULQDQ Intrinsics
* Avx512bw
* Reimplement `_xgetbv` with LLVM intrinsics
* Avx512bw
* Add reamained vmax and vmin via auto-generated code
* Add VAES intrinsics

Fixes #56483.
2020-12-14 22:16:47 +00:00
bors
fa41639427 Auto merge of #77618 - fusion-engineering-forks:windows-parker, r=Amanieu
Add fast futex-based thread parker for Windows.

This adds a fast futex-based thread parker for Windows. It either uses WaitOnAddress+WakeByAddressSingle or NT Keyed Events (NtWaitForKeyedEvent+NtReleaseKeyedEvent), depending on which is available. Together, this makes this thread parker work for Windows XP and up. Before this change, park()/unpark() did not work on Windows XP: it needs condition variables, which only exist since Windows Vista.

---

Unfortunately, NT Keyed Events are an undocumented Windows API. However:
- This API is relatively simple with obvious behaviour, and there are several (unofficial) articles documenting the details. [1]
- parking_lot has been using this API for years (on Windows versions before Windows 8). [2] Many big projects extensively use parking_lot, such as servo and the Rust compiler itself.
- It is the underlying API used by Windows SRW locks and Windows critical sections. [3] [4]
- The source code of the implementations of Wine, ReactOs, and Windows XP are available and match the expected behaviour.
- The main risk with an undocumented API is that it might change in the future. But since we only use it for older versions of Windows, that's not a problem.
- Even if these functions do not block or wake as we expect (which is unlikely, see all previous points), this implementation would still be memory safe. The NT Keyed Events API is only used to sleep/block in the right place.

[1]\: http://www.locklessinc.com/articles/keyed_events/
[2]\: https://github.com/Amanieu/parking_lot/commit/43abbc964e
[3]\: https://docs.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c
[4]\: Windows Internals, Part 1, ISBN 9780735671300

---

The choice of fallback API is inspired by parking_lot(_core), but the implementation of this thread parker is different. While parking_lot has no use for a fast path (park() directly returning if unpark() was already called), this implementation has a fast path that returns without even checking which waiting/waking API to use, as the same atomic variable with compatible states is used in all cases.
2020-12-14 16:41:14 +00:00
bors
1f7762b4fc Auto merge of #80024 - GuillaumeGomez:rollup-rqd46ko, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #79918 (doc(array,vec): add notes about side effects when empty-initializing)
 - #79936 (Fix item name display on mobile)
 - #80013 (Refactor test_lang_string_parse to make it clearer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-14 13:45:38 +00:00
Guillaume Gomez
2169094ab8
Rollup merge of #80013 - poliorcetics:rustdoc-test-refactor, r=jyn514
Refactor test_lang_string_parse to make it clearer

Follows https://github.com/rust-lang/rust/pull/79454#discussion_r540190949

A small PR made to refactor a test in rustdoc that was becoming unwieldy.

``@rustbot`` label T-rustdoc
r? ``@jyn514``
2020-12-14 14:43:47 +01:00
Guillaume Gomez
63e86a7f72
Rollup merge of #79936 - GuillaumeGomez:mobile-fix-item-name, r=Nemo157,jyn514
Fix item name display on mobile

Fixes https://github.com/rust-lang/docs.rs/issues/1200

![Screenshot_20201211-200931](https://user-images.githubusercontent.com/3050060/101944457-0c06eb00-3bed-11eb-8f63-a4d4fd3cbb56.jpg)
![Screenshot_20201211-195846](https://user-images.githubusercontent.com/3050060/101944459-0d381800-3bed-11eb-91ff-815a2af7ca72.jpg)

cc `@jyn514`

r? `@Nemo157`
2020-12-14 14:43:45 +01:00
Guillaume Gomez
5d8b2a5bf1
Rollup merge of #79918 - woodruffw-forks:ww/doc-initializer-side-effects, r=dtolnay
doc(array,vec): add notes about side effects when empty-initializing

Copying some context from a conversation in the Rust discord:

* Both `vec![T; 0]` and `[T; 0]` are syntactically valid, and produce empty containers of their respective types

* Both *also* have side effects:

```rust
fn side_effect() -> String {
    println!("side effect!");

    "foo".into()
}

fn main() {
    println!("before!");

    let x = vec![side_effect(); 0];

    let y = [side_effect(); 0];

    println!("{:?}, {:?}", x, y);
}
```

produces:

```
before!
side effect!
side effect!
[], []
```

This PR just adds two small notes to each's documentation, warning users that side effects can occur.

I've also submitted a clippy proposal: https://github.com/rust-lang/rust-clippy/issues/6439
2020-12-14 14:43:44 +01:00
Dániel Buga
fa64c272c8 Add test case for Self:: links 2020-12-14 11:00:54 +01:00
Dániel Buga
cc31b992b1 Review suggestions 2020-12-14 11:00:53 +01:00
Dániel Buga
850437b6f9 Cache link resolution results in current module
Co-authored-by: Joshua Nelson <jyn514@gmail.com>
2020-12-14 11:00:53 +01:00
bors
3c45bff23d Auto merge of #79959 - JohnTitor:tidy-entries, r=petrochenkov
Check the number of entries in UI test on tidy

This helps #73494 to be resolved.

r? `@petrochenkov`
2020-12-14 09:25:00 +00:00
bors
331e74014a Auto merge of #79944 - sivadeilra:syms_proc_macro_testing, r=petrochenkov
Improve error handling in `symbols` proc-macro

This improves how the `symbols` proc-macro handles errors.
If it finds an error in its input, the macro does not panic.
Instead, it still produces an output token stream. That token
stream will contain `compile_error!(...)` macro invocations.
This will still cause compilation to fail (which is what we want),
but it will prevent meaningless errors caused by the output not
containing symbols that the macro normally generates.

This solves a small (but annoying) problem. When you're editing
rustc_span/src/symbol.rs, and you get something wrong (dup
symbol name, misordered symbol), you want to get only the errors
that are relevant, not a burst of errors that are irrelevant.
This change also uses the correct Span when reporting errors,
so you get errors that point to the correct place in
rustc_span/src/symbol.rs where something is wrong.

This also adds several unit tests which test the `symbols` proc-macro.

This commit also makes it easy to run the `symbols` proc-macro
as an ordinary Cargo test. Just run `cargo test`. This makes it
easier to do development on the macro itself, such as running it
under a debugger.

This commit also uses the `Punctuated` type in `syn` for parsing
comma-separated lists, rather than doing it manually.

The output of the macro is not changed at all by this commit,
so rustc should be completely unchanged. This just improves
quality of life during development.
2020-12-14 07:03:52 +00:00
Yuki Okushi
adda964bb5 Check the number of entries in UI test 2020-12-14 09:59:12 +09:00
bors
7feab000b2 Auto merge of #80005 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
BTreeMap: declare clear_parent_link directly on the root it needs

r? `@Mark-Simulacrum`
2020-12-13 22:13:02 +00:00
Arlie Davis
1a5b9b037e ./x.py fmt 2020-12-13 13:36:01 -08:00
bors
803c60218f Auto merge of #79978 - Aaron1011:fix/capture-broken-token, r=petrochenkov
Properly capture trailing 'unglued' token

If we try to capture the `Vec<u8>` in `Option<Vec<u8>>`, we'll
need to capture a `>` token which was 'unglued' from a `>>` token.
The processing of unglueing a token for parsing purposes bypasses the
usual capturing infrastructure, so we currently lose the trailing `>`.
As a result, we fall back to the reparsed `TokenStream`, causing us to
lose spans.

This commit makes token capturing keep track of a trailing 'unglued'
token. Note that we don't need to care about unglueing except at the end
of the captured tokens - if we capture both the first and second unglued
tokens, then we'll end up capturing the full 'glued' token, which
already works correctly.
2020-12-13 19:31:06 +00:00
bors
69ff39ee32 Auto merge of #79987 - ssomers:btree_cleanup_4, r=Mark-Simulacrum
BTreeMap: detect bulk_steal's count-1 underflow in release builds too

r? `@Mark-Simulacrum`
2020-12-13 17:09:41 +00:00
Alexis Bourget
ec0f1d70c9 Refactor test_lang_string_parse to make it clearer 2020-12-13 17:47:46 +01:00
bors
cbab347e68 Auto merge of #79376 - ssomers:btree_choose_parent_kv, r=Mark-Simulacrum
BTreeMap: clarify comments and panics around choose_parent_kv

Fixes a lie in recent code: `unreachable!("empty non-root node")` should shout "empty internal node", but it might as well be good and keep quiet

r? `@Mark-Simulacrum`
2020-12-13 14:42:37 +00:00
bors
057937bdda Auto merge of #79668 - coolreader18:recover-const-impl, r=petrochenkov
Recover on `const impl<> X for Y`

`@leonardo-m` mentioned that `const impl Foo for Bar` could be recovered from in #79287.

I'm not sure about the error strings as they are, I think it should probably be something like the error that `expected_one_of_not_found` makes + the suggestion to flip the keywords, but I'm not sure how exactly to do that. Also, I decided not to try to handle `const unsafe impl` or `unsafe const impl` cause I figured that `unsafe impl const` would be pretty rare anyway (if it's even valid?), and it wouldn't be worth making the code more messy.
2020-12-13 10:52:29 +00:00
Stein Somers
bdc6adfb3b BTreeMap: declare clear_parent_link directly on the root it needs 2020-12-13 11:13:54 +01:00
bors
d149b6579f Auto merge of #79956 - camelid:variant-field-vis, r=petrochenkov
Resolve enum field visibility correctly

Fixes #79593. 🎉

Previously, this code treated enum fields' visibility as if they were
struct fields. However, that's not correct because the visibility of a
struct field with `ast::VisibilityKind::Inherited` is private to the
module it's defined in, whereas the visibility of an *enum* field with
`ast::VisibilityKind::Inherited` is the visibility of the enum it
belongs to.
2020-12-13 08:40:07 +00:00
bors
12813159a9 Auto merge of #79994 - JohnTitor:rollup-43wl2uj, r=JohnTitor
Rollup of 12 pull requests

Successful merges:

 - #79360 (std::iter: document iteration over `&T` and `&mut T`)
 - #79398 (Link loop/for keyword)
 - #79834 (Remove deprecated linked_list_extras methods.)
 - #79845 (Fix rustup support in default_build_triple for python3)
 - #79940 (fix more clippy::complexity findings)
 - #79942 (Add post-init hook for static memory for miri.)
 - #79954 (Fix building compiler docs with stage 0)
 - #79963 (Fix typo in `DebruijnIndex` documentation)
 - #79970 (Misc rustbuild improvements when the LLVM backend isn't used)
 - #79973 (rustdoc light theme: Fix CSS for selected buttons)
 - #79984 (Remove an unused dependency that made `rustdoc` crash)
 - #79985 (Fixes submit event of the search input)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-13 04:02:26 +00:00
Yuki Okushi
3213089c02
Rollup merge of #79985 - GuillaumeGomez:fix-submit-event, r=jyn514
Fixes submit event of the search input

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

It's a very funny corner case:

In HTML, when a button follows an input (in a `form`), if the enter keep is pressed on the input, instead of sending the submit event to the input, it'll create a click event on the button following it, which in this case made the help popup show up whenever "enter" was pressed.

cc `@camelid`

r? `@jyn514`
2020-12-13 11:05:48 +09:00
Yuki Okushi
424e44af00
Rollup merge of #79984 - Nadrieril:remove-unused-dep, r=jyn514
Remove an unused dependency that made `rustdoc` crash

Whilst struggling with https://github.com/rust-lang/rust/issues/79980 I discovered that this dependency was unused, and that made rustdoc crash. This PR removes it.
2020-12-13 11:05:47 +09:00
Yuki Okushi
5115bbf1dd
Rollup merge of #79973 - camelid:rustdoc-search-tab-color, r=GuillaumeGomez
rustdoc light theme: Fix CSS for selected buttons

Fixes #79961.

The background was dark before, which made the text impossible to read.
Now the button doesn't override the background, and the only thing it
does is add a light-blue top border.

Ultimately, the search results tabs now look very similar to how they
used to look.

r? `@GuillaumeGomez`
2020-12-13 11:05:45 +09:00
Yuki Okushi
d90084c226
Rollup merge of #79970 - bjorn3:no_unnecessary_llvm_checkout, r=Mark-Simulacrum
Misc rustbuild improvements when the LLVM backend isn't used

* Don't checkout llvm-project
* Don't require cmake and ninja

Fixes #78564
2020-12-13 11:05:43 +09:00
Yuki Okushi
e4a663cbaa
Rollup merge of #79963 - LeSeulArtichaut:debruijn-typo, r=Dylan-DPC
Fix typo in `DebruijnIndex` documentation

Suggested in https://github.com/rust-lang/rust/pull/79169#discussion_r541564114.
r? ``@lqd``
2020-12-13 11:05:41 +09:00
Yuki Okushi
54119d4436
Rollup merge of #79954 - jyn514:normalize-oops, r=Mark-Simulacrum
Fix building compiler docs with stage 0

This regressed in https://github.com/rust-lang/rust/pull/79525 (see https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Can't.20document.20single.20crate).

r? `@Mark-Simulacrum`
2020-12-13 11:05:40 +09:00
Yuki Okushi
2b43980ef4
Rollup merge of #79942 - JCTyblaidd:static-mem-init, r=RalfJung
Add post-init hook for static memory for miri.

Adds a post-initialization hook to treat memory initialized using the interpreter as if it was initialized in a static context.

See: https://github.com/rust-lang/miri/pull/1644 & https://github.com/rust-lang/miri/issues/1643
2020-12-13 11:05:38 +09:00
Yuki Okushi
1b81f08d4c
Rollup merge of #79940 - matthiaskrgr:cl15ppy, r=Dylan-DPC
fix more clippy::complexity findings

fix clippy::unnecessary_filter_map
use if let Some(x) = ..  instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn)
fix clippy::{needless_bool, manual_unwrap_or}
don't clone types that are copy (clippy::clone_on_copy)
don't convert types into identical types with .into() (clippy::useless_conversion)
use strip_prefix over slicing (clippy::manual_strip)

r? ``@Dylan-DPC``
2020-12-13 11:05:36 +09:00
Yuki Okushi
f80c6aeb87
Rollup merge of #79845 - jyn514:python3, r=Mark-Simulacrum
Fix rustup support in default_build_triple for python3

bootstrap completely ignores all errors when detecting a rustup version,
so this wasn't noticed before.

Fixes the following error:

```
rustup not detected: a bytes-like object is required, not 'str'
falling back to auto-detect
```

This also takes the opportunity to only call rustup and other external
commands only once during startup.

Follow-up to https://github.com/rust-lang/rust/pull/78513.
2020-12-13 11:05:35 +09:00
Yuki Okushi
89051d81b9
Rollup merge of #79834 - m-ou-se:bye-linked-list-extras, r=Mark-Simulacrum
Remove deprecated linked_list_extras methods.

https://github.com/rust-lang/rust/issues/27794#issuecomment-667524201:
> I'd say give it about 2 weeks then remove them.

It's been 18 weeks. Time to remove them. :)

Closes #27794.
2020-12-13 11:05:32 +09:00
Yuki Okushi
d559bb6707
Rollup merge of #79398 - pickfire:keyword, r=Dylan-DPC
Link loop/for keyword

Even though the reference already have all of these, I am just adding related keywords in the see also to let others easily click on the related keyword.
2020-12-13 11:05:30 +09:00
Yuki Okushi
1698773263
Rollup merge of #79360 - wchargin:wchargin-doc-iter-by-reference, r=m-ou-se
std::iter: document iteration over `&T` and `&mut T`

A colleague of mine is new to Rust, and mentioned that it was “slightly
confusing” to figure out what `&mut` does in iterating over `&mut foo`:

```rust
for value in &mut self.my_vec {
    // ...
}
```

My colleague had read the `std::iter` docs and not found the answer
there. There is a brief section at the top about “the three forms of
iteration”, which mentions `iter_mut`, but it doesn’t cover the purpose
of `&mut coll` for a collection `coll`. This patch adds an explanatory
section to the docs. I opted to create a new section so that it can
appear after the note that `impl<I: Iterator> IntoIterator for I`, and
it’s nice for the existing “three forms of iteration” to appear near the
top.

Test Plan:
Ran `./x.py doc library/core`, and the result looked good, including
links. Manually copy-pasted the two doctests into the playground and ran
them.

wchargin-branch: doc-iter-by-reference
2020-12-13 11:05:22 +09:00
bors
dd11f45a68 Auto merge of #79988 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
BTreeMap: capture a recurring use pattern as replace_kv

r? `@Mark-Simulacrum`
2020-12-13 01:28:59 +00:00
Stein Somers
0ae4c95eff BTreeMap: capture a recurring use pattern as replace_kv 2020-12-13 00:44:00 +01:00
Stein Somers
ad75a96b34 BTreeMap: detect bulk_steal's count-1 underflow in release builds too 2020-12-13 00:37:30 +01:00
Arlie Davis
201a833eef Improve error handling in symbols proc-macro
This improves how the `symbols` proc-macro handles errors.
If it finds an error in its input, the macro does not panic.
Instead, it still produces an output token stream. That token
stream will contain `compile_error!(...)` macro invocations.
This will still cause compilation to fail (which is what we want),
but it will prevent meaningless errors caused by the output not
containing symbols that the macro normally generates.

This solves a small (but annoying) problem. When you're editing
rustc_span/src/symbol.rs, and you get something wrong (dup
symbol name, misordered symbol), you want to get only the errors
that are relevant, not a burst of errors that are irrelevant.
This change also uses the correct Span when reporting errors,
so you get errors that point to the correct place in
rustc_span/src/symbol.rs where something is wrong.

This also adds several unit tests which test the `symbols` proc-macro.

This commit also makes it easy to run the `symbols` proc-macro
as an ordinary Cargo test. Just run `cargo test`. This makes it
easier to do development on the macro itself, such as running it
under a debugger.

This commit also uses the `Punctuated` type in `syn` for parsing
comma-separated lists, rather than doing it manually.

The output of the macro is not changed at all by this commit,
so rustc should be completely unchanged. This just improves
quality of life during development.
2020-12-12 15:29:12 -08:00
Guillaume Gomez
98118bbde4 Fixes submit event of the search input
In HTML, when a button follows an input, if the enter keep is pressed on the input, instead of sending the submit event to the input, it'll create a click event on the button following it, which in this case made the help popup show up whenever "enter" was pressed.
2020-12-13 00:25:06 +01:00
bors
f61e5cab76 Auto merge of #79976 - jyn514:assertion-failure, r=jyn514
Remove incorrect assert

Fixes an assertion failure when resolving `::std` (or any other crate that uses the `::` style, see https://github.com/rust-lang/rust/pull/79809/files#r541776478, https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Perf.20failing).

Unblocks https://github.com/rust-lang/rustc-perf/pull/806.

r? `@ghost` - this is a trivial fix and breaking rustc-perf so I'm going to approve it unilaterally. cc `@Mark-Simulacrum` `@Eric-Arellano`
2020-12-12 23:01:25 +00:00
Joshua Nelson
9df0348299 Fix building compiler docs with stage 0 2020-12-12 17:31:35 -05:00
Nadrieril
600efe7f10 Remove an unused dependency that made rustdoc crash 2020-12-12 22:13:03 +00:00