Skip to content

indicate origin of where type parameter for uninferred types #67277

Closed
@nikomatsakis

Description

@nikomatsakis
Contributor

Over in #65951, @estebank and I were discussing that we could improve the error message in cases like:

async fn foo() {
bar().await;
//~^ ERROR type inside `async fn` body must be known in this context
//~| NOTE cannot infer type for `T`
//~| NOTE the type is part of the `async fn` body because of this `await`
//~| NOTE in this expansion of desugaring of `await`
}

Presently, we say:

https://github.com/rust-lang/rust/blob/master/src/test/ui/async-await/unresolved_type_param.stderr#L1-L5

but this T we reference comes from the definition of bar:

async fn bar<T>() -> () {}

it'd be nice if we said "cannot infer value for type parameter T declared on the fn bar".

I believe that name comes from the TypeParameterDefinition information that we track as part of a type variable's origin:

if let TypeVariableOriginKind::TypeParameterDefinition(name) = var_origin.kind {
return (name.to_string(), Some(var_origin.span));
}

So we could do this by modifying that variant to track the DefId of the type parameter and then looking at the parent to derive the context.

This issue has been assigned to @ohadravid via this comment.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on Dec 13, 2019
nikomatsakis

nikomatsakis commented on Dec 13, 2019

@nikomatsakis
ContributorAuthor

I'm tagging this as E-mentor because it has some rough mentoring instructions. Feel free to reach out to me for help, too.

ohadravid

ohadravid commented on Dec 13, 2019

@ohadravid
Contributor

@rustbot claim

self-assigned this
on Dec 13, 2019
added 2 commits that reference this issue on Dec 15, 2019

Rollup merge of rust-lang#67285 - ohadravid:indicate-origin-of-where-…

3a94151

Rollup merge of rust-lang#67285 - ohadravid:indicate-origin-of-where-…

6cf51ad
added 2 commits that reference this issue on Dec 20, 2019

Rollup merge of rust-lang#67285 - ohadravid:indicate-origin-of-where-…

03169a9

Rollup merge of rust-lang#67285 - ohadravid:indicate-origin-of-where-…

403bb09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @nikomatsakis@ohadravid@rustbot

    Issue actions

      indicate origin of where type parameter for uninferred types · Issue #67277 · rust-lang/rust