]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #79607 - DrMeepster:maybe_uninit_write_slice, r=m-ou-se
bors [Wed, 16 Dec 2020 06:26:51 +0000 (06:26 +0000)]
Auto merge of #79607 - DrMeepster:maybe_uninit_write_slice, r=m-ou-se

MaybeUninit::copy/clone_from_slice

This PR adds 2 new methods to MaybeUninit under the feature of `maybe_uninit_write_slice`: `copy_from_slice` and `clone_from_slice`.

These are useful for initializing uninitialized buffers (such as the one returned by `Vec::spare_capacity_mut` for example) with initialized data.

The methods behave similarly to the methods on slices, but the destination is uninitialized and they return the destination slice as an initialized slice.

3 years agoAuto merge of #80041 - jyn514:shrink-item, r=GuillaumeGomez
bors [Wed, 16 Dec 2020 03:35:08 +0000 (03:35 +0000)]
Auto merge of #80041 - jyn514:shrink-item, r=GuillaumeGomez

Get rid of `clean::Deprecation`

This brings the size of `item.deprecation` from 56 to 16 bytes. Helps with #79103 and https://github.com/rust-lang/rust/issues/76382, in the same vein as https://github.com/rust-lang/rust/pull/79957.

r? `@GuillaumeGomez`

3 years agoAuto merge of #78833 - CDirkx:parse_prefix, r=dtolnay
bors [Wed, 16 Dec 2020 00:47:50 +0000 (00:47 +0000)]
Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay

Refactor and fix `parse_prefix` on Windows

This PR is an extension of #78692 as well as a general refactor of `parse_prefix`:

**Fixes**:
There are two errors in the current implementation of `parse_prefix`:

Firstly, in the current implementation only `\` is recognized as a separator character in device namespace prefixes. This behavior is only correct for verbatim paths; `"\\.\C:/foo"` should be parsed as `"C:"` instead of `"C:/foo"`.

Secondly, the current implementation only handles single separator characters. In non-verbatim paths a series of separator characters should be recognized as a single boundary, e.g. the UNC path `"\\localhost\\\\\\C$\foo"` should be parsed as `"\\localhost\\\\\\C$"` and then `UNC(server: "localhost", share: "C$")`, but currently it is not parsed at all, because it starts being parsed as `\\localhost\` and then has an invalid empty share location.

Paths like `"\\.\C:/foo"` and `"\\localhost\\\\\\C$\foo"` are valid on Windows, they are equivalent to just `"C:\foo"`.

**Refactoring**:
All uses of `&[u8]` within `parse_prefix` are extracted to helper functions and`&OsStr` is used instead. This reduces the number of places unsafe is used:
- `get_first_two_components` is adapted to the more general `parse_next_component` and used in more places
- code for parsing drive prefixes is extracted to `parse_drive`

3 years agoAuto merge of #78399 - vn-ki:gsgdt-graphviz, r=oli-obk
bors [Tue, 15 Dec 2020 22:00:02 +0000 (22:00 +0000)]
Auto merge of #78399 - vn-ki:gsgdt-graphviz, r=oli-obk

make MIR graphviz generation use gsgdt

gsgdt [https://crates.io/crates/gsgdt] is a crate which provides an
interface for stringly typed graphs. It also provides generation of
graphviz dot format from said graph.

This is the first in a series of PRs on moving graphviz code out of rustc into normal crates and then implementating graph diffing on top of these crates.

r? `@oli-obk`

3 years agowrite_slice(_cloned)
DrMeepster [Tue, 1 Dec 2020 06:24:04 +0000 (22:24 -0800)]
write_slice(_cloned)

3 years agoAuto merge of #80044 - jyn514:smaller-name, r=GuillaumeGomez
bors [Tue, 15 Dec 2020 18:40:50 +0000 (18:40 +0000)]
Auto merge of #80044 - jyn514:smaller-name, r=GuillaumeGomez

[rustdoc] Switch to Symbol for item.name

This decreases the size of `Item` from 680 to 616 bytes. It also does a
lot less work since it no longer has to copy as much.

Helps with #79103.

r? `@GuillaumeGomez`

3 years agoAuto merge of #80055 - GuillaumeGomez:rollup-p09mweg, r=GuillaumeGomez
bors [Tue, 15 Dec 2020 15:58:46 +0000 (15:58 +0000)]
Auto merge of #80055 - GuillaumeGomez:rollup-p09mweg, r=GuillaumeGomez

Rollup of 6 pull requests

Successful merges:

 - #79379 (Show hidden elements by default when JS is disabled)
 - #79796 (Hide associated constants too when collapsing implementation)
 - #79958 (Fixes reported bugs in Rust Coverage)
 - #80008 (Fix `cargo-binutils` link)
 - #80016 (Use imports instead of rewriting the type signature of `RustcOptGroup::stable`)
 - #80025 (Replace some `println!` with `tidy_error!` to simplify)

Failed merges:

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

3 years agoRollup merge of #80025 - JohnTitor:tidy-error, r=Mark-Simulacrum
Guillaume Gomez [Tue, 15 Dec 2020 15:43:28 +0000 (16:43 +0100)]
Rollup merge of #80025 - JohnTitor:tidy-error, r=Mark-Simulacrum

Replace some `println!` with `tidy_error!` to simplify

3 years agoRollup merge of #80016 - jyn514:imports, r=GuillaumeGomez
Guillaume Gomez [Tue, 15 Dec 2020 15:43:26 +0000 (16:43 +0100)]
Rollup merge of #80016 - jyn514:imports, r=GuillaumeGomez

Use imports instead of rewriting the type signature of `RustcOptGroup::stable`

This was an adventure; see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/'higher.20ranked.20subtype.20error'

r? `@GuillaumeGomez`

3 years agoRollup merge of #80008 - EFanZh:patch-1, r=GuillaumeGomez
Guillaume Gomez [Tue, 15 Dec 2020 15:43:24 +0000 (16:43 +0100)]
Rollup merge of #80008 - EFanZh:patch-1, r=GuillaumeGomez

Fix `cargo-binutils` link

3 years agoRollup merge of #79958 - richkadel:llvm-coverage-counters-2.2.0, r=tmandry
Guillaume Gomez [Tue, 15 Dec 2020 15:43:23 +0000 (16:43 +0100)]
Rollup merge of #79958 - richkadel:llvm-coverage-counters-2.2.0, r=tmandry

Fixes reported bugs in Rust Coverage

Fixes: #79569
Fixes: #79566
Fixes: #79565
For the first issue (#79569), I got hit a `debug_assert!()` before
encountering the reported error message (because I have `debug = true`
enabled in my config.toml).

The assertion showed me that some `SwitchInt`s can have more than one
target pointing to the same `BasicBlock`.

I had thought that was invalid, but since it seems to be possible, I'm
allowing this now.

I added a new test for this.

----

In the last two cases above, both tests (intentionally) fail to compile,
but the `InstrumentCoverage` pass is invoked anyway.

The MIR starts with an `Unreachable` `BasicBlock`, which I hadn't
encountered before. (I had assumed the `InstrumentCoverage` pass
would only be invoked with MIRs from successful compilations.)

I don't have test infrastructure set up to test coverage on files that
fail to compile, so I didn't add a new test.

r? `@tmandry`
FYI: `@wesleywiser`

3 years agoRollup merge of #79796 - GuillaumeGomez:hide-associated-const-when-collapsing, r...
Guillaume Gomez [Tue, 15 Dec 2020 15:43:21 +0000 (16:43 +0100)]
Rollup merge of #79796 - GuillaumeGomez:hide-associated-const-when-collapsing, r=jyn514

Hide associated constants too when collapsing implementation

Fixes #71849.

r? `@jyn514`

3 years agoRollup merge of #79379 - GuillaumeGomez:no-js-not-hidden, r=Nemo157
Guillaume Gomez [Tue, 15 Dec 2020 15:43:13 +0000 (16:43 +0100)]
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`

3 years agoAuto merge of #78068 - RalfJung:union-safe-assign, r=nikomatsakis
bors [Tue, 15 Dec 2020 11:31:03 +0000 (11:31 +0000)]
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.

3 years agoAuto merge of #73210 - wesleywiser:consts_in_debuginfo, r=oli-obk
bors [Tue, 15 Dec 2020 08:46:00 +0000 (08:46 +0000)]
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.

3 years agoAuto merge of #78682 - glandium:issue78471, r=lcnr
bors [Tue, 15 Dec 2020 06:32:10 +0000 (06:32 +0000)]
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.

3 years agoAuto merge of #77700 - bugadani:rustdoc-link-cache, r=jyn514
bors [Tue, 15 Dec 2020 04:06:51 +0000 (04:06 +0000)]
Auto merge of #77700 - bugadani:rustdoc-link-cache, r=jyn514

Rustdoc: Cache resolved links in current module

A step towards #77681

3 years agoSwitch to Symbol for item.name
Joshua Nelson [Tue, 15 Dec 2020 00:30:36 +0000 (19:30 -0500)]
Switch to Symbol for item.name

This decreases the size of `Item` from 680 to 616 bytes. It also does a
lot less work since it no longer has to copy as much.

3 years agoGet rid of `clean::Deprecation`
Joshua Nelson [Mon, 14 Dec 2020 23:44:59 +0000 (18:44 -0500)]
Get rid of `clean::Deprecation`

This brings the size of `item.deprecation` from 56 to 16 bytes.

3 years agoRemove unnecessary unwrap_or
Joshua Nelson [Tue, 15 Dec 2020 00:06:41 +0000 (19:06 -0500)]
Remove unnecessary unwrap_or

This was always questionable, and removing it doesn't fail any tests, so
I think this was not affecting the behavior. It dates all the way back
to the very first commit of rustdoc: 268f3f0ff5d80544ca21d565354eae6d3e29fb91

3 years agoAuto merge of #79922 - tmiasko:lower-discriminant, r=nagisa
bors [Tue, 15 Dec 2020 01:56:25 +0000 (01:56 +0000)]
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`).

3 years agoConvenience funcs for `some_option.unwrap_or(...)`
Rich Kadel [Mon, 14 Dec 2020 21:12:15 +0000 (13:12 -0800)]
Convenience funcs for `some_option.unwrap_or(...)`

This ensures consistent handling of default values for options that are
None if not specified on the command line.

3 years agoDisable the constant debuginfo promotion pass by default
Wesley Wiser [Mon, 14 Dec 2020 12:35:03 +0000 (07:35 -0500)]
Disable the constant debuginfo promotion pass by default

It doesn't work correctly on *-pc-windows-gnu

3 years agoAuto merge of #79938 - tmiasko:stdarch, r=Amanieu
bors [Mon, 14 Dec 2020 22:16:47 +0000 (22:16 +0000)]
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.

3 years agoImprove warnings on incompatible options involving -Zinstrument-coverage
Rich Kadel [Mon, 14 Dec 2020 08:25:29 +0000 (00:25 -0800)]
Improve warnings on incompatible options involving -Zinstrument-coverage

Adds checks for:

* `no_core` attribute
* explicitly-enabled `legacy` symbol mangling
* mir_opt_level > 1 (which enables inlining)

I removed code from the `Inline` MIR pass that forcibly disabled
inlining if `-Zinstrument-coverage` was set. The default `mir_opt_level`
does not enable inlining anyway. But if the level is explicitly set and
is greater than 1, I issue a warning.

The new warnings show up in tests, which is much better for diagnosing
potential option conflicts in these cases.

3 years agoAuto merge of #77618 - fusion-engineering-forks:windows-parker, r=Amanieu
bors [Mon, 14 Dec 2020 16:41:14 +0000 (16:41 +0000)]
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.

3 years agoReplace some `println!` with `tidy_error!` to simplify
Yuki Okushi [Mon, 14 Dec 2020 14:10:15 +0000 (23:10 +0900)]
Replace some `println!` with `tidy_error!` to simplify

3 years agoAuto merge of #80024 - GuillaumeGomez:rollup-rqd46ko, r=GuillaumeGomez
bors [Mon, 14 Dec 2020 13:45:38 +0000 (13:45 +0000)]
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

3 years agoRollup merge of #80013 - poliorcetics:rustdoc-test-refactor, r=jyn514
Guillaume Gomez [Mon, 14 Dec 2020 13:43:47 +0000 (14:43 +0100)]
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``

3 years agoRollup merge of #79936 - GuillaumeGomez:mobile-fix-item-name, r=Nemo157,jyn514
Guillaume Gomez [Mon, 14 Dec 2020 13:43:45 +0000 (14:43 +0100)]
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`

3 years agoRollup merge of #79918 - woodruffw-forks:ww/doc-initializer-side-effects, r=dtolnay
Guillaume Gomez [Mon, 14 Dec 2020 13:43:44 +0000 (14:43 +0100)]
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

3 years agoAdd test case for Self:: links
Dániel Buga [Mon, 30 Nov 2020 22:17:11 +0000 (23:17 +0100)]
Add test case for Self:: links

3 years agoReview suggestions
Dániel Buga [Mon, 30 Nov 2020 22:16:50 +0000 (23:16 +0100)]
Review suggestions

3 years agoCache link resolution results in current module
Dániel Buga [Fri, 9 Oct 2020 08:27:14 +0000 (10:27 +0200)]
Cache link resolution results in current module

Co-authored-by: Joshua Nelson <jyn514@gmail.com>
3 years agoAuto merge of #79959 - JohnTitor:tidy-entries, r=petrochenkov
bors [Mon, 14 Dec 2020 09:25:00 +0000 (09:25 +0000)]
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`

3 years agoAuto merge of #79944 - sivadeilra:syms_proc_macro_testing, r=petrochenkov
bors [Mon, 14 Dec 2020 07:03:52 +0000 (07:03 +0000)]
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.

3 years agoCheck the number of entries in UI test
Yuki Okushi [Sat, 12 Dec 2020 06:15:06 +0000 (15:15 +0900)]
Check the number of entries in UI test

3 years agoAuto merge of #80005 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
bors [Sun, 13 Dec 2020 22:13:02 +0000 (22:13 +0000)]
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`

3 years ago./x.py fmt
Arlie Davis [Sun, 13 Dec 2020 21:36:01 +0000 (13:36 -0800)]
./x.py fmt

3 years agoUse imports instead of rewriting the type signature of `stable`
Joshua Nelson [Sun, 13 Dec 2020 20:13:41 +0000 (15:13 -0500)]
Use imports instead of rewriting the type signature of `stable`

This was an adventure; see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/'higher.20ranked.20subtype.20error'

3 years agoAuto merge of #79978 - Aaron1011:fix/capture-broken-token, r=petrochenkov
bors [Sun, 13 Dec 2020 19:31:06 +0000 (19:31 +0000)]
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.

3 years agoAuto merge of #79987 - ssomers:btree_cleanup_4, r=Mark-Simulacrum
bors [Sun, 13 Dec 2020 17:09:41 +0000 (17:09 +0000)]
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`

3 years agoRefactor test_lang_string_parse to make it clearer
Alexis Bourget [Sun, 13 Dec 2020 16:47:46 +0000 (17:47 +0100)]
Refactor test_lang_string_parse to make it clearer

3 years agoAuto merge of #79376 - ssomers:btree_choose_parent_kv, r=Mark-Simulacrum
bors [Sun, 13 Dec 2020 14:42:37 +0000 (14:42 +0000)]
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`

3 years agoFix `cargo-binutils` link
EFanZh [Sun, 13 Dec 2020 11:23:16 +0000 (19:23 +0800)]
Fix `cargo-binutils` link

3 years agoAuto merge of #79668 - coolreader18:recover-const-impl, r=petrochenkov
bors [Sun, 13 Dec 2020 10:52:29 +0000 (10:52 +0000)]
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.

3 years agoBTreeMap: declare clear_parent_link directly on the root it needs
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: declare clear_parent_link directly on the root it needs

3 years agoAuto merge of #79956 - camelid:variant-field-vis, r=petrochenkov
bors [Sun, 13 Dec 2020 08:40:07 +0000 (08:40 +0000)]
Auto merge of #79956 - camelid:variant-field-vis, r=petrochenkov

Resolve enum field visibility correctly

Fixes #79593. :tada:

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.

3 years agoAuto merge of #79994 - JohnTitor:rollup-43wl2uj, r=JohnTitor
bors [Sun, 13 Dec 2020 04:02:26 +0000 (04:02 +0000)]
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

3 years agoRollup merge of #79985 - GuillaumeGomez:fix-submit-event, r=jyn514
Yuki Okushi [Sun, 13 Dec 2020 02:05:48 +0000 (11:05 +0900)]
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`

3 years agoRollup merge of #79984 - Nadrieril:remove-unused-dep, r=jyn514
Yuki Okushi [Sun, 13 Dec 2020 02:05:47 +0000 (11:05 +0900)]
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.

3 years agoRollup merge of #79973 - camelid:rustdoc-search-tab-color, r=GuillaumeGomez
Yuki Okushi [Sun, 13 Dec 2020 02:05:45 +0000 (11:05 +0900)]
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`

3 years agoRollup merge of #79970 - bjorn3:no_unnecessary_llvm_checkout, r=Mark-Simulacrum
Yuki Okushi [Sun, 13 Dec 2020 02:05:43 +0000 (11:05 +0900)]
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

3 years agoRollup merge of #79963 - LeSeulArtichaut:debruijn-typo, r=Dylan-DPC
Yuki Okushi [Sun, 13 Dec 2020 02:05:41 +0000 (11:05 +0900)]
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``

3 years agoRollup merge of #79954 - jyn514:normalize-oops, r=Mark-Simulacrum
Yuki Okushi [Sun, 13 Dec 2020 02:05:40 +0000 (11:05 +0900)]
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`

3 years agoRollup merge of #79942 - JCTyblaidd:static-mem-init, r=RalfJung
Yuki Okushi [Sun, 13 Dec 2020 02:05:38 +0000 (11:05 +0900)]
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

3 years agoRollup merge of #79940 - matthiaskrgr:cl15ppy, r=Dylan-DPC
Yuki Okushi [Sun, 13 Dec 2020 02:05:36 +0000 (11:05 +0900)]
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``

3 years agoRollup merge of #79845 - jyn514:python3, r=Mark-Simulacrum
Yuki Okushi [Sun, 13 Dec 2020 02:05:35 +0000 (11:05 +0900)]
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.

3 years agoRollup merge of #79834 - m-ou-se:bye-linked-list-extras, r=Mark-Simulacrum
Yuki Okushi [Sun, 13 Dec 2020 02:05:32 +0000 (11:05 +0900)]
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.

3 years agoRollup merge of #79398 - pickfire:keyword, r=Dylan-DPC
Yuki Okushi [Sun, 13 Dec 2020 02:05:30 +0000 (11:05 +0900)]
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.

3 years agoRollup merge of #79360 - wchargin:wchargin-doc-iter-by-reference, r=m-ou-se
Yuki Okushi [Sun, 13 Dec 2020 02:05:22 +0000 (11:05 +0900)]
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

3 years agoAuto merge of #79988 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
bors [Sun, 13 Dec 2020 01:28:59 +0000 (01:28 +0000)]
Auto merge of #79988 - ssomers:btree_cleanup_5, r=Mark-Simulacrum

BTreeMap: capture a recurring use pattern as replace_kv

r? `@Mark-Simulacrum`

3 years agoBTreeMap: capture a recurring use pattern as replace_kv
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: capture a recurring use pattern as replace_kv

3 years agoBTreeMap: detect bulk_steal's count-1 underflow in release builds too
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: detect bulk_steal's count-1 underflow in release builds too

3 years agoImprove error handling in `symbols` proc-macro
Arlie Davis [Fri, 11 Dec 2020 19:32:48 +0000 (11:32 -0800)]
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.

3 years agoFixes submit event of the search input
Guillaume Gomez [Sat, 12 Dec 2020 22:30:13 +0000 (23:30 +0100)]
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.

3 years agoAuto merge of #79976 - jyn514:assertion-failure, r=jyn514
bors [Sat, 12 Dec 2020 23:01:25 +0000 (23:01 +0000)]
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`

3 years agoFix building compiler docs with stage 0
Joshua Nelson [Sat, 12 Dec 2020 01:27:28 +0000 (20:27 -0500)]
Fix building compiler docs with stage 0

3 years agoRemove an unused dependency that made `rustdoc` crash
Nadrieril [Sat, 12 Dec 2020 22:13:03 +0000 (22:13 +0000)]
Remove an unused dependency that made `rustdoc` crash

3 years agoResolve enum field visibility correctly
Camelid [Sat, 12 Dec 2020 03:52:51 +0000 (19:52 -0800)]
Resolve enum field visibility correctly

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.

3 years agoProperly capture trailing 'unglued' token
Aaron Hill [Sat, 12 Dec 2020 20:20:22 +0000 (15:20 -0500)]
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.

3 years agoRecover on `const impl<> X for Y`
Noah [Thu, 3 Dec 2020 18:37:19 +0000 (12:37 -0600)]
Recover on `const impl<> X for Y`

3 years agoRemove incorrect assert
Joshua Nelson [Sat, 12 Dec 2020 20:40:58 +0000 (15:40 -0500)]
Remove incorrect assert

3 years agorustdoc light theme: Fix CSS for selected buttons
Camelid [Sat, 12 Dec 2020 19:42:34 +0000 (11:42 -0800)]
rustdoc light theme: Fix CSS for selected buttons

The background was dark before, which made the text impossible to read.
Now the background is white, which is how selected `div`s are rendered.

As a result, the search results tabs now look identical to how they
used to look (before #79896).

3 years agoAuto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomez
bors [Sat, 12 Dec 2020 19:41:56 +0000 (19:41 +0000)]
Auto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomez

[rustdoc] Calculate span information on demand instead of storing it ahead of time

This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`.

~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback.

Helps with #79103

3 years agoBTreeMap: clarify comments and panics surrounding choose_parent_kv
Stein Somers [Tue, 24 Nov 2020 11:27:38 +0000 (12:27 +0100)]
BTreeMap: clarify comments and panics surrounding choose_parent_kv

3 years agoAuto merge of #79969 - petrochenkov:outestidy, r=Mark-Simulacrum
bors [Sat, 12 Dec 2020 17:24:29 +0000 (17:24 +0000)]
Auto merge of #79969 - petrochenkov:outestidy, r=Mark-Simulacrum

tidy: Re-enable check for inline unit tests

It regressed in https://github.com/rust-lang/rust/pull/73265 and compiler crates are no longer checked.

3 years agoDon't require cmake and ninja when the LLVM backend is not used
bjorn3 [Sat, 12 Dec 2020 17:13:04 +0000 (18:13 +0100)]
Don't require cmake and ninja when the LLVM backend is not used

3 years agoDon't checkout llvm-project when the LLVM backend isn't built
bjorn3 [Sat, 12 Dec 2020 17:02:37 +0000 (18:02 +0100)]
Don't checkout llvm-project when the LLVM backend isn't built

3 years agoRemove some no longer necessary `#[cfg(test)]`s
Vadim Petrochenkov [Sat, 12 Dec 2020 16:20:37 +0000 (19:20 +0300)]
Remove some no longer necessary `#[cfg(test)]`s

With https://github.com/rust-lang/rust/pull/69838 inner modules are never touched in the outer module is unconfigured.

3 years agotidy: Re-enable check for inline unit tests
Vadim Petrochenkov [Sat, 12 Dec 2020 16:18:44 +0000 (19:18 +0300)]
tidy: Re-enable check for inline unit tests

3 years agoFix typo in `DebruijnIndex` documentation
LeSeulArtichaut [Sat, 12 Dec 2020 15:13:06 +0000 (16:13 +0100)]
Fix typo in `DebruijnIndex` documentation

Co-authored-by: Rémy Rakic <lqd@users.noreply.github.com>
3 years agoAuto merge of #79370 - jyn514:tidy-error, r=GuillaumeGomez
bors [Sat, 12 Dec 2020 15:03:00 +0000 (15:03 +0000)]
Auto merge of #79370 - jyn514:tidy-error, r=GuillaumeGomez

Don't abort rustdoc tests if `tidy` isn't installed

Follow-up to https://github.com/rust-lang/rust/pull/78752.

Before:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 396 tests
..................................................2020-11-23T12:12:37.735649Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................. 100/396
.................................................................................................... 200/396
.................................................................................................... 300/396
...............................i...............2020-11-23T12:15:00.271271Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................
```

After:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 4 tests
.FFF
failures:

---- [rustdoc] rustdoc/fn-pointer-arg-name.rs stdout ----

error: htmldocck failed!
status: exit code: 1
command: "/usr/bin/python" "/home/joshua/rustc/src/etc/htmldocck.py" "/home/joshua/rustc/build/x86_64-unknown-linux-gnu/test/rustdoc/fn-pointer-arg-name" "/home/joshua/rustc/src/test/rustdoc/fn-pointer-arg-name.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
4: `@has` check failed
`XPATH PATTERN` did not match
// `@has` - '//*[`@class="rust` fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'

Encountered 1 errors

------------------------------------------

info: generating a diff against nightly rustdoc
failed to run tidy - is it installed? - Permission denied (os error 13)
failed to run tidy - is it installed? - Permission denied (os error 13)
 # a diff without running `tidy`
```

r? `@GuillaumeGomez`

3 years agoSmall cleanups
Joshua Nelson [Sat, 12 Dec 2020 14:38:35 +0000 (09:38 -0500)]
Small cleanups

- Use a tuple struct instead of a single field
- Enforce calling `source_callsite()` by making the inner span private
- Rename `empty` to `dummy`

3 years agoIgnore .css files in the diff
Joshua Nelson [Thu, 26 Nov 2020 20:48:21 +0000 (15:48 -0500)]
Ignore .css files in the diff

These are always static and never autogenerated, so the diffs aren't
useful.

3 years agoIf tidy isn't installed, only give one error, not many
Joshua Nelson [Thu, 26 Nov 2020 19:05:54 +0000 (14:05 -0500)]
If tidy isn't installed, only give one error, not many

3 years agoDon't abort rustdoc tests if `tidy` isn't installed
Joshua Nelson [Tue, 24 Nov 2020 01:50:02 +0000 (20:50 -0500)]
Don't abort rustdoc tests if `tidy` isn't installed

Before:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 396 tests
..................................................2020-11-23T12:12:37.735649Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................. 100/396
.................................................................................................... 200/396
.................................................................................................... 300/396
...............................i...............2020-11-23T12:15:00.271271Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................
```

After:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 4 tests
.FFF
failures:

---- [rustdoc] rustdoc/fn-pointer-arg-name.rs stdout ----

error: htmldocck failed!
status: exit code: 1
command: "/usr/bin/python" "/home/joshua/rustc/src/etc/htmldocck.py" "/home/joshua/rustc/build/x86_64-unknown-linux-gnu/test/rustdoc/fn-pointer-arg-name" "/home/joshua/rustc/src/test/rustdoc/fn-pointer-arg-name.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
4: @has check failed
`XPATH PATTERN` did not match
// @has - '//*[@class="rust fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'

Encountered 1 errors

------------------------------------------

info: generating a diff against nightly rustdoc
failed to run tidy - is it installed? - Permission denied (os error 13)
failed to run tidy - is it installed? - Permission denied (os error 13)
 # a diff without running `tidy`
```

3 years agoAuto merge of #79169 - LeSeulArtichaut:ty-lib, r=nikomatsakis
bors [Sat, 12 Dec 2020 12:36:18 +0000 (12:36 +0000)]
Auto merge of #79169 - LeSeulArtichaut:ty-lib, r=nikomatsakis

Create `rustc_type_ir`

Decided to start small 😄

This PR creates a `rustc_type_ir` crate as part of the WG-Traits plan to create a shared type library.
~~There already exists a `rustc_ty` crate, so I named the new crate `rustc_ty_library`. However I think it would make sense to rename the current `rustc_ty` to something else (e.g. `rustc_ty_passes`) to free the name for this new crate.~~

r? `@jackh726`

3 years agoAuto merge of #79937 - RalfJung:miri, r=RalfJung
bors [Sat, 12 Dec 2020 10:14:34 +0000 (10:14 +0000)]
Auto merge of #79937 - RalfJung:miri, r=RalfJung

update Miri

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

3 years agoFixes reported bugs in Rust Coverage
Rich Kadel [Sat, 12 Dec 2020 02:28:37 +0000 (18:28 -0800)]
Fixes reported bugs in Rust Coverage

Fixes: #79569
Fixes: #79566
Fixes: #79565
For the first issue (#79569), I got hit a `debug_assert!()` before
encountering the reported error message (because I have `debug = true`
enabled in my config.toml).

The assertion showed me that some `SwitchInt`s can have more than one
target pointing to the same `BasicBlock`.

I had thought that was invalid, but since it seems to be possible, I'm
allowing this now.

I added a new test for this.

----

In the last two cases above, both tests (intentionally) fail to compile,
but the `InstrumentCoverage` pass is invoked anyway.

The MIR starts with an `Unreachable` `BasicBlock`, which I hadn't
encountered before. (I had assumed the `InstrumentCoverage` pass
would only be invoked with MIRs from successful compilations.)

I don't have test infrastructure set up to test coverage on files that
fail to compile, so I didn't add a new test.

3 years agoFix the JSON backend
Joshua Nelson [Sat, 12 Dec 2020 04:57:18 +0000 (23:57 -0500)]
Fix the JSON backend

This was simpler than expected.

3 years agoCalculate span info on-demand instead of ahead of time
Joshua Nelson [Sat, 12 Dec 2020 04:01:26 +0000 (23:01 -0500)]
Calculate span info on-demand instead of ahead of time

This should *vastly* reduce memory usage.

3 years agoPass Session into renderer
Joshua Nelson [Sat, 12 Dec 2020 03:36:51 +0000 (22:36 -0500)]
Pass Session into renderer

3 years agoAuto merge of #79931 - RalfJung:no-redundant-storage-live, r=oli-obk
bors [Sat, 12 Dec 2020 02:40:17 +0000 (02:40 +0000)]
Auto merge of #79931 - RalfJung:no-redundant-storage-live, r=oli-obk

make redundant StorageLive UB

The interesting behavior of StorageLive in loops (https://github.com/rust-lang/rust/issues/42371) has been fixed, so we can now finally make it a hard error to mark a local as live that is already live. :)

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/42371

3 years agoAuto merge of #79553 - sexxi-goose:mir_min_cap_writeback, r=nikomatsakis
bors [Sat, 12 Dec 2020 00:23:29 +0000 (00:23 +0000)]
Auto merge of #79553 - sexxi-goose:mir_min_cap_writeback, r=nikomatsakis

Capture precise paths in THIR and MIR

This PR allows THIR and MIR to use the result of the new capture analysis to actually capture precise paths

To achieve we:
- Writeback min capture results to TypeckResults
- Move handling upvars to PlaceBuilder in mir_build
- Lower precise paths in THIR build by reading min_captures
- Search for ancestors in min_capture when trying to build a MIR place which starts off of an upvar

Closes: https://github.com/rust-lang/project-rfc-2229/issues/10
Partly implements: rust-lang/project-rfc-2229#18

Work that remains (not in this PR):
- [ ] [Known bugs when feature gate is enabled](https://github.com/rust-lang/project-rfc-2229/projects/1?card_filter_query=label%3Abug)
- [ ] Use min_capure_map for
  - [ ] Liveness analysis
  - [ ] rustc_mir/interpret/validity.rs
  - [ ] regionck
- [ ] rust-lang/project-rfc-2229#8
- [ ] remove closure_captures and upvar_capture_map

r? `@ghost`

3 years agofix clippy::unnecessary_filter_map
Matthias Krüger [Fri, 11 Dec 2020 18:13:16 +0000 (19:13 +0100)]
fix clippy::unnecessary_filter_map

3 years agouse if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return...
Matthias Krüger [Fri, 11 Dec 2020 17:19:51 +0000 (18:19 +0100)]
use if let Some(x) = ..  instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn)

3 years agofix clippy::{needless_bool, manual_unwrap_or}
Matthias Krüger [Fri, 11 Dec 2020 17:08:05 +0000 (18:08 +0100)]
fix clippy::{needless_bool, manual_unwrap_or}

3 years agodon't clone types that are copy (clippy::clone_on_copy)
Matthias Krüger [Fri, 11 Dec 2020 16:49:00 +0000 (17:49 +0100)]
don't clone types that are copy (clippy::clone_on_copy)

3 years agodon't convert types into identical types with .into() (clippy::useless_conversion)
Matthias Krüger [Fri, 11 Dec 2020 16:40:59 +0000 (17:40 +0100)]
don't convert types into identical types with .into() (clippy::useless_conversion)