Commit graph

1406 commits

Author SHA1 Message Date
bors
0157cc977f Auto merge of #89534 - camsteffen:diag-name, r=oli-obk
Introduce `tcx.get_diagnostic_name`

Introduces a "reverse lookup" for diagnostic items. This is mainly intended for `@rust-lang/clippy` which often does a long series of `is_diagnostic_item` calls for the same `DefId`.

r? `@oli-obk`
2021-10-07 14:22:16 +00:00
Manish Goregaokar
f5bfa3450a
Rollup merge of #89528 - FabianWolff:issue-89497, r=jackh726
Fix suggestion to borrow when casting from pointer to reference

Fixes #89497.
2021-10-06 12:33:21 -07:00
Cameron Steffen
b6cab80c18 Use get_diagnostic_name 2021-10-06 13:10:08 -05:00
Cameron Steffen
33b9b95305 Introduce get_diagnostic_name 2021-10-06 08:40:28 -05:00
bors
d7539a6af0 Auto merge of #89323 - estebank:derive-binop, r=petrochenkov
Consider unfulfilled obligations in binop errors

When encountering a binop where the types would have been accepted, if
all the predicates had been fulfilled, include information about the
predicates and suggest appropriate `#[derive]`s if possible.

Fix #84515.
2021-10-06 06:20:25 +00:00
Esteban Kuber
e8fc076f23 Consider unfulfilled obligations in binop errors
When encountering a binop where the types would have been accepted, if
all the predicates had been fulfilled, include information about the
predicates and suggest appropriate `#[derive]`s if possible.

Point at trait(s) that needs to be `impl`emented.
2021-10-05 23:34:13 +00:00
Manish Goregaokar
960e49e89b
Rollup merge of #88706 - ThePuzzlemaker:issue-88609, r=jackh726
Normalize associated type projections when checking return type of main

This fixes #88609.

Previously, the return type of `fn main()` would not have any associated type projections within normalized before checking if it implements the standard library trait `std::process::Termination`. This commit appears to fix it.

This feels vaguely symptomatic of a problem in the underlying trait solving engine, but I am not sure how I would solve that. I am unsure why the example in #88609 with `assert_impl_termination` and `fn foo()` work, but simply `fn main()` doesn't. The way that I solved this is also probably not the best way to do this, so please let me know if there is a better way to do this.

I have added a build-pass regression test for this issue.
2021-10-05 12:52:41 -07:00
Manish Goregaokar
04314a6061
Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett
Follow the diagnostic output style guide

Detected by #89455.
2021-10-04 23:56:23 -07:00
Manish Goregaokar
87f782ede6
Rollup merge of #89423 - DevinR528:reachable-fields, r=Nadrieril
Fix ICE caused by non_exaustive_omitted_patterns struct lint

fixes #89382

Add check that a list of `Pat`s is non empty to prevent ICE in `FnCtxt::lint_non_exhaustive_omitted_patterns`.

Is related to #89374 and #89105
2021-10-04 23:56:20 -07:00
Jubilee
05b4cd6789
Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis
Correctly handle supertraits for min_specialization

Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.

r? ````@nikomatsakis````
2021-10-04 21:12:35 -07:00
Jubilee
4f6afee4e5
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
Perform type inference in range pattern

Fix #88074
2021-10-04 21:12:33 -07:00
Jubilee
2bc89ce0bf
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisa
Consistently use 'supertrait'.

A subset of places referred to 'super-trait', so this changes them
to all use 'supertrait'. This matches 'supertype' and some other
usages. An exception is 'auto-trait' which is consistently used
in that manner.
2021-10-04 13:58:14 -07:00
Jubilee
a2c6075dff
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Fix an ICE caused by type mismatch errors being ignored

This PR fixes #87771. It turns out that the check on `compiler/rustc_typeck/src/check/demand.rs:148` leads to the ICE. I removed it because the early return in [`check_expr_assign`](dec7fc3ced/compiler/rustc_typeck/src/check/expr.rs (L928)) already prevents unnecessary error messages from the call to `check_expr_coercable_to_type`.
2021-10-04 13:58:07 -07:00
Fabian Wolff
388bcc1cb0 Fix suggestion to borrow when casting from pointer to reference 2021-10-04 21:15:02 +02:00
bors
e737694a4d Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`
2021-10-03 21:44:10 +00:00
Hirochika Matsumoto
fb0b1a5466 Follow the diagnostic output style guide 2021-10-03 14:28:39 +09:00
Cameron Steffen
eec856bfbc Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
Cameron Steffen
67ea84d97a Add desugaring mark to while loop 2021-10-02 17:41:14 -05:00
Devin Ragotzy
b06409ebcd Rename etc -> has_rest_pat 2021-10-02 17:51:31 -04:00
Devin Ragotzy
f7a8980347 Reorder etc check for non_exhaustive_omitted_patterns 2021-10-02 17:50:53 -04:00
Devin Ragotzy
8cbcc893a6 Fix ICE caused by non_exaustive_omitted_patterns struct lint 2021-10-02 17:50:53 -04:00
bors
b27661eb33 Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillot
Fix clippy lints

I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.
2021-10-02 10:52:09 +00:00
Bruce Mitchener
058a21d5cf Consistently use 'supertrait'.
A subset of places referred to 'super-trait', so this changes them
to all use 'supertrait'. This matches 'supertype' and some other
usages. An exception is 'auto-trait' which is consistently used
in that manner.
2021-10-02 08:05:44 +07:00
Guillaume Gomez
759eba0a08 Fix clippy lints 2021-10-01 23:17:19 +02:00
bors
c02371c442 Auto merge of #88880 - cjgillot:no-krate, r=oli-obk
Rework HIR API to make invocations of the hir_crate query harder.

`hir_crate` forces the recomputation of queries that depend on it.

This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
2021-10-01 20:06:34 +00:00
Manish Goregaokar
1708219940
Rollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebank
feat(rustc_parse): recover from pre-RFC-2000 const generics syntax

Fixes #89013
2021-10-01 09:18:17 -07:00
Manish Goregaokar
e77d163e82
Rollup merge of #89251 - estebank:negative-index-literals, r=davidtwco
Detect when negative literal indices are used and suggest appropriate code
2021-09-30 23:41:06 -07:00
Manish Goregaokar
b437be45ea
Rollup merge of #89202 - estebank:infer-call-type, r=oli-obk
Resolve infered types when complaining about unexpected call type

```
error[E0618]: expected function, found `{integer}`
  --> $DIR/call-block.rs:2:13
   |
LL |     let _ = {42}();
   |             ^^^^--
   |             |
   |             call expression requires function
```
instead of
```
error[E0618]: expected function, found `_`
  --> $DIR/call-block.rs:2:13
   |
LL |     let _ = {42}();
   |             ^^^^--
   |             |
   |             call expression requires function
```
2021-09-30 18:05:21 -07:00
Matthew Jasper
c8f86cad2d Elaborate predicates in min_specialization checks
Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.
2021-09-30 21:42:09 +01:00
bors
aa7aca3b95 Auto merge of #89282 - sexxi-goose:fix-88118, r=nikomatsakis
2229: Consume IfLet expr

When using the IfLet guard feature, we can ICE when attempting to resolve PlaceBuilders.
For pattern matching, we currently don't consume the IfLet expression when "visiting" the arms leading us to not "read" all variables and hence not being able to resolve them.

r? `@nikomatsakis`
Closes https://github.com/rust-lang/rust/issues/88118
2021-09-30 20:23:47 +00:00
bors
69c1c6a173 Auto merge of #89250 - Aaron1011:keep-bound-region-names, r=estebank
Don't anonymize bound region names during typeck

Once this anonymization has performed, we have no
way of recovering the original names during NLL
borrow checking. Keeping the original names allows
error messages in full NLL mode to contain the original
bound region names.

As a result, the typeck results may contain types that
differ only in the names used for their bound regions. However,
anonimization of bound regions does not guarantee that
all distinct types are unqual (e.g. not subtypes of each other).
For example, `for<'a> fn(&'a u32, &'a u32)` and
`for<'b, 'c> fn(&'b u32, &'c u32)` are subtypes of each other,
as explained here:

63cc2bb3d0/compiler/rustc_infer/src/infer/nll_relate/mod.rs (L682-L690)

Therefore, any code handling types with higher-ranked regions already
needs to handle the case where two distinct `Ty`s are 'actually'
equal.
2021-09-30 07:33:59 +00:00
Camille GILLOT
abc57f63ad Move body_owners to tcx.hir(). 2021-09-29 23:16:48 +02:00
Camille GILLOT
db9fea508a Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
bors
50f9f7810c Auto merge of #89331 - GuillaumeGomez:rollup-b10unye, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #87260 (Libgccjit codegen)
 - #89212 (x.py: run `rustup toolchain link` in setup)
 - #89233 (Hide `<...> defined here` note if the source is not available)
 - #89235 (make junit output more consistent with default format)
 - #89255 (Fix incorrect disambiguation suggestion for associated items)
 - #89276 (Fix the population of the `union.impls` field)
 - #89283 (Add regression test for issue #83564)
 - #89318 (rustc_session: Remove lint store from `Session`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-29 10:39:41 +00:00
Michael Howell
105b60f250 feat(rustc_typeck): avoid erroring with "wrong number of generics" if there's other problems
As shown in the two test requirements that got updated, if there's other problems,
then those other problems are probably the root cause of the incorrect generics count.
2021-09-28 15:56:45 -07:00
Guillaume Gomez
48b5d110ae
Rollup merge of #89255 - FabianWolff:issue-88806, r=cjgillot
Fix incorrect disambiguation suggestion for associated items

Fixes #88806. I have not added a new test case, because the erroneous behavior is already present in existing test cases.
2021-09-28 20:00:16 +02:00
Guillaume Gomez
3c60e040b2
Rollup merge of #89233 - FabianWolff:issue-89159, r=estebank
Hide `<...> defined here` note if the source is not available

Fixes #89159. Similar to #87088.

r? ``@estebank``
2021-09-28 20:00:14 +02:00
Esteban Kuber
e19d82f1bf review comments 2021-09-28 16:13:39 +00:00
Oli Scherer
9b5aa063d8 More tracing instrumentation 2021-09-28 12:28:22 +00:00
Roxane
87010206ad 2229: Consume IfLet expr 2021-09-26 15:52:02 -04:00
Esteban Kuber
5c70f25f8c Detect when negative literal indices are used and suggest appropriate code 2021-09-26 16:52:10 +00:00
Fabian Wolff
3d08ff1c19 Fix incorrect disambiguation suggestion for associated items 2021-09-25 21:47:33 +02:00
Aaron Hill
78013f296a
Don't anonymize bound region names during typeck
Once this anonymization has performed, we have no
way of recovering the original names during NLL
borrow checking. Keeping the original names allows
error messages in full NLL mode to contain the original
bound region names.

As a result, the typeck results may contain types that
differ only in the names used for their bound regions. However,
anonimization of bound regions does not guarantee that
all distinct types are unqual (e.g. not subtypes of each other).
For example, `for<'a> fn(&'a u32, &'a u32)` and
`for<'b, 'c> fn(&'b u32, &'c u32)` are subtypes of each other,
as explained here:

63cc2bb3d0/compiler/rustc_infer/src/infer/nll_relate/mod.rs (L682-L690)

Therefore, any code handling types with higher-ranked regions already
needs to handle the case where two distinct `Ty`s are 'actually'
equal.
2021-09-25 13:04:00 -05:00
bors
6867dd2c01 Auto merge of #89230 - workingjubilee:rollup-1swktdq, r=workingjubilee
Rollup of 8 pull requests

Successful merges:

 - #88893 (Add 1.56.0 release notes)
 - #89001 (Be explicit about using Binder::dummy)
 - #89072 (Avoid a couple of Symbol::as_str calls in cg_llvm )
 - #89104 (Simplify scoped_thread)
 - #89208 ([rfc 2229] Drop fully captured upvars in the same order as the regular drop code)
 - #89210 (Add missing time complexities to linked_list.rs)
 - #89217 (Enable "generate-link-to-definition" option on rust tools docs as well)
 - #89221 (Give better error for `macro_rules! name!`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-25 00:20:28 +00:00
Fabian Wolff
911ced003a Hide <...> defined here note if the source is not available 2021-09-24 22:42:05 +02:00
Jubilee
7ade6ed48e
Rollup merge of #89208 - wesleywiser:rfc_2229_droporder, r=nikomatsakis
[rfc 2229] Drop fully captured upvars in the same order as the regular drop code

Currently, with the new 2021 edition, if a closure captures all of the
fields of an upvar, we'll drop those fields in the order they are used
within the closure instead of the normal drop order (the definition
order of the fields in the type).

This changes that so we sort the captured fields by the definition order
which causes them to drop in that same order as well.

Fixes rust-lang/project-rfc-2229#42

r? `@nikomatsakis`
2021-09-24 11:40:14 -07:00
Jubilee
ee2e97c416
Rollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis
Be explicit about using Binder::dummy

This is somewhat of a late followup to the binder refactor PR. It removes `ToPredicate` and `ToPolyTraitImpls` that hide the use of `Binder::dummy`. While this does make code a bit more verbose, it allows us be more careful about where we create binders.

Another alternative here might be to add a new trait `ToBinder` or something with a `dummy()` fn. Which could still allow grepping but allows doing something like `trait_ref.dummy()` (but I also wonder if longer-term, it would be better to be even more explicit with a `bind_with_vars(ty::List::empty())` *but* that's not clear yet.

r? ``@nikomatsakis``
2021-09-24 11:40:11 -07:00
Fabian Wolff
cb6c13977a Make error message for malformed fn/fn_mut lang item more specific 2021-09-24 20:15:19 +02:00
Fabian Wolff
4337089098 Add basic checks for well-formedness of fn/fn_mut lang items 2021-09-24 18:26:27 +02:00
Wesley Wiser
389365631d Fix tidy and respond to some feedback 2021-09-23 22:15:12 -04:00