Commit Graph

10766 Commits

Author SHA1 Message Date
Michael Goulet
bcf98841d4 resolve lifetimes for const generic defaults 2022-02-05 01:30:14 -08:00
bors
27f5d830eb Auto merge of #93594 - matthiaskrgr:rollup-lcvhpdv, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #92528 (Make `Fingerprint::combine_commutative` associative)
 - #93221 ([borrowck] Fix help on mutating &self in async fns)
 - #93542 (Prevent lifetime elision in type alias)
 - #93546 (Validate that values in switch int terminator are unique)
 - #93571 (better suggestion for duplicated `where` clause)
 - #93574 (don't suggest adding `let` due to bad assignment expressions inside of `while` loop)
 - #93590 (More let_else adoptions)
 - #93592 (Remove unused dep from rustc_arena)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-02 19:07:07 +00:00
Matthias Krüger
93155c5956
Rollup merge of #93592 - est31:remove_unused_deps, r=bjorn3
Remove unused dep from rustc_arena
2022-02-02 19:34:08 +01:00
Matthias Krüger
3388e6d9fd
Rollup merge of #93590 - est31:let_else, r=lcnr
More let_else adoptions

Continuation of #89933, #91018, #91481, #93046.
2022-02-02 19:34:07 +01:00
Matthias Krüger
799bded9b4
Rollup merge of #93574 - compiler-errors:bad-let-suggestion, r=lcnr
don't suggest adding `let` due to bad assignment expressions inside of `while` loop

adds a check that our `lhs` expression is actually within the conditional part of the `while` loop, instead of anywhere in the `while` body.

fixes #93486
2022-02-02 19:34:06 +01:00
Matthias Krüger
ef500863bd
Rollup merge of #93571 - compiler-errors:better-where-suggestion, r=lcnr
better suggestion for duplicated `where` clause

fixes #93567
2022-02-02 19:34:05 +01:00
Matthias Krüger
b53eaf7ce5
Rollup merge of #93546 - tmiasko:validate-switch-int, r=oli-obk
Validate that values in switch int terminator are unique
2022-02-02 19:34:04 +01:00
Matthias Krüger
b622552e10
Rollup merge of #93221 - alyssaverkade:fix-93093, r=wesleywiser
[borrowck] Fix help on mutating &self in async fns

Previously, when rustc was provided an async function that tried to
mutate through a shared reference to an implicit self (as shown in the
ui test), rustc would suggest modifying the parameter signature
to `&mut` + the fully qualified name of the ty (in the case of the repro
`S`). If a user modified their code to match the suggestion, the
compiler would not accept it.

This commit modifies the suggestion so that when rustc is provided the
ui test that is also attached in this commit, it suggests (correctly)
`&mut self`. We try to be careful about distinguishing between implicit
and explicit self annotations, since the latter seem to be handled
correctly already.

This is my first PR here so I'm pretty sure I probably missed something/could use better terminology. I also didn't try to make the match exhaustive since implicit self is the only real special case that I need to handle (that I'm aware of), and I'm pretty sure there's a cleaner way to do this so any advice would be greatly appreciated! (I'm also not terribly confident about how I wrote the ui tests)

here is your cc as requested `@compiler-errors`

This is an attempt to fix #93093
2022-02-02 19:34:02 +01:00
Matthias Krüger
21ffe45631
Rollup merge of #92528 - tmiasko:combine-commutative, r=michaelwoerister
Make `Fingerprint::combine_commutative` associative

The previous implementation swapped lower and upper 64-bits of a result
of modular addition, so the function was non-associative.

r? `@Aaron1011`
2022-02-02 19:34:01 +01:00
est31
3cb7618f58 Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
est31
670f5c6ef3 More let_else adoptions 2022-02-02 17:11:01 +01:00
bors
7cd14d2f56 Auto merge of #93312 - pierwill:map-all-local-trait-impls, r=cjgillot
Return an indexmap in `all_local_trait_impls` query

The data structure previously used here required that `DefId` be `Ord`. As part of #90317, we do not want `DefId` to implement `Ord`.
2022-02-02 15:36:12 +00:00
bors
dca1e7aa5a Auto merge of #93154 - michaelwoerister:fix-generic-closure-and-generator-debuginfo, r=wesleywiser
debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo.

Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name.

This commit also emits `{closure_env#0}` as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called `{closure#0}`). Previously both were assigned the same name.

NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.
2022-02-02 12:37:28 +00:00
Michael Goulet
f35d43cdf0 better suggestion for duplicated where 2022-02-02 00:29:45 -08:00
Michael Goulet
bc23bbb990 don't suggest adding let due to expressions inside of while loop 2022-02-01 23:27:04 -08:00
Matthias Krüger
344bb59530
Rollup merge of #93560 - steffahn:a_typo, r=petrochenkov
Fix two incorrect "it's" (typos in comments)

Found one of these while reading the documentation online. The other came up because it's in the same file.
2022-02-02 07:11:09 +01:00
Matthias Krüger
c483b9f1bf
Rollup merge of #93559 - danielframpton:link-args-typo, r=oli-obk
Add missing | between print options

The help text for the newly stabilized print option is missing a | between stack-protector-strategies and link-args.
2022-02-02 07:11:08 +01:00
Matthias Krüger
8ede21b09c
Rollup merge of #92788 - estebank:colon-colon, r=cjgillot
Detect `::` -> `:` typo in type argument

When writing `Vec<A:B>`, suggest `Vec<A::B>`.
2022-02-02 07:11:05 +01:00
bors
d5f9c40e6a Auto merge of #93466 - cjgillot:query-dead, r=nagisa
Make dead code check a query.

Dead code check is run for each invocation of the compiler, even if no modifications were involved.
This PR makes dead code check a query keyed on the module. This allows to skip the check when a module has not changed.
To perform this, a query `live_symbols_and_ignored_derived_traits` is introduced to encapsulate the global analysis of finding live symbols. The second query `check_mod_deathness` outputs diagnostics for each module based on this first query's results.
2022-02-02 02:29:32 +00:00
Esteban Kuber
b26ad8d10f Detect :: -> : typo in type argument
When writing `Vec<A:B>`, suggest `Vec<A::B>`.
2022-02-02 01:19:24 +00:00
bors
1ea4851715 Auto merge of #93285 - JulianKnodt:const_eq_2, r=oli-obk
Continue work on associated const equality

This actually implements some more complex logic for assigning associated consts to values.
Inside of projection candidates, it now defers to a separate function for either consts or
types. To reduce amount of code, projections are now generic over T, where T is either a Type or
a Const. I can add some comments back later, but this was the fastest way to implement it.

It also now finds the correct type of consts in type_of.

---

The current main TODO is finding the const of the def id for the LeafDef.

Right now it works if the function isn't called, but once you use the trait impl with the bound it fails inside projection.
I was hoping to get some help in getting the `&'tcx ty::Const<'tcx>`, in addition to a bunch of other `todo!()`s which I think may not be hit.

r? `@oli-obk`

Updates #92827
2022-02-01 23:18:01 +00:00
Frank Steffahn
63b12aea27 Fix two incorrect "it's" 2022-02-01 22:32:02 +01:00
Daniel Frampton
e22729b464 Add missing | between print options 2022-02-01 12:40:01 -08:00
kadmin
78fb74a600 Fix w/ comments 2022-02-01 20:19:54 +00:00
bors
ad88831cd5 Auto merge of #93548 - matthiaskrgr:rollup-f7dkn3p, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #86374 (Enable combining `+crt-static` and `relocation-model=pic` on `x86_64-unknown-linux-gnu`)
 - #91828 (Implement `RawWaker` and `Waker` getters for underlying pointers)
 - #92021 (Eliminate duplicate codes of is_single_fp_element)
 - #92584 (add rustc lint, warning when iterating over hashmaps 2)
 - #93267 (implement a lint for suspicious auto trait impls)
 - #93290 (remove `TyS::same_type`)
 - #93436 (Update compiler_builtins to fix duplicate symbols in `armv7-linux-androideabi` rlib)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-01 16:55:43 +00:00
Matthias Krüger
724ce3798f
Rollup merge of #93290 - lcnr:same_type, r=jackh726
remove `TyS::same_type`

This function ignored regions and constants in adts, but didn't do so for references or any other types. cc https://github.com/rust-lang/rust/pull/93148#discussion_r791408057
2022-02-01 16:08:05 +01:00
Matthias Krüger
eb01fe85f7
Rollup merge of #93267 - lcnr:auto-trait-lint, r=nikomatsakis
implement a lint for suspicious auto trait impls

cc https://github.com/rust-lang/rust/pull/85048#issuecomment-1019805102

r? ``@nikomatsakis``
2022-02-01 16:08:04 +01:00
Matthias Krüger
741b62af07
Rollup merge of #92584 - lcnr:query-stable-lint, r=estebank
add rustc lint, warning when iterating over hashmaps 2

first introduced in #89558 and reverted in #90380 due to its perf impact

r? ``@estebank``
2022-02-01 16:08:03 +01:00
Matthias Krüger
788f2969f6
Rollup merge of #92021 - woodenarrow:br_single_fp_element, r=Mark-Simulacrum
Eliminate duplicate codes of is_single_fp_element

There are duplicate codes of is_single_fp_element function. Merge these codes to TyAndLayout impl block.
![image](https://user-images.githubusercontent.com/95843988/146707753-ba9ffc41-5888-4a53-80cf-f4fe3bcbac54.png)
2022-02-01 16:08:03 +01:00
Matthias Krüger
ce6c1484f8
Rollup merge of #86374 - bossmc:enable-static-pie-for-gnu, r=nagisa
Enable combining `+crt-static` and `relocation-model=pic` on `x86_64-unknown-linux-gnu`

Modern `gcc` versions support `-static-pie`, and `rustc` will already fall-back to `-static` if the local `gcc` is too old (and hence this change is optimistic rather than absolute).  This brings the `-musl` and `-gnu` targets to feature compatibility (albeit with different default settings).

Of note a `-static` or `-static-pie` binary based on glibc that uses NSS-backed functions (`gethostbyname` or `getpwuid` etc.) need to have access to the `libnss_X.so.2` libraries and any of their dynamic dependencies.

I wasn't sure about the `# only`/`# ignore` changes (I've not got a `gnux32` toolchain to test with hence not also enabling `-static-pie` there).
2022-02-01 16:08:01 +01:00
bors
686663a49e Auto merge of #93284 - eholk:disable-drop-range-analysis, r=pnkfelix
Disable drop range analysis

The previous PR, #93165, still performed the drop range analysis despite ignoring the results. Unfortunately, there were ICEs in the analysis as well, so some packages failed to build (see the issue #93197 for an example). This change further disables the analysis and just provides dummy results in that case.
2022-02-01 13:45:38 +00:00
Camille GILLOT
4e7d47bb6c Make dead code check a query. 2022-02-01 13:11:03 +01:00
lcnr
7ebd48d006 remove TyS::same_type
it ignored regions and constants in adts,
but didn't do so for references or any other types.
This seemed quite weird
2022-02-01 11:21:26 +01:00
Michael Woerister
fd7557b7ee debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo.
Before this change, closure/generator environments coming from different
instantiations of the same generic function were all assigned the same
name even though they were distinct types with potentially different data
layout. Now we append the generic arguments of the originating function
to the type name.

This commit also emits '{closure_env#0}' as the name of these types in
order to disambiguate them from the accompanying closure function
'{closure#0}'. Previously both were assigned the same name.
2022-02-01 10:39:40 +01:00
lcnr
4bbe970673 review + rebase 2022-02-01 10:29:36 +01:00
lcnr
6970547d40 rustfmt is broken, manually reduce line length 2022-02-01 10:15:59 +01:00
lcnr
a1a30f7548 add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
lcnr
ea624699e3 implement lint for suspicious auto trait impls 2022-02-01 09:55:19 +01:00
lcnr
7fcf7745cc update FutureIncompatibilityReason 2022-02-01 09:55:19 +01:00
bors
93e8201ca7 Auto merge of #93534 - ehuss:rollup-9ecozo9, r=ehuss
Rollup of 9 pull requests

Successful merges:

 - #91343 (Fix suggestion to slice if scrutinee is a `Result` or `Option`)
 - #93019 (If an integer is entered with an upper-case base prefix (0Xbeef, 0O755, 0B1010), suggest to make it lowercase)
 - #93090 (`impl Display for io::ErrorKind`)
 - #93456 (Remove an unnecessary transmute from opaque::Encoder)
 - #93492 (Hide failed command unless in verbose mode)
 - #93504 (kmc-solid: Increase the default stack size)
 - #93513 (Allow any pretty printed line to have at least 60 chars)
 - #93532 (Update books)
 - #93533 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-01 07:04:17 +00:00
Eric Huss
2e39a3f6ec
Rollup merge of #93513 - dtolnay:linewidth, r=nagisa
Allow any pretty printed line to have at least 60 chars

Follow-up to #93155. The rustc AST pretty printer has a tendency to get stuck in "vertical smear mode" when formatting highly nested code, where it puts a linebreak at *every possible* linebreak opportunity once the indentation goes beyond the pretty printer's target line width:

```rust
...
                                                              ((&([("test"
                                                                       as
                                                                       &str)]
                                                                     as
                                                                     [&str; 1])
                                                                   as
                                                                   &[&str; 1]),
                                                               (&([]
                                                                     as
                                                                     [ArgumentV1; 0])
                                                                   as
                                                                   &[ArgumentV1; 0]))
...
```

```rust
...
                                                                          [(1
                                                                               as
                                                                               i32),
                                                                           (2
                                                                               as
                                                                               i32),
                                                                           (3
                                                                               as
                                                                               i32)]
                                                                             as
                                                                             [i32; 3]
...
```

This is less common after #93155 because that PR greatly reduced the total amount of indentation, but the "vertical smear mode" failure mode is still just as present when you have deeply nested modules, functions, or trait impls, such as in the case of macro-expanded code from `-Zunpretty=expanded`.

Vertical smear mode is never the best way to format highly indented code though. It does not prevent the target line width from being exceeded, and it produces output that is less readable than just a longer line.

This PR makes the pretty printing algorithm allow a minimum of 60 chars on every line independent of indentation. So as code gets more indented, the right margin eventually recedes to make room for formatting without vertical smear.

```console
├─────────────────────────────────────┤
├─────────────────────────────────────┤
├─────────────────────────────────────┤
  ├───────────────────────────────────┤
    ├─────────────────────────────────┤
      ├───────────────────────────────┤
        ├─────────────────────────────┤
          ├───────────────────────────┤
            ├───────────────────────────┤
              ├───────────────────────────┤
            ├───────────────────────────┤
          ├───────────────────────────┤
        ├─────────────────────────────┤
      ├───────────────────────────────┤
    ├─────────────────────────────────┤
  ├───────────────────────────────────┤
├─────────────────────────────────────┤
```
2022-01-31 20:13:00 -08:00
Eric Huss
3aa2e4584b
Rollup merge of #93456 - bjorn3:remove_unnecessary_unsafe, r=michaelwoerister
Remove an unnecessary transmute from opaque::Encoder
2022-01-31 20:12:57 -08:00
Eric Huss
d7c0b4f706
Rollup merge of #93019 - 5225225:uppercase-suffix, r=wesleywiser
If an integer is entered with an upper-case base prefix (0Xbeef, 0O755, 0B1010), suggest to make it lowercase

The current error for this case isn't really great, it just complains about the whole thing past the `0` being an invalid suffix.
2022-01-31 20:12:55 -08:00
Eric Huss
5159c013b0
Rollup merge of #91343 - FabianWolff:issue-91328-as-deref, r=jackh726
Fix suggestion to slice if scrutinee is a `Result` or `Option`

Fixes #91328.
2022-01-31 20:12:55 -08:00
bors
25862ffc8d Auto merge of #93259 - eddyb:diagbld-scalar-pair, r=jackh726
rustc_errors: only box the `diagnostic` field in `DiagnosticBuilder`.

I happened to need to do the first change (replacing `allow_suggestions` with equivalent functionality on `Diagnostic` itself) as part of a larger change, and noticed that there's only two fields left in `DiagnosticBuilderInner`.

So with this PR, instead of a single pointer, `DiagnosticBuilder` is two pointers, which should work just as well for passing *it* by value (and may even work better wrt some operations, though probably not by much).

But anything that was already taking advantage of `DiagnosticBuilder` being a single pointer, and wrapping it further (e.g. `Result<T, DiagnosticBuilder>` w/ non-ZST `T`), ~~will probably see a slowdown~~, so I want to do a perf run before even trying to propose this.
2022-02-01 03:58:32 +00:00
bors
a6cd4aa9a7 Auto merge of #93386 - WaffleLapkin:rustc_must_implement_one_of_check_target, r=nagisa
Check that `#[rustc_must_implement_one_of]` is applied to a trait

`#[rustc_must_implement_one_of]` only makes sense when applied to a trait, so it's sensible to emit an error otherwise.
2022-02-01 00:50:28 +00:00
Tomasz Miąsko
22872e508f Validate that values in switch int terminator are unique 2022-02-01 00:00:00 +00:00
bors
745e926487 Auto merge of #93381 - tmiasko:is-self-recursive, r=ecstatic-morse
Check the number of arguments first in `is_recursive_call`
2022-01-31 21:16:17 +00:00
Fabian Wolff
95344c02fd Add FIXME comment 2022-01-31 20:34:26 +01:00
David Tolnay
6db97b35d8
Allow any line to have at least 60 chars 2022-01-31 10:56:57 -08:00