Commit Graph

172220 Commits

Author SHA1 Message Date
bors
db78ab70a8 Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk
Only enable ConstProp on opt level >= 1

r? `@JakobDegen`
2022-07-09 02:04:17 +00:00
Daniel Xu
34e9e6dff1 Fix duplicated type annotation suggestion
Before, there was more or less duplicated suggestions to add type hints.
Fix by clearing more generic suggestions when a more specific suggestion
is possible.

This fixes #93506 .
2022-07-08 21:03:03 -05:00
Nicholas Nethercote
0578697a63 Minor updates based on review comments. 2022-07-09 10:04:09 +10:00
Jakob Degen
4939f6c64b Clarify MIR semantics of storage statements 2022-07-08 16:58:24 -07:00
bors
47575bb066 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.
2022-07-08 23:17:34 +00:00
Nicholas Nethercote
16a286b003 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.
2022-07-09 09:02:50 +10:00
Nicholas Nethercote
559398fa78 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.
2022-07-09 09:02:50 +10:00
Nicholas Nethercote
65d0bfbca5 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.
2022-07-09 09:02:50 +10:00
Nicholas Nethercote
7f1dfcab67 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.
2022-07-09 09:02:50 +10:00
Nicholas Nethercote
27571da5fa Remove FieldInfo::attrs.
It's unused. This also removes the need for the lifetime on `FieldInfo`,
which is nice.
2022-07-09 09:02:50 +10:00
Nicholas Nethercote
d3057b5ca7 Rename FieldInfo fields.
Use `self_exprs` and `other_selflike_exprs` in a manner similar to the
previous commit.
2022-07-09 09:02:50 +10:00
Nicholas Nethercote
32c9ffb9cc 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`.
2022-07-09 09:02:49 +10:00
Tamir Duberstein
a491d4582d
Update integer_atomics tracking issue
Updates #32976.
Updates #99069.
2022-07-08 17:52:04 -04:00
est31
bdf1d22515 Intra-doc-link-ify reference to Clone::clone_from 2022-07-08 22:47:07 +02:00
bors
06754d8852 Auto merge of #99034 - RalfJung:miri, r=Mark-Simulacrum
update Miri

Fixes https://github.com/rust-lang/rust/issues/98922
r? `@ghost`
2022-07-08 20:36:33 +00:00
Patrick Walton
1e0ad0c1d4 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
2022-07-08 11:31:08 -07:00
bors
052495d001 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).
2022-07-08 17:55:26 +00:00
Infra
aa7bcaa8c3
set all padding for main element in print 2022-07-08 12:44:16 -04:00
bors
45263fc66d 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
2022-07-08 15:24:57 +00:00
Takayuki Maeda
01893d880f remove a string comparison about types 2022-07-09 00:07:52 +09:00
Oli Scherer
69b1b3c011 Create a custom layout path for UnsafeCell instead of piggy backing on the layout_scalar_valid_range logic 2022-07-08 14:48:38 +00:00
lcnr
aea2d7e20a don't use commit_if_ok during higher_ranked_sub 2022-07-08 16:33:59 +02:00
Oli Scherer
4bfba76a3d Add tests for libstd types 2022-07-08 14:28:19 +00:00
Oli Scherer
d6b93eb793 Only register hidden types for opaque types from the current crate, nothing else would work anyway. 2022-07-08 13:59:44 +00:00
Dylan DPC
54dde8678b
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
2022-07-08 18:25:51 +05:30
Dylan DPC
dbae8309a0
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`
2022-07-08 18:25:50 +05:30
Dylan DPC
fe87923b54
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`
2022-07-08 18:25:49 +05:30
Dylan DPC
1ce8de3087
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``
2022-07-08 18:25:48 +05:30
bors
fbdb07f4e7 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`
2022-07-08 12:44:14 +00:00
Obei Sideg
1b32eb34b3 Update ui test for the new E0530 suggestion 2022-07-08 14:54:11 +03:00
Ralf Jung
cf9186ec69 interpret: only to track_caller in debug builds due to perf 2022-07-08 07:33:19 -04:00
Obei Sideg
c2436d54d0 Check if E0530 is rustc_resolve::late::PatternSource::Match to emit suggestion 2022-07-08 14:06:50 +03:00
Caio
1c3bab2fc9 Fix last let_chains blocker 2022-07-08 07:25:50 -03:00
Obei Sideg
ea46e7a47e Check if E0530 is tuple variant or tuple struct to emit suggestion 2022-07-08 13:20:05 +03:00
bors
1dcff2d507 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.
2022-07-08 10:03:27 +00:00
bors
0f97e02bdc 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
2022-07-08 07:22:33 +00:00
Matthias Krüger
445702d0cb
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
2022-07-08 08:00:41 +02:00
Matthias Krüger
e58c2d4f52
Rollup merge of #99019 - pierwill:doc-mir-statement, r=cjgillot
Add doc comments in `rustc_middle::mir`
2022-07-08 08:00:40 +02:00
Matthias Krüger
6c6791a458
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``
2022-07-08 08:00:39 +02:00
Matthias Krüger
5dcd28cd19
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).
2022-07-08 08:00:38 +02:00
Matthias Krüger
9c6bcb60f3
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!  Thanks!

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

r? ``@joshtriplett``
2022-07-08 08:00:37 +02:00
Matthias Krüger
b36e58a458
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```
2022-07-08 08:00:36 +02:00
Infra
933cbd4069
try to fix tidy issues 2022-07-08 01:54:55 -04:00
Infra
0b50007760
improve print styles
this change removes some interactive elements in `@media print` form.

more specifically, it removes the source links, the expand/collapse toggle buttons, and the `#copy-path` button.
it also adjusts some spacing and removes the `.top-doc` description completely if it's currently collapsed.
2022-07-08 01:29:35 -04:00
Michael Goulet
69ac8a68af Collapse some weirdly-wrapping derives 2022-07-08 04:36:30 +00:00
Ralf Jung
1cc7139ee0 add regex to rustc-workspace-hack 2022-07-08 00:23:44 -04:00
Michael Goulet
08135254dc Highlight conflicting param-env candidates 2022-07-08 03:51:08 +00:00
Michael Goulet
2058333780 simplify plurals in fluent messages using hir::ConstContext 2022-07-08 03:48:10 +00:00
Michael Goulet
f97f2a47ff Migrate MutDeref, TransientMutBorrow diagnostics 2022-07-08 03:48:10 +00:00
Michael Goulet
584e5d4c4f Migrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnostics 2022-07-08 03:47:59 +00:00