Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit coercion suggestions in more places #67009

Merged
merged 2 commits into from
Dec 7, 2019

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Dec 4, 2019

Fixes #66910

We have several different kinds of suggestions we can try to make when
type coercion fails. However, we were previously only emitting these
suggestions from demand_coerce_diag. This resulted in the compiler
failing to emit applicable suggestions in several different cases, such
as when the implicit return value of a function had the wrong type.

This commit adds a new emit_coerce_suggestions method, which tries to
emit a number of related suggestions. This method is called from both
demand_coerce_diag and CoerceMany::coerce_inner, which covers a much
wider range of cases than before.

We now suggest using .await in more cases where it is applicable,
among other improvements.

I'm not happy about disabling the issue-59756, but from what I can tell, the suggestion infrastructure in rustc lacks any way of indicating mutually exclusive suggestions (and compiletest lacks a way to only apply a subset of available suggestions).

Fixes rust-lang#66910

We have several different kinds of suggestions we can try to make when
type coercion fails. However, we were previously only emitting these
suggestions from `demand_coerce_diag`. This resulted in the compiler
failing to emit applicable suggestions in several different cases, such
as when the implicit return value of a function had the wrong type.

This commit adds a new `emit_coerce_suggestions` method, which tries to
emit a number of related suggestions. This method is called from both
`demand_coerce_diag` and `CoerceMany::coerce_inner`, which covers a much
wider range of cases than before.

We now suggest using `.await` in more cases where it is applicable,
among other improvements.
Currently, rustfix has no notion of mutually exclusive suggestions. When
it processes issue-59756, it will attempt to apply two mutually
exclusive suggestions for the same span, causing an error.
@rust-highfive
Copy link
Collaborator

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 4, 2019
@Centril
Copy link
Contributor

Centril commented Dec 4, 2019

Seems like a clear improvement; r? @Centril @bors r+

@bors
Copy link
Contributor

bors commented Dec 4, 2019

📌 Commit a6883c0 has been approved by Centril

@rust-highfive rust-highfive assigned Centril and unassigned cramertj Dec 4, 2019
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 4, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 6, 2019
…Centril

Emit coercion suggestions in more places

Fixes rust-lang#66910

We have several different kinds of suggestions we can try to make when
type coercion fails. However, we were previously only emitting these
suggestions from `demand_coerce_diag`. This resulted in the compiler
failing to emit applicable suggestions in several different cases, such
as when the implicit return value of a function had the wrong type.

This commit adds a new `emit_coerce_suggestions` method, which tries to
emit a number of related suggestions. This method is called from both
`demand_coerce_diag` and `CoerceMany::coerce_inner`, which covers a much
wider range of cases than before.

We now suggest using `.await` in more cases where it is applicable,
among other improvements.

I'm not happy about disabling the `issue-59756`, but from what I can tell, the suggestion infrastructure in rustc lacks any way of indicating mutually exclusive suggestions (and compiletest lacks a way to only apply a subset of available suggestions).
bors added a commit that referenced this pull request Dec 6, 2019
Rollup of 10 pull requests

Successful merges:

 - #66606 (Add feature gate for mut refs in const fn)
 - #66841 (Add `{f32,f64}::approx_unchecked_to<Int>` unsafe methods)
 - #67009 (Emit coercion suggestions in more places)
 - #67052 (Ditch `parse_in_attr`)
 - #67071 (Do not ICE on closure typeck)
 - #67078 (accept union inside enum if not followed by identifier)
 - #67090 (Change "either" to "any" in Layout::from_size_align's docs)
 - #67092 (Fix comment typos in src/libcore/alloc.rs)
 - #67094 (get rid of __ in field names)
 - #67102 (Add note to src/ci/docker/README.md about multiple docker images)

Failed merges:

 - #67101 (use `#[allow(unused_attributes)]` to paper over incr.comp problem)

r? @ghost
@bors bors merged commit a6883c0 into rust-lang:master Dec 7, 2019
@Aaron1011 Aaron1011 deleted the fix/coerce-suggestion branch December 7, 2019 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slightly incorrect help message with mismatched typs in async code
5 participants