Commit Graph

698 Commits

Author SHA1 Message Date
bors
e40d5e83dc Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebank
rewrite error handling for unresolved inference vars

Pretty much completely rewrites `fn emit_inference_failure_err`.

This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments.
Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs.

r? `@estebank` `@petrochenkov`
2022-06-03 12:37:16 +00:00
Dylan DPC
5c041f98fa
Rollup merge of #97023 - cjgillot:uniform-anon, r=estebank
Diagnose anonymous lifetimes errors more uniformly between async and regular fns

Async fns and regular fns are desugared differently.  For the former, we create a generic parameter at HIR level.  For the latter, we just create an anonymous region for typeck.

I plan to migrate regular fns to the async fn desugaring.

Before that, this PR attempts to merge the diagnostics for both cases.

r? ```@estebank```
2022-06-02 11:13:22 +02:00
lcnr
681736a6b2 generic_arg_contains_target: ignore closures 2022-06-02 10:19:15 +02:00
lcnr
69d575e58d eagerly fetch the typeck_results 2022-06-02 10:19:15 +02:00
lcnr
bc0d12cc6c use verbose suggestions 2022-06-02 10:19:15 +02:00
lcnr
3fe346e7a3 add new emit_inference_failure_err 2022-06-02 10:19:15 +02:00
lcnr
721fc73208 remove the old emit_inference_failure_err 2022-06-02 10:19:15 +02:00
Dylan DPC
65bdfe3b41
Rollup merge of #97531 - compiler-errors:for-loop-pat-mismatch, r=davidtwco
Note pattern mismatch coming from `for` loop desugaring

Fixes #97163
2022-05-30 14:33:52 +02:00
Michael Goulet
2e25c2346b Note pattern mismatch coming from for-loop desugaring 2022-05-29 13:01:59 -07:00
bors
bef2b7cd1c Auto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbini
Finish bumping stage0

It looks like the last time had left some remaining cfg's -- which made me think
that the stage0 bump was actually successful. This brings us to a released 1.62
beta though.

This now brings us to cfg-clean, with the exception of check-cfg-features in bootstrap;
I'd prefer to leave that for a separate PR at this time since it's likely to be more tricky.

cc https://github.com/rust-lang/rust/pull/97147#issuecomment-1132845061

r? `@pietroalbini`
2022-05-29 16:28:21 +00:00
Camille GILLOT
3162b33ce5 Handle anonymous lifetimes properly in diagnostics. 2022-05-29 12:16:09 +02:00
Camille GILLOT
da175c743c Make lifetime errors more precise in the presence of Fresh lifetimes. 2022-05-29 12:16:09 +02:00
Mark Rousskov
b454991ac4 Finish bumping stage0
It looks like the last time had left some remaining cfg's -- which made me think
that the stage0 bump was actually successful. This brings us to a released 1.62
beta though.
2022-05-27 07:36:17 -04:00
b-naber
5f65331b3e suggest constraining dyn trait in impl in NLL 2022-05-25 18:13:17 +02:00
b-naber
c1072d2a9a make TraitObject visitors public 2022-05-25 18:13:16 +02:00
Dylan DPC
f4bf64c3f0
Rollup merge of #97292 - compiler-errors:tcxify-rustc, r=davidtwco
Lifetime variance fixes for rustc

#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime.

This is doable, since many lifetimes are already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from #97287 so the compiler team can review independently.
2022-05-23 15:11:04 +02:00
Michael Goulet
1784634a39 Lifetime variance fixes for rustc 2022-05-22 14:29:32 -07:00
Jack Huey
683a9c8391 Do leak check after function ptr coercion 2022-05-22 11:18:36 -04:00
Matthias Krüger
76f662c963
Rollup merge of #97109 - TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk
Fix misleading `cannot infer type for type parameter` error

closes #93198
2022-05-20 19:54:39 +02:00
Takayuki Maeda
3d0f9fb544 report ambiguous type parameters when their parents are impl or fn
fix ci error

emit err for `impl_item`
2022-05-20 23:04:44 +09:00
lcnr
4fcf43f67c update comments 2022-05-20 11:49:29 +02:00
Yuki Okushi
13ee094260
Rollup merge of #97080 - lcnr:relate-sus, r=oli-obk
remove the `RelateResultCompare` trait

it's unused
2022-05-17 19:01:33 +09:00
Takayuki Maeda
910979a6d4 fix misleading cannot infer type for type parameter error 2022-05-17 17:34:58 +09:00
bors
c1d65eaa45 Auto merge of #96892 - oli-obk:🐌_obligation_cause_code_🐌, r=estebank
Clean up derived obligation creation

r? `@estebank`

working on fixing the perf regression from https://github.com/rust-lang/rust/pull/91030#issuecomment-1083360210
2022-05-17 01:46:25 +00:00
lcnr
0ea7301fa3 remove the RelateResultCompare trait 2022-05-16 15:41:05 +02:00
bors
2a8a0fc423 Auto merge of #96883 - jackh726:early-binder-2, r=oli-obk
Add EarlyBinder

Chalk has no concept of `Param` (e0ade19d13/chalk-ir/src/lib.rs (L579)) or `ReEarlyBound` (e0ade19d13/chalk-ir/src/lib.rs (L1308)). Everything  is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk.

Either way, tracking when we have or haven't already substituted out these in rustc can be helpful.

As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted.

r? `@nikomatsakis`
2022-05-14 23:53:11 +00:00
Jack Huey
91afd02632 Add bound_explicit_item_bounds and bound_item_bounds 2022-05-14 10:16:49 -04:00
Jack Huey
6c05e8d009 Add bound_fn_sig 2022-05-13 18:27:40 -04:00
Jack Huey
c92248ab9f Add bound_type_of 2022-05-13 18:27:18 -04:00
Takayuki Maeda
daeec7e22d stop suggesting non-existing fully qualified paths 2022-05-11 19:18:02 +09:00
Jack Huey
319575ae8c Introduce EarlyBinder 2022-05-10 22:47:18 -04:00
Oli Scherer
05a62c5527 Remove clone_code method 2022-05-10 10:42:29 +00:00
Oli Scherer
704bbe5210 Move an extension trait method onto the type directly and reuse it 2022-05-10 09:26:09 +00:00
bors
030c886c29 Auto merge of #96155 - jackh726:param-heuristics-followup, r=estebank
Followups for method call error change

Each commit is self-contained. Fixes most of the followup reviews from that PR.

r? `@estebank`
2022-05-08 04:05:36 +00:00
bors
574830f573 Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07 06:30:29 +00:00
Jack Huey
62d0e4cba9 Resolve vars in note_type_err 2022-05-06 23:35:42 -04:00
Takayuki Maeda
857eb02abe suggest fully qualified path with appropriate params 2022-05-06 23:14:11 +09:00
Josh Triplett
0fc5c524f5 Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
Elliot Roberts
7907385999 fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
Vadim Petrochenkov
5b5964f569 rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03:00
bors
7c4b476969 Auto merge of #96347 - estebank:issue-96292, r=compiler-errors
Erase type params when suggesting fully qualified path

When suggesting the use of a fully qualified path for a method call that
is ambiguous because it has multiple candidates, erase type params in
the resulting code, as they would result in an error when applied. We
replace them with `_` in the output to rely on inference. There might be
cases where this still produces slighlty incomplete suggestions, but it
otherwise produces many more errors in relatively common cases.

Fix #96292
2022-04-30 18:44:01 +00:00
Camille GILLOT
94449e6101 Store all generic bounds as where predicates. 2022-04-30 13:55:13 +02:00
Camille GILLOT
05b29f9a92 Inline WhereClause into Generics. 2022-04-30 13:51:49 +02:00
David Wood
73fa217bc1 errors: span_suggestion takes impl ToString
Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:05:20 +01:00
Dylan DPC
cbfbc3be7d
Rollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime-suggestion, r=jackh726
Recover suggestions to introduce named lifetime under NLL

Fixes #96157

r? ```@jackh726```

Built on top of #96385 so only the second commit is relevant
2022-04-28 20:13:01 +02:00
Dylan DPC
4c628bbb1c
Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnr
replace let else with `?`

r? `@oli-obk`
2022-04-28 02:40:36 +02:00
marmeladema
2c94218238 Recover suggestions to introduce named lifetime under NLL 2022-04-27 22:36:40 +02:00
Ellen
f697955c1e tut tut tut 2022-04-27 08:51:33 +01:00
marmeladema
e1b074a2a8 Recover most impl Trait and dyn Trait lifetime bound suggestions under NLL 2022-04-25 09:14:44 +02:00
marmeladema
7b0db3e7c8 Improve span for consider adding an explicit lifetime bound suggestions under NLL
Because NLL borrowck is run after typeck, `in_progress_typeck_results`
was always `None` which was preventing the retrieval of the span to which
the suggestion is suppose to add the lifetime bound.

We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure`
so that under NLL, we give the owner id of the current body.
2022-04-24 09:34:50 +02:00