]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoImplement support for DWARF version 5.
Patrick Walton [Mon, 20 Jun 2022 23:26:51 +0000 (16:26 -0700)]
Implement support for DWARF version 5.

DWARF version 5 brings a number of improvements over version 4. Quoting from
the announcement [1]:

> Version 5 incorporates improvements in many areas: better data compression,
> separation of debugging data from executable files, improved description of
> macros and source files, faster searching for symbols, improved debugging
> optimized code, as well as numerous improvements in functionality and
> performance.

On platforms where DWARF version 5 is supported (Linux, primarily), this commit
adds support for it behind a new `-Z dwarf-version=5` flag.

[1]: https://dwarfstd.org/Public_Review.php

2 years agoAuto merge of #99054 - Dylan-DPC:rollup-0zuhhds, r=Dylan-DPC
bors [Fri, 8 Jul 2022 15:24:57 +0000 (15:24 +0000)]
Auto merge of #99054 - Dylan-DPC:rollup-0zuhhds, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #98533 (Add a `-Zdump-drop-tracking-cfg` debugging flag)
 - #98654 (An optimization for `pest-2.1.3`)
 - #98657 (Migrate some diagnostics from `rustc_const_eval` to `SessionDiagnostic`)
 - #98794 (Highlight conflicting param-env candidates)

Failed merges:

 - #98957 ( don't allow ZST in ScalarInt )

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

2 years agoRollup merge of #98794 - compiler-errors:conflicting-param-env, r=michaelwoerister
Dylan DPC [Fri, 8 Jul 2022 12:55:51 +0000 (18:25 +0530)]
Rollup merge of #98794 - compiler-errors:conflicting-param-env, r=michaelwoerister

Highlight conflicting param-env candidates

This could probably be further improved by noting _why_ equivalent param-env candidates (modulo regions) leads to ambiguity.

Fixes #98786

2 years agoRollup merge of #98657 - compiler-errors:rustc-const-eval-session-diagnostic-1, r...
Dylan DPC [Fri, 8 Jul 2022 12:55:50 +0000 (18:25 +0530)]
Rollup merge of #98657 - compiler-errors:rustc-const-eval-session-diagnostic-1, r=davidtwco

Migrate some diagnostics from `rustc_const_eval` to `SessionDiagnostic`

I'm still trying to get the hang of this, so it doesn't migrate _all_ of `rustc_const_eval`. Working on that later.

r? `@davidtwco`

2 years agoRollup merge of #98654 - nnethercote:pest-2.1.3-opt, r=pnkfelix
Dylan DPC [Fri, 8 Jul 2022 12:55:49 +0000 (18:25 +0530)]
Rollup merge of #98654 - nnethercote:pest-2.1.3-opt, r=pnkfelix

An optimization for `pest-2.1.3`

An easy win I found while looking at a profile of `pest-2.1.3`. It's also a small code cleanup.

r? `@pnkfelix`

2 years agoRollup merge of #98533 - jyn514:drop-tracking-debugging, r=eholk
Dylan DPC [Fri, 8 Jul 2022 12:55:48 +0000 (18:25 +0530)]
Rollup merge of #98533 - jyn514:drop-tracking-debugging, r=eholk

Add a `-Zdump-drop-tracking-cfg` debugging flag

This is useful for debugging drop-tracking; previously, you had to recompile
rustc from source and manually add a call to `write_graph_to_file`. This
makes the option more discoverable and configurable at runtime.

I also took the liberty of making the labels for the CFG nodes much easier to read:
previously, they looked like `id(2), local_id: 48`, now they look like
```
expr from_config (hir_id=HirId { owner: DefId(0:10 ~ default_struct_update[79f9]::foo), local_id: 2})
```

r? ``@eholk``

2 years agoAuto merge of #98758 - nnethercote:more-derive-output-improvements, r=Mark-Simulacrum
bors [Fri, 8 Jul 2022 12:44:14 +0000 (12:44 +0000)]
Auto merge of #98758 - nnethercote:more-derive-output-improvements, r=Mark-Simulacrum

More derive output improvements

This PR includes:
- Some test improvements.
- Some cosmetic changes to derive output that make the code look more like what a human would write.
- Some more fundamental improvements to `cmp` and `partial_cmp` generation.

r? `@Mark-Simulacrum`

2 years agoAuto merge of #98638 - bjorn3:less_string_interning, r=tmiasko
bors [Fri, 8 Jul 2022 10:03:27 +0000 (10:03 +0000)]
Auto merge of #98638 - bjorn3:less_string_interning, r=tmiasko

Use less string interning

This removes string interning in a couple of places where doing so won't result in perf improvements. I also switched one place to use pre-interned symbols.

2 years agoAuto merge of #99047 - matthiaskrgr:rollup-01vn70s, r=matthiaskrgr
bors [Fri, 8 Jul 2022 07:22:33 +0000 (07:22 +0000)]
Auto merge of #99047 - matthiaskrgr:rollup-01vn70s, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #95635 (sess: stabilize `--terminal-width` as `--diagnostic-width`)
 - #98718 (Stabilize `into_future`)
 - #98795 (A few cleanups)
 - #98798 (Fix caching bug in `download-rustc = true`)
 - #99019 (Add doc comments in `rustc_middle::mir`)
 - #99026 (Add test for and fix rust-lang/rust-clippy#9131)

Failed merges:

 - #98957 ( don't allow ZST in ScalarInt )

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

2 years agoRollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet
Matthias Krüger [Fri, 8 Jul 2022 06:00:41 +0000 (08:00 +0200)]
Rollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet

Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by #98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: https://github.com/rust-lang/rust-clippy/issues/9131

2 years agoRollup merge of #99019 - pierwill:doc-mir-statement, r=cjgillot
Matthias Krüger [Fri, 8 Jul 2022 06:00:40 +0000 (08:00 +0200)]
Rollup merge of #99019 - pierwill:doc-mir-statement, r=cjgillot

Add doc comments in `rustc_middle::mir`

2 years agoRollup merge of #98798 - jyn514:download-rustc-cached, r=Mark-Simulacrum
Matthias Krüger [Fri, 8 Jul 2022 06:00:39 +0000 (08:00 +0200)]
Rollup merge of #98798 - jyn514:download-rustc-cached, r=Mark-Simulacrum

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`.

Fixes the following error:
```
thread 'main' panicked at 'fs::read_dir(&lib_dir) failed with No such file or directory (os error 2) ("/home/jnelson/rust-lang/rust2/build/x86_64-unknown-linux-gnu/ci-rustc/lib")', config.rs:1563:20
```

r? ``@Mark-Simulacrum``

2 years agoRollup merge of #98795 - jackh726:lexical_region_resolve_cleanup, r=compiler-errors
Matthias Krüger [Fri, 8 Jul 2022 06:00:38 +0000 (08:00 +0200)]
Rollup merge of #98795 - jackh726:lexical_region_resolve_cleanup, r=compiler-errors

A few cleanups

Each commit is (mostly) self-explanatory. These changes have come as I try to remove `ReEmpty` (#98559).

2 years agoRollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc
Matthias Krüger [Fri, 8 Jul 2022 06:00:37 +0000 (08:00 +0200)]
Rollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc

Stabilize `into_future`

https://github.com/rust-lang/rust/issues/67644 has been labeled with [S-tracking-ready-to-stabilize](https://github.com/rust-lang/rust/labels/S-tracking-ready-to-stabilize) - which mentions someone needs to file a stabilization PR. So hence this PR! :sparkles: Thanks!

Closes https://github.com/rust-lang/rust/issues/67644

r? ``@joshtriplett``

2 years agoRollup merge of #95635 - davidtwco:terminal-width-stabilization, r=oli-obk
Matthias Krüger [Fri, 8 Jul 2022 06:00:36 +0000 (08:00 +0200)]
Rollup merge of #95635 - davidtwco:terminal-width-stabilization, r=oli-obk

sess: stabilize `--terminal-width` as `--diagnostic-width`

Formerly `-Zterminal-width`, `--terminal-width` allows the user or build
tool to inform rustc of the width of the terminal so that diagnostics
can be truncated.

Pending agreement to stabilize, see tracking issue at #84673.

r? ```@oli-obk```

2 years agoHighlight conflicting param-env candidates
Michael Goulet [Sat, 2 Jul 2022 01:30:07 +0000 (01:30 +0000)]
Highlight conflicting param-env candidates

2 years agosimplify plurals in fluent messages using hir::ConstContext
Michael Goulet [Fri, 8 Jul 2022 03:46:18 +0000 (03:46 +0000)]
simplify plurals in fluent messages using hir::ConstContext

2 years agoMigrate MutDeref, TransientMutBorrow diagnostics
Michael Goulet [Wed, 29 Jun 2022 06:22:15 +0000 (23:22 -0700)]
Migrate MutDeref, TransientMutBorrow diagnostics

2 years agoMigrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnostics
Michael Goulet [Wed, 29 Jun 2022 05:46:25 +0000 (22:46 -0700)]
Migrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnostics

2 years agoMigrate StaticAccess diagnostic
Michael Goulet [Wed, 29 Jun 2022 05:32:32 +0000 (22:32 -0700)]
Migrate StaticAccess diagnostic

2 years agoImplement IntoDiagnosticArg for hir::ConstContext
Michael Goulet [Wed, 29 Jun 2022 05:09:59 +0000 (22:09 -0700)]
Implement IntoDiagnosticArg for hir::ConstContext

2 years agoMigrate NonConstOp diagnostic
Michael Goulet [Wed, 29 Jun 2022 04:46:01 +0000 (21:46 -0700)]
Migrate NonConstOp diagnostic

2 years agoMigrate unstable-in-stable diagnostic
Michael Goulet [Wed, 29 Jun 2022 04:26:05 +0000 (21:26 -0700)]
Migrate unstable-in-stable diagnostic

2 years agoUse dashes instead of underscores in fluent names
Michael Goulet [Wed, 29 Jun 2022 04:03:14 +0000 (21:03 -0700)]
Use dashes instead of underscores in fluent names

2 years agoAuto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank
bors [Fri, 8 Jul 2022 03:05:15 +0000 (03:05 +0000)]
Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank

Shorten def_span of closures to just their header

Continuation of https://github.com/rust-lang/rust/pull/93967.

2 years agoMove code from rustc_trait_selection/opaque_types to better places
Jack Huey [Fri, 1 Jul 2022 01:27:13 +0000 (21:27 -0400)]
Move code from rustc_trait_selection/opaque_types to better places

2 years agoMove is_free and is_free_or_static to Region, change resolve_var to resolve_region...
Jack Huey [Tue, 28 Jun 2022 04:08:35 +0000 (00:08 -0400)]
Move is_free and is_free_or_static to Region, change resolve_var to resolve_region, and remove RootEmptyRegion

2 years agoAuto merge of #98360 - estebank:uninit-binding, r=oli-obk
bors [Thu, 7 Jul 2022 23:36:21 +0000 (23:36 +0000)]
Auto merge of #98360 - estebank:uninit-binding, r=oli-obk

 On partial uninit error point at where we need init

When a binding is declared without a value, borrowck verifies that all
codepaths have *one* assignment to them to initialize them fully. If
there are any cases where a condition can be met that leaves the binding
uninitialized or we attempt to initialize a field of an uninitialized
binding, we emit E0381.

We now look at all the statements that initialize the binding, and use
them to explore branching code paths that *don't* and point at them. If
we find *no* potential places where an assignment to the binding might
be missing, we display the spans of all the existing initializers to
provide some context.

Fix https://github.com/rust-lang/rust/issues/97956.

2 years agoAuto merge of #99024 - matthiaskrgr:rollup-8ygpcpg, r=matthiaskrgr
bors [Thu, 7 Jul 2022 20:55:34 +0000 (20:55 +0000)]
Auto merge of #99024 - matthiaskrgr:rollup-8ygpcpg, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #97917 (Implement ExitCodeExt for Windows)
 - #98844 (Reword comments and rename HIR visiting methods.)
 - #98979 (interpret: use AllocRange in UninitByteAccess)
 - #98986 (Fix missing word in comment)
 - #98994 (replace process exit with more detailed exit in src/bootstrap/*.rs)
 - #98995 (Add a test for #80471)
 - #99002 (suggest adding a derive for #[default] applied to variants)
 - #99004 (Add a test for #70408)
 - #99017 (Replace boolean argument for print_where_clause with an enum to make code more clear)

Failed merges:

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

2 years agofix arm test
Esteban Küber [Thu, 7 Jul 2022 20:16:33 +0000 (13:16 -0700)]
fix arm test

2 years agoAdd test for and fix rust-lang/rust-clippy#9131
Andrea Nall [Thu, 7 Jul 2022 19:30:37 +0000 (19:30 +0000)]
Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by #98446

2 years agoWording tweak
Esteban Küber [Thu, 23 Jun 2022 17:42:17 +0000 (10:42 -0700)]
Wording tweak

2 years agoFix label on uninit binding field assignment
Esteban Küber [Wed, 22 Jun 2022 22:36:26 +0000 (15:36 -0700)]
Fix label on uninit binding field assignment

2 years agoAvoid misleading message/label in `match-cfg-fake-edges.rs` test
Esteban Küber [Wed, 22 Jun 2022 19:59:48 +0000 (12:59 -0700)]
Avoid misleading message/label in `match-cfg-fake-edges.rs` test

2 years agoAdd test for `for` loop maybe initializing binding
Esteban Küber [Wed, 22 Jun 2022 18:26:08 +0000 (11:26 -0700)]
Add test for `for` loop maybe initializing binding

2 years agoReview comments: wording
Esteban Küber [Wed, 22 Jun 2022 18:04:36 +0000 (11:04 -0700)]
Review comments: wording

2 years agoTweak wording and spans
Esteban Küber [Tue, 21 Jun 2022 22:54:17 +0000 (15:54 -0700)]
Tweak wording and spans

2 years agoOn partial uninit error point at where we need init
Esteban Küber [Tue, 21 Jun 2022 18:57:45 +0000 (11:57 -0700)]
On partial uninit error point at where we need init

When a binding is declared without a value, borrowck verifies that all
codepaths have *one* assignment to them to initialize them fully. If
there are any cases where a condition can be met that leaves the binding
uninitialized or we attempt to initialize a field of an unitialized
binding, we emit E0381.

We now look at all the statements that initialize the binding, and use
them to explore branching code paths that *don't* and point at them. If
we find *no* potential places where an assignment to the binding might
be missing, we display the spans of all the existing initializers to
provide some context.

2 years agoRollup merge of #99017 - GuillaumeGomez:rustdoc-ending-enum, r=notriddle
Matthias Krüger [Thu, 7 Jul 2022 18:33:32 +0000 (20:33 +0200)]
Rollup merge of #99017 - GuillaumeGomez:rustdoc-ending-enum, r=notriddle

Replace boolean argument for print_where_clause with an enum to make code more clear

As you suggested ``@notriddle.`` Just not sure if the naming seems good to you?

r? ``@notriddle``

2 years agoRollup merge of #99004 - TaKO8Ki:add-test-for-70408, r=Mark-Simulacrum
Matthias Krüger [Thu, 7 Jul 2022 18:33:31 +0000 (20:33 +0200)]
Rollup merge of #99004 - TaKO8Ki:add-test-for-70408, r=Mark-Simulacrum

Add a test for #70408

closes #70408

2 years agoRollup merge of #99002 - fee1-dead-contrib:sugg_derive, r=michaelwoerister
Matthias Krüger [Thu, 7 Jul 2022 18:33:30 +0000 (20:33 +0200)]
Rollup merge of #99002 - fee1-dead-contrib:sugg_derive, r=michaelwoerister

suggest adding a derive for #[default] applied to variants

cc ``@TaKO8Ki`` as followup to #98873.

2 years agoRollup merge of #98995 - TaKO8Ki:add-test-for-80471, r=Mark-Simulacrum
Matthias Krüger [Thu, 7 Jul 2022 18:33:29 +0000 (20:33 +0200)]
Rollup merge of #98995 - TaKO8Ki:add-test-for-80471, r=Mark-Simulacrum

Add a test for #80471

Tests #80471, but doesn't close it, see https://github.com/rust-lang/rust/issues/80471#issuecomment-1177658967.

2 years agoRollup merge of #98994 - kons-9:dont_use_process_exit, r=jyn514
Matthias Krüger [Thu, 7 Jul 2022 18:33:28 +0000 (20:33 +0200)]
Rollup merge of #98994 - kons-9:dont_use_process_exit, r=jyn514

replace process exit with more detailed exit in src/bootstrap/*.rs

Fixes [#98830](https://github.com/rust-lang/rust/issues/98830)

I implemeted "detail_exit.rs" in lib.rs, and replace all of std::process::exit.
So, error code should panic in test code.
```
// lib.rs
pub fn detail_exit(code: i32) -> ! {
    // Successful exit
    if code == 0 {
        std::process::exit(0);
    }
    if cfg!(test) {
        panic!("status code: {}", code);
    } else {
        std::panic::resume_unwind(Box::new(code));
    }
}
```

<details>
<summary>% rg "exit\(" src/bootstrap/*.rs</summary>

```
builder.rs
351:            crate::detail_exit(1);
1000:            crate::detail_exit(1);
1429:                    crate::detail_exit(1);

compile.rs
1331:        crate::detail_exit(1);

config.rs
818:                    crate::detail_exit(2);
1488:        crate::detail_exit(1);

flags.rs
263:                crate::detail_exit(exit_code);
349:            crate::detail_exit(exit_code);
381:            crate::detail_exit(1);
602:                        crate::detail_exit(1);
616:                crate::detail_exit(1);
807:            crate::detail_exit(1);

format.rs
35:            crate::detail_exit(1);
117:        crate::detail_exit(1);

lib.rs
714:            detail_exit(1);
1620:                detail_exit(1);
1651:pub fn detail_exit(code: i32) -> ! {
1654:        std::process::exit(0);

sanity.rs
107:            crate::detail_exit(1);

setup.rs
97:        crate::detail_exit(1);
290:            crate::detail_exit(1);

test.rs
676:            crate::detail_exit(1);
1024:                crate::detail_exit(1);
1254:            crate::detail_exit(1);

tool.rs
207:                crate::detail_exit(1);

toolstate.rs
96:    crate::detail_exit(3);
111:            crate::detail_exit(1);
182:            crate::detail_exit(1);
228:            crate::detail_exit(1);

util.rs
339:        crate::detail_exit(1);
378:        crate::detail_exit(1);
468:    crate::detail_exit(1);
```
</details>

2 years agoRollup merge of #98986 - pierwill:patch-5, r=oli-obk
Matthias Krüger [Thu, 7 Jul 2022 18:33:27 +0000 (20:33 +0200)]
Rollup merge of #98986 - pierwill:patch-5, r=oli-obk

Fix missing word in comment

2 years agoRollup merge of #98979 - RalfJung:more-alloc-range, r=oli-obk
Matthias Krüger [Thu, 7 Jul 2022 18:33:26 +0000 (20:33 +0200)]
Rollup merge of #98979 - RalfJung:more-alloc-range, r=oli-obk

interpret: use AllocRange in UninitByteAccess

also use nice new format string syntax in `interpret/error.rs`, and use the `#` flag to add `0x` prefixes where applicable.

r? ``@oli-obk``

2 years agoRollup merge of #98844 - cjgillot:deep-visit, r=jyn514
Matthias Krüger [Thu, 7 Jul 2022 18:33:24 +0000 (20:33 +0200)]
Rollup merge of #98844 - cjgillot:deep-visit, r=jyn514

Reword comments and rename HIR visiting methods.

Sparked by this discussion in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Confused.20by.20comment.20on.20.60deep_visit_item_likes_in_module.60)

r? ``@jyn514`` ``@camsteffen``

2 years agoRollup merge of #97917 - AronParker:master, r=ChrisDenton
Matthias Krüger [Thu, 7 Jul 2022 18:33:23 +0000 (20:33 +0200)]
Rollup merge of #97917 - AronParker:master, r=ChrisDenton

Implement ExitCodeExt for Windows

Fixes #97914

### Motivation:

On Windows it is common for applications to return `HRESULT` (`i32`) or `DWORD` (`u32`) values. These stem from COM based components ([HRESULTS](https://docs.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize)), Win32 errors ([GetLastError](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror)), GUI applications ([WM_QUIT](https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-quit)) and more. The newly stabilized `ExitCode` provides an excellent fit for propagating these values, because `std::process::exit` does not run deconstructors which can result in errors. However, `ExitCode` currently only implements `From<u8> for ExitCode`, which disallows the full range of `i32`/`u32` values. This pull requests attempts to address that shortcoming by providing windows specific extensions that accept a `u32` value (which covers all possible `HRESULTS` and Win32 errors) analog to [ExitStatusExt::from_raw](https://doc.rust-lang.org/std/os/windows/process/trait.ExitStatusExt.html#tymethod.from_raw).

This was also intended by the original Stabilization https://github.com/rust-lang/rust/pull/93840#issue-1129209143=  as pointed out by ``@eggyal`` in https://github.com/rust-lang/rust/issues/97914#issuecomment-1151076755:

> Issues around platform specific representations: We resolved this issue by changing the return type of report from i32 to the opaque type ExitCode. __That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future.__

[Emphasis added]

### API

```rust
/// Windows-specific extensions to [`process::ExitCode`].
///
/// This trait is sealed: it cannot be implemented outside the standard library.
/// This is so that future additional methods are not breaking changes.
#[stable(feature = "windows_process_exit_code_from", since = "1.63.0")]
pub trait ExitCodeExt: Sealed {
    /// Creates a new `ExitCode` from the raw underlying `u32` return value of
    /// a process.
    #[stable(feature = "windows_process_exit_code_from", since = "1.63.0")]
    fn from_raw(raw: u32) -> Self;
}

#[stable(feature = "windows_process_exit_code_from", since = "1.63.0")]
impl ExitCodeExt for process::ExitCode {
    fn from_raw(raw: u32) -> Self {
        process::ExitCode::from_inner(From::from(raw))
    }
}
```

### Misc

I apologize in advance if I misplaced any attributes regarding stabilzation, as far as I learned traits are insta-stable so I chose to make them stable. If this is an error, please let me know and I'll correct it. I also added some additional machinery to make it work, analog to [ExitStatus](https://doc.rust-lang.org/std/process/struct.ExitStatus.html#).

EDIT: Proposal: https://github.com/rust-lang/libs-team/issues/48

2 years agoAuto merge of #95573 - cjgillot:lower-query, r=michaelwoerister
bors [Thu, 7 Jul 2022 18:14:44 +0000 (18:14 +0000)]
Auto merge of #95573 - cjgillot:lower-query, r=michaelwoerister

Make lowering a query

Split from https://github.com/rust-lang/rust/pull/88186.

This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query.
In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so.

Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by:
- enclosing `Definitions` in a lock, so as to allow modification;
- creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system.

See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.

2 years agoAdd doc comments in `rustc_middle::mir`
pierwill [Thu, 7 Jul 2022 16:32:52 +0000 (11:32 -0500)]
Add doc comments in `rustc_middle::mir`

2 years agoAuto merge of #99014 - Dylan-DPC:rollup-n84y0jk, r=Dylan-DPC
bors [Thu, 7 Jul 2022 15:08:27 +0000 (15:08 +0000)]
Auto merge of #99014 - Dylan-DPC:rollup-n84y0jk, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #96856 (Fix ProjectionElem validation)
 - #97711 (Improve soundness of rustc_arena)
 - #98507 (Finishing touches for `#[expect]` (RFC 2383))
 - #98692 (rustdoc: Cleanup more FIXMEs)
 - #98901 (incr: cache dwarf objects in work products)
 - #98930 (Make MIR basic blocks field public)
 - #98973 (Remove (unused) inherent impl anchors)
 - #98981 ( Edit `rustc_mir_dataflow::framework` documentation )

Failed merges:

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

2 years agoReplace boolean argument for print_where_clause with an enum to make code more clear
Guillaume Gomez [Thu, 7 Jul 2022 14:16:35 +0000 (16:16 +0200)]
Replace boolean argument for print_where_clause with an enum to make code more clear

2 years agoReword comments and rename HIR visiting methods.
Camille GILLOT [Sun, 3 Jul 2022 13:28:57 +0000 (15:28 +0200)]
Reword comments and rename HIR visiting methods.

2 years agoRollup merge of #98981 - pierwill:pierwill/dataflow-docs-edits, r=Dylan-DPC
Dylan DPC [Thu, 7 Jul 2022 12:36:55 +0000 (18:06 +0530)]
Rollup merge of #98981 - pierwill:pierwill/dataflow-docs-edits, r=Dylan-DPC

 Edit `rustc_mir_dataflow::framework` documentation

Some edits for clarity and consistency.

2 years agoRollup merge of #98973 - GuillaumeGomez:inherent-impl-anchors, r=notriddle
Dylan DPC [Thu, 7 Jul 2022 12:36:54 +0000 (18:06 +0530)]
Rollup merge of #98973 - GuillaumeGomez:inherent-impl-anchors, r=notriddle

Remove (unused) inherent impl anchors

This is something `@notriddle` realized a few days ago: we have unused anchors in the DOM.

This PR removes them.

You can test it [here](https://rustdoc.crud.net/imperio/inherent-impl-anchors/foo/index.html).

r? `@notriddle`

2 years agoRollup merge of #98930 - tmiasko:pub-basic-blocks, r=oli-obk
Dylan DPC [Thu, 7 Jul 2022 12:36:53 +0000 (18:06 +0530)]
Rollup merge of #98930 - tmiasko:pub-basic-blocks, r=oli-obk

Make MIR basic blocks field public

This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.

To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.

The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.

2 years agoRollup merge of #98901 - davidtwco:split-dwarf-incr-workproduct, r=michaelwoerister
Dylan DPC [Thu, 7 Jul 2022 12:36:52 +0000 (18:06 +0530)]
Rollup merge of #98901 - davidtwco:split-dwarf-incr-workproduct, r=michaelwoerister

incr: cache dwarf objects in work products

Cache DWARF objects alongside object files in work products when those exist so that DWARF object files are available for thorin in packed mode in incremental scenarios.

r? `@michaelwoerister`

2 years agoRollup merge of #98692 - camelid:more-fixmes, r=GuillaumeGomez
Dylan DPC [Thu, 7 Jul 2022 12:36:51 +0000 (18:06 +0530)]
Rollup merge of #98692 - camelid:more-fixmes, r=GuillaumeGomez

rustdoc: Cleanup more FIXMEs

r? `@GuillaumeGomez`

2 years agoRollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser
Dylan DPC [Thu, 7 Jul 2022 12:36:50 +0000 (18:06 +0530)]
Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser

Finishing touches for `#[expect]` (RFC 2383)

This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature.

As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly.

---

changelog: [`duplicate_mod`]: Fixed lint attribute interaction

r? `@wesleywiser`

cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549

And I guess that's it. Here have a magical unicorn :unicorn:

2 years agoRollup merge of #97711 - Nilstrieb:rustc-arena-ub, r=wesleywiser
Dylan DPC [Thu, 7 Jul 2022 12:36:49 +0000 (18:06 +0530)]
Rollup merge of #97711 - Nilstrieb:rustc-arena-ub, r=wesleywiser

Improve soundness of rustc_arena

Make it runnable in miri by changing the loop iteration count for some tests in miri. Also fix a stacked borrows issue with box.

2 years agoRollup merge of #96856 - DrMeepster:fix_projection_validation, r=Icnr
Dylan DPC [Thu, 7 Jul 2022 12:36:48 +0000 (18:06 +0530)]
Rollup merge of #96856 - DrMeepster:fix_projection_validation, r=Icnr

Fix ProjectionElem validation

`TypeChecker::visit_projection_elem` was not actually being called.

2 years agoAuto merge of #98675 - eddyb:cg-array-literal, r=nikic
bors [Thu, 7 Jul 2022 12:23:26 +0000 (12:23 +0000)]
Auto merge of #98675 - eddyb:cg-array-literal, r=nikic

rustc_codegen_ssa: use `project_index`, not `project_field`, for array literals.

See https://github.com/rust-lang/rust/pull/98615#issuecomment-1170082774 for some context.

In short, we were using `project_field` even for array `mir::Rvalue::Aggregate`s, which results in benchmarks like `deep-vector.rs` (and presumably also some real-world usecases?) being impacted by how we handle non-array aggregate fields.

(This is a separate PR so that we can measure the perf effects in isolation)

r? `@nikic`

2 years agoAuto merge of #98841 - Kobzol:hir-validator-bitset, r=cjgillot
bors [Thu, 7 Jul 2022 07:38:08 +0000 (07:38 +0000)]
Auto merge of #98841 - Kobzol:hir-validator-bitset, r=cjgillot

Use a bitset instead of a hash map in HIR ID validator

The hashset insertion was slightly hot in incr patched runs, but it seems unnecessary to use a hashset here, as it just checks that a dense set of N integers was seen.

I'm not sure if it's possible to know the amount of items beforehand to preallocate the bitset? I suppose not.

2 years agoBless coverage reports.
Camille GILLOT [Tue, 5 Jul 2022 15:45:10 +0000 (17:45 +0200)]
Bless coverage reports.

2 years agoBless MSVC debuginfo.
Camille GILLOT [Sun, 3 Jul 2022 15:34:26 +0000 (17:34 +0200)]
Bless MSVC debuginfo.

2 years agoBless aarch64 test.
Camille GILLOT [Sun, 3 Jul 2022 13:11:26 +0000 (15:11 +0200)]
Bless aarch64 test.

2 years agoFix borrowck closure span.
Camille GILLOT [Mon, 27 Jun 2022 05:33:19 +0000 (07:33 +0200)]
Fix borrowck closure span.

2 years agoBless codegen test.
Camille GILLOT [Sun, 26 Jun 2022 12:02:33 +0000 (14:02 +0200)]
Bless codegen test.

2 years agoShorten span for closures.
Camille GILLOT [Mon, 27 Jun 2022 05:45:35 +0000 (07:45 +0200)]
Shorten span for closures.

2 years agoadd a test for #70408
Takayuki Maeda [Thu, 7 Jul 2022 06:42:48 +0000 (15:42 +0900)]
add a test for #70408

2 years agoMove `dominators` from Body to BasicBlocks
Tomasz Miąsko [Tue, 5 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Move `dominators` from Body to BasicBlocks

2 years agoMove `switch_sources` from Body to BasicBlocks
Tomasz Miąsko [Tue, 5 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Move `switch_sources` from Body to BasicBlocks

2 years agoMove `predecessors` from Body to BasicBlocks
Tomasz Miąsko [Tue, 5 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Move `predecessors` from Body to BasicBlocks

2 years agoMove `is_cfg_cyclic` from Body to BasicBlocks
Tomasz Miąsko [Tue, 5 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Move `is_cfg_cyclic` from Body to BasicBlocks

2 years agoMake MIR basic blocks field public
Tomasz Miąsko [Mon, 4 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Make MIR basic blocks field public

This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.

To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.

The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.

2 years agosuggest adding a derive for #[default] applied to variants
Deadbeef [Thu, 7 Jul 2022 04:57:01 +0000 (04:57 +0000)]
suggest adding a derive for #[default] applied to variants

2 years agosquash the commits
toshiki goto [Wed, 6 Jul 2022 06:05:44 +0000 (15:05 +0900)]
squash the commits

implement detail_exit but I'm not sure it is right.

not create new file and write detail exit in lib.rs

replace std::process::exit to detail_exit

that is not related to code runnning.

remove pub

2 years agoAuto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisa
bors [Thu, 7 Jul 2022 04:18:47 +0000 (04:18 +0000)]
Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisa

Suggest using block for `extern "abi" fn` with no body

`@rustbot` modify labels: +A-diagnostics

2 years agoadd a test for #80471
Takayuki Maeda [Thu, 7 Jul 2022 02:33:56 +0000 (11:33 +0900)]
add a test for #80471

2 years agoAuto merge of #98487 - cjgillot:variance-nohir, r=wesleywiser
bors [Thu, 7 Jul 2022 01:17:36 +0000 (01:17 +0000)]
Auto merge of #98487 - cjgillot:variance-nohir, r=wesleywiser

Do not fetch HIR to compute variances.

Everything can be done using higher-level queries.  This simplifies the code, and should allow better incremental caching.

2 years agoAuto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obk
bors [Wed, 6 Jul 2022 22:50:29 +0000 (22:50 +0000)]
Auto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obk

interpret: remove support for unsized_locals

I added support for unsized_locals in https://github.com/rust-lang/rust/pull/59780 but the current implementation is a crude hack and IMO definitely not the right way to have unsized locals in MIR. It also [causes problems](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Missing.20Layout.20Check.20in.20.60interpret.2Foperand.2Ers.60.3F). and what codegen does is unsound and has been for years since clearly nobody cares (so I hope nobody actually relies on that implementation and I'll be happy if Miri ensures they do not). I think if we want to have unsized locals in Miri/MIR we should add them properly, either by having a `StorageLive` that takes metadata or by having an `alloca` that returns a pointer (making the ptr indirection explicit) or something like that.

So, this PR removes the `LocalValue::Unallocated` hack. It adds `Immediate::Uninit`, for several reasons:
- This lets us still do fairly little work in `push_stack_frame`, in particular we do not actually have to create any allocations.
- If/when I remove `ScalarMaybeUninit`, we will need something like this to have an "optimized" representation of uninitialized locals. Without this we'd have to put uninitialized integers into the heap!
- const-prop needs some way to indicate "I don't know the value of this local'; it used to use `LocalValue::Unallocated` for that, now it can use `Immediate::Uninit`.

There is still a fundamental difference between `LocalValue::Unallocated` and `Immediate::Uninit`: the latter is considered a regular local that you can read from and write to, it just has a more optimized representation when compared with an actual `Allocation` that is fully uninit. In contrast, `LocalValue::Unallocated`  had this really odd behavior where you would write to it but not read from it. (This is in fact what caused the problems mentioned above.)

While at it I also did two drive-by cleanups/improvements:
- In `pop_stack_frame`, do the return value copying and local deallocation while the frame is still on the stack. This leads to better error locations being reported. The old errors were [sometimes rather confusing](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.202022-06-24/near/287445522).
- Deduplicate `copy_op` and `copy_op_transmute`.

r? `@oli-obk`

2 years agoUse DefIdTree instead of re-implementing it.
Camille GILLOT [Thu, 2 Jun 2022 18:08:38 +0000 (20:08 +0200)]
Use DefIdTree instead of re-implementing it.

2 years agoRemove dead code.
Camille GILLOT [Tue, 3 May 2022 20:14:44 +0000 (22:14 +0200)]
Remove dead code.

2 years agoReword create_def comment.
Camille GILLOT [Tue, 3 May 2022 20:14:07 +0000 (22:14 +0200)]
Reword create_def comment.

2 years agoUse a dedicated DepKind for the forever-red node.
Camille GILLOT [Tue, 3 May 2022 20:04:49 +0000 (22:04 +0200)]
Use a dedicated DepKind for the forever-red node.

2 years agoComment untracked_crate.
Camille GILLOT [Tue, 3 May 2022 20:01:01 +0000 (22:01 +0200)]
Comment untracked_crate.

2 years agoRemove `sess` field from LoweringContext.
Camille GILLOT [Mon, 2 May 2022 18:32:17 +0000 (20:32 +0200)]
Remove `sess` field from LoweringContext.

2 years agoExpand comment in `with_hir_id_owner`.
Camille GILLOT [Mon, 2 May 2022 18:32:10 +0000 (20:32 +0200)]
Expand comment in `with_hir_id_owner`.

2 years agoCreate a forever red node and use it to force side effects.
Camille GILLOT [Wed, 27 Apr 2022 17:18:26 +0000 (19:18 +0200)]
Create a forever red node and use it to force side effects.

2 years agoDo not create a new NodeId when not used.
Camille GILLOT [Sat, 2 Apr 2022 14:13:20 +0000 (16:13 +0200)]
Do not create a new NodeId when not used.

2 years agoRemove useless branch.
Camille GILLOT [Sat, 2 Apr 2022 14:13:01 +0000 (16:13 +0200)]
Remove useless branch.

2 years agoMake AST lowering a query.
Camille GILLOT [Tue, 13 Jul 2021 16:45:20 +0000 (18:45 +0200)]
Make AST lowering a query.

2 years agoAllow to create definitions inside the query system.
Camille GILLOT [Mon, 12 Jul 2021 20:19:25 +0000 (22:19 +0200)]
Allow to create definitions inside the query system.

2 years agoAuto merge of #98987 - GuillaumeGomez:rollup-bcy32bp, r=GuillaumeGomez
bors [Wed, 6 Jul 2022 20:09:41 +0000 (20:09 +0000)]
Auto merge of #98987 - GuillaumeGomez:rollup-bcy32bp, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #96935 (Allow arithmetic and certain bitwise ops on AtomicPtr)
 - #98519 (Replace some `guess_head_span` with `def_span`)
 - #98911 (rustdoc: filter '_ lifetimes from ty::Generics)
 - #98939 (rustdoc: Add more semantic information to impl IDs)
 - #98971 (Fix typo in file descriptor docs)
 - #98983 (docs: Add overview of `rustc_middle::mir::TerminatorKind`)
 - #98984 (Remove erroneous doc comment)

Failed merges:

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

2 years agoFix `#[expect]` and `#[allow]` for `clippy::duplicate_mod`
xFrednet [Sat, 25 Jun 2022 22:00:47 +0000 (00:00 +0200)]
Fix `#[expect]` and `#[allow]` for `clippy::duplicate_mod`

2 years agoAdd function to manually fulfill lint expectations (RFC 2383)
xFrednet [Thu, 16 Jun 2022 11:20:57 +0000 (13:20 +0200)]
Add function to manually fulfill lint expectations (RFC 2383)

2 years agoDocument, that some lint have to be expected on the crate level (RFC 2383)
xFrednet [Thu, 16 Jun 2022 10:52:35 +0000 (12:52 +0200)]
Document, that some lint have to be expected on the crate level (RFC 2383)

Examples: NON_ASCII_IDENTS, UNCOMMON_CODEPOINTS, CONFUSABLE_IDENTS, MIXED_SCRIPT_CONFUSABLES

2 years agoRollup merge of #98984 - pierwill:patch-4, r=RalfJung
Guillaume Gomez [Wed, 6 Jul 2022 18:43:29 +0000 (20:43 +0200)]
Rollup merge of #98984 - pierwill:patch-4, r=RalfJung

Remove erroneous doc comment

Fixes the formatting issue shown here:

<img width="803" alt="Screen Shot 2022-07-06 at 12 50 56 PM" src="https://user-images.githubusercontent.com/19642016/177612734-2d881c6a-2850-4c1b-8f1a-08339ad5bfbc.png">

2 years agoRollup merge of #98983 - pierwill:patch-3, r=RalfJung
Guillaume Gomez [Wed, 6 Jul 2022 18:43:28 +0000 (20:43 +0200)]
Rollup merge of #98983 - pierwill:patch-3, r=RalfJung

docs: Add overview of `rustc_middle::mir::TerminatorKind`

2 years agoRollup merge of #98971 - MinnDevelopment:patch-1, r=Dylan-DPC
Guillaume Gomez [Wed, 6 Jul 2022 18:43:28 +0000 (20:43 +0200)]
Rollup merge of #98971 - MinnDevelopment:patch-1, r=Dylan-DPC

Fix typo in file descriptor docs

2 years agoRollup merge of #98939 - GuillaumeGomez:rustdoc-disamb-impls, r=notriddle
Guillaume Gomez [Wed, 6 Jul 2022 18:43:27 +0000 (20:43 +0200)]
Rollup merge of #98939 - GuillaumeGomez:rustdoc-disamb-impls, r=notriddle

rustdoc: Add more semantic information to impl IDs

Take over of #92745.

I fixed the last remaining issue for the links in the sidebar (mentioned by `@jsha)` and fixed the few links broken in the std/core docs.

cc `@camelid`
r? `@notriddle`