]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agodon't allow ZST in ScalarInt
Ralf Jung [Sun, 3 Jul 2022 15:17:23 +0000 (11:17 -0400)]
don't allow ZST in ScalarInt

There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So instead add new ZST variants to those types that did not have other variants
which could be used for this purpose.

23 months agoAuto merge of #99078 - Dylan-DPC:rollup-gnw6cli, r=Dylan-DPC
bors [Sat, 9 Jul 2022 07:15:34 +0000 (07:15 +0000)]
Auto merge of #99078 - Dylan-DPC:rollup-gnw6cli, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #98350 (Implement support for DWARF version 5.)
 - #98915 (Clarify deriving code)
 - #98980 (fix ICE in ConstProp)
 - #99008 (Adding suggestion for E0530)
 - #99043 (Collapse some weirdly-wrapping derives)
 - #99048 (Remove a string comparison about types)
 - #99070 (Update integer_atomics tracking issue)

Failed merges:

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

23 months agoRollup merge of #99070 - tamird:update-tracking-issue, r=RalfJung
Dylan DPC [Sat, 9 Jul 2022 05:58:09 +0000 (11:28 +0530)]
Rollup merge of #99070 - tamird:update-tracking-issue, r=RalfJung

Update integer_atomics tracking issue

Updates #32976.
Updates #99069.

r? ``@RalfJung``

23 months agoRollup merge of #99048 - TaKO8Ki:remove-type-string-comparison, r=compiler-errors
Dylan DPC [Sat, 9 Jul 2022 05:58:08 +0000 (11:28 +0530)]
Rollup merge of #99048 - TaKO8Ki:remove-type-string-comparison, r=compiler-errors

Remove a string comparison about types

23 months agoRollup merge of #99043 - compiler-errors:derive-nit, r=cjgillot
Dylan DPC [Sat, 9 Jul 2022 05:58:07 +0000 (11:28 +0530)]
Rollup merge of #99043 - compiler-errors:derive-nit, r=cjgillot

Collapse some weirdly-wrapping derives

self-explanatory

23 months agoRollup merge of #99008 - obeis:issue-98974, r=compiler-errors
Dylan DPC [Sat, 9 Jul 2022 05:58:06 +0000 (11:28 +0530)]
Rollup merge of #99008 - obeis:issue-98974, r=compiler-errors

Adding suggestion for E0530

Closes #98974

23 months agoRollup merge of #98980 - RalfJung:const-prop-ice, r=oli-obk
Dylan DPC [Sat, 9 Jul 2022 05:58:05 +0000 (11:28 +0530)]
Rollup merge of #98980 - RalfJung:const-prop-ice, r=oli-obk

fix ICE in ConstProp

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

23 months agoRollup merge of #98915 - nnethercote:clarify-deriving-code, r=Mark-Simulacrum
Dylan DPC [Sat, 9 Jul 2022 05:58:04 +0000 (11:28 +0530)]
Rollup merge of #98915 - nnethercote:clarify-deriving-code, r=Mark-Simulacrum

Clarify deriving code

A number of clarifications to the deriving code.

r? ``@Mark-Simulacrum``

23 months agoRollup merge of #98350 - pcwalton:dwarf5, r=michaelwoerister
Dylan DPC [Sat, 9 Jul 2022 05:58:03 +0000 (11:28 +0530)]
Rollup merge of #98350 - pcwalton:dwarf5, r=michaelwoerister

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

r? ``@michaelwoerister``

23 months agoAuto merge of #99028 - tmiasko:inline, r=estebank
bors [Sat, 9 Jul 2022 04:34:51 +0000 (04:34 +0000)]
Auto merge of #99028 - tmiasko:inline, r=estebank

Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.

23 months agoAuto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk
bors [Sat, 9 Jul 2022 02:04:17 +0000 (02:04 +0000)]
Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk

Only enable ConstProp on opt level >= 1

r? `@JakobDegen`

23 months agoMinor updates based on review comments.
Nicholas Nethercote [Thu, 7 Jul 2022 21:57:34 +0000 (07:57 +1000)]
Minor updates based on review comments.

23 months agoAuto merge of #98816 - estebank:implicit-sized, r=oli-obk
bors [Fri, 8 Jul 2022 23:17:34 +0000 (23:17 +0000)]
Auto merge of #98816 - estebank:implicit-sized, r=oli-obk

Track implicit `Sized` obligations in type params

When we evaluate `ty::GenericPredicates` we introduce the implicit
`Sized` predicate of type params, but we do so with only the `Predicate`
its `Span` as context, we don't have an `Obligation` or
`ObligationCauseCode` we could influence. To try and carry this
information through, we add a new field to `ty::GenericPredicates` that
tracks both which predicates come from a type param and whether that
param has any bounds already (to use in suggestions).

We also suggest adding a `?Sized` bound if appropriate on E0599.

Address part of #98539.

23 months agoSimplify `cs_fold`.
Nicholas Nethercote [Tue, 5 Jul 2022 01:23:55 +0000 (11:23 +1000)]
Simplify `cs_fold`.

`cs_fold` has four distinct cases, covered by three different function
arguments:

- first field
- combine current field with previous results
- no fields
- non-matching enum variants

This commit clarifies things by replacing the three function arguments
with one that takes a new `CsFold` type with four slightly different)
cases

- single field
- combine result for current field with results for previous fields
- no fields
- non-matching enum variants

This makes the code shorter and clearer.

23 months agoFix some inconsistencies.
Nicholas Nethercote [Tue, 5 Jul 2022 00:21:37 +0000 (10:21 +1000)]
Fix some inconsistencies.

This makes `cs_cmp`, `cs_partial_cmp`, and `cs_op` (for `PartialEq`)
more similar. It also fixes some out of date comments.

23 months agoCut down large comment about zero-variant enums.
Nicholas Nethercote [Mon, 4 Jul 2022 23:50:36 +0000 (09:50 +1000)]
Cut down large comment about zero-variant enums.

When deriving functions for zero-variant enums, we just generated a
function body that calls `std::instrincs::unreachable`. There is a large
comment with some not-very-useful historical discussion about
alternatives, including some discussion of feature-gating zero-variant
enums, which is clearly irrelevant today.

This commit cuts the comment down greatly.

23 months agoAvoid transposes in deriving code.
Nicholas Nethercote [Mon, 4 Jul 2022 23:04:41 +0000 (09:04 +1000)]
Avoid transposes in deriving code.

The deriving code has some complex parts involving iterations over
selflike args and also fields within structs and enum variants.

The return types for a few functions demonstrate this:

- `TraitDef::create_{struct_pattern,enum_variant_pattern}` returns a
  `(P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>)`
- `TraitDef::create_struct_field_accesses` returns a `Vec<(Span,
  Option<Ident>, P<Expr>)>`.

This results in per-field data stored within per-selflike-arg data, with
lots of repetition within the per-field data elements. This then has to
be "transposed" in two places (`expand_struct_method_body` and
`expand_enum_method_body`) into per-self-like-arg data stored within
per-field data. It's all quite clumsy and confusing.

This commit rearranges things greatly. Data is obtained in the needed
form up-front, avoiding the need for transposition. Also, various
functions are split, removed, and added, to make things clearer and
avoid tuple return values.

The diff is hard to read, which reflects the messiness of the original
code -- there wasn't an easy way to break these changes into small
pieces. (Sorry!) It's a net reduction of 35 lines and a readability
improvement. The generated code is unchanged.

23 months agoRemove `FieldInfo::attrs`.
Nicholas Nethercote [Mon, 4 Jul 2022 22:59:17 +0000 (08:59 +1000)]
Remove `FieldInfo::attrs`.

It's unused. This also removes the need for the lifetime on `FieldInfo`,
which is nice.

23 months agoRename `FieldInfo` fields.
Nicholas Nethercote [Mon, 4 Jul 2022 22:47:04 +0000 (08:47 +1000)]
Rename `FieldInfo` fields.

Use `self_exprs` and `other_selflike_exprs` in a manner similar to the
previous commit.

23 months agoClarify args terminology.
Nicholas Nethercote [Mon, 4 Jul 2022 22:25:47 +0000 (08:25 +1000)]
Clarify args terminology.

The deriving code has inconsistent terminology to describe args.

In some places it distinguishes between:
- the `&self` arg (if present), versus
- all other args.

In other places it distinguishes between:
- the `&self` arg (if present) and any other arguments with the same
  type (in practice there is at most one, e.g. in `PartialEq::eq`),
  versus
- all other args.

The terms "self_args" and "nonself_args" are sometimes used for the
former distinction, and sometimes for the latter. "args" is also
sometimes used for "all other args".

This commit makes the code consistently uses "self_args"/"nonself_args"
for the former and "selflike_args"/"nonselflike_args" for the latter.
This change makes the code easier to read.

The commit also adds a panic on an impossible path (the `Self_` case) in
`extract_arg_details`.

23 months agoUpdate integer_atomics tracking issue
Tamir Duberstein [Fri, 8 Jul 2022 21:52:04 +0000 (17:52 -0400)]
Update integer_atomics tracking issue

Updates #32976.
Updates #99069.

23 months agoAuto merge of #99034 - RalfJung:miri, r=Mark-Simulacrum
bors [Fri, 8 Jul 2022 20:36:33 +0000 (20:36 +0000)]
Auto merge of #99034 - RalfJung:miri, r=Mark-Simulacrum

update Miri

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

23 months 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

23 months agoAuto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiser
bors [Fri, 8 Jul 2022 17:55:26 +0000 (17:55 +0000)]
Auto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiser

don't succeed `evaluate_obligation` query if new opaque types were registered

fixes #98608
fixes #98604

The root cause of all this is that in type flag computation we entirely ignore nongeneric things like struct fields and the signature of function items. So if a flag had to be set for a struct if it is set for a field, that will only happen if the field is generic, as only the generic parameters are checked.

I now believe we cannot use type flags to handle opaque types. They seem like the wrong tool for this.

Instead, this PR replaces the previous logic by adding a new variant of `EvaluatedToOk`: `EvaluatedToOkModuloOpaqueTypes`, which says that there were some opaque types that got hidden types bound, but that binding may not have been legal (because we don't know if the opaque type was in its defining scope or not).

23 months 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

23 months agoremove a string comparison about types
Takayuki Maeda [Fri, 8 Jul 2022 15:07:52 +0000 (00:07 +0900)]
remove a string comparison about types

23 months agoOnly register hidden types for opaque types from the current crate, nothing else...
Oli Scherer [Fri, 8 Jul 2022 13:59:44 +0000 (13:59 +0000)]
Only register hidden types for opaque types from the current crate, nothing else would work anyway.

23 months 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

23 months 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`

23 months 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`

23 months 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``

23 months 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`

23 months agoUpdate ui test for the new E0530 suggestion
Obei Sideg [Fri, 8 Jul 2022 11:54:11 +0000 (14:54 +0300)]
Update ui test for the new E0530 suggestion

23 months agointerpret: only to track_caller in debug builds due to perf
Ralf Jung [Fri, 8 Jul 2022 11:33:19 +0000 (07:33 -0400)]
interpret: only to track_caller in debug builds due to perf

23 months agoCheck if E0530 is `rustc_resolve::late::PatternSource::Match` to emit suggestion
Obei Sideg [Fri, 8 Jul 2022 11:01:30 +0000 (14:01 +0300)]
Check if E0530 is `rustc_resolve::late::PatternSource::Match` to emit suggestion

23 months agoCheck if E0530 is `tuple variant` or `tuple struct` to emit suggestion
Obei Sideg [Fri, 8 Jul 2022 10:20:05 +0000 (13:20 +0300)]
Check if E0530 is `tuple variant` or `tuple struct` to emit suggestion

23 months 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.

23 months 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

23 months 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

23 months 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`

23 months 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``

23 months 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).

23 months 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``

23 months 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```

23 months agoCollapse some weirdly-wrapping derives
Michael Goulet [Fri, 8 Jul 2022 04:36:30 +0000 (04:36 +0000)]
Collapse some weirdly-wrapping derives

23 months agoadd regex to rustc-workspace-hack
Ralf Jung [Fri, 8 Jul 2022 04:23:01 +0000 (00:23 -0400)]
add regex to rustc-workspace-hack

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

23 months 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

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

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

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

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

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

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

23 months 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

23 months 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.

23 months 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

23 months agoupdate Miri
Ralf Jung [Fri, 8 Jul 2022 00:51:58 +0000 (20:51 -0400)]
update Miri

23 months 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

23 months 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.

23 months 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

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

23 months agoMiscellaneous inlining improvements
Tomasz Miąsko [Thu, 7 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.

23 months 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

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

23 months 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

23 months 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

23 months 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

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

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

23 months 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.

23 months agoTrack `WellFormed` obligations with an appropriate cause, instead of `MiscObligation`
Esteban Küber [Fri, 1 Jul 2022 23:48:14 +0000 (16:48 -0700)]
Track `WellFormed` obligations with an appropriate cause, instead of `MiscObligation`

23 months agoTrack implicit `Sized` obligations in type params
Esteban Küber [Fri, 1 Jul 2022 23:47:26 +0000 (16:47 -0700)]
Track implicit `Sized` obligations in type params

Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting
the HIR Generics. (Fix #98539)

23 months 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``

23 months 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

23 months 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.

23 months 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.

23 months 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>

23 months 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

23 months 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``

23 months 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``

23 months 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

23 months agoAdd test for #98539
Esteban Küber [Fri, 1 Jul 2022 23:33:35 +0000 (16:33 -0700)]
Add test for #98539

23 months 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.

23 months agoAdding suggestion for E0530
Obei Sideg [Thu, 7 Jul 2022 09:45:08 +0000 (12:45 +0300)]
Adding suggestion for E0530

23 months 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`

23 months agomake a name less ambiguous
Ralf Jung [Thu, 7 Jul 2022 16:01:36 +0000 (12:01 -0400)]
make a name less ambiguous

23 months 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

23 months 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

23 months 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.

23 months 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.

23 months 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`

23 months 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.

23 months 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`

23 months 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`

23 months 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:

23 months 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.

23 months 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.

23 months 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`

23 months agonot knowing about opaque types is worse than not knowing about regions, make sure...
Oli Scherer [Thu, 7 Jul 2022 08:10:50 +0000 (08:10 +0000)]
not knowing about opaque types is worse than not knowing about regions, make sure we don't accidentally mark something as ok-modulo-regions if there are opaque types involved