-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Point at method call when type annotations are needed #65951
Changes from 1 commit
12af256
252773a
cca4b6d
33b0636
6b76d82
5d1adbb
2924d38
cc1ab3d
860c7e4
94ab9ec
45550ef
da023c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ async fn bar<T>() -> () {} | |
async fn foo() { | ||
bar().await; | ||
//~^ ERROR type inside `async fn` body must be known in this context | ||
//~| NOTE cannot infer type for `T` | ||
//~| NOTE cannot infer type for type parameter `T` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @estebank do you think it's possible/desirable for us to say "type parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is desirable, but not trivial to accomplish at the moment. The only way I can see of relating a type param and where it came from is with judicious use of a visitor, which I believe will require enough tweaking that would push this PR to not land in the next beta. I can certainly follow up on that. Note that neither this change or that one will address the cases where we say "cannot infer type 🤷" and nothing else. |
||
//~| NOTE the type is part of the `async fn` body because of this `await` | ||
//~| NOTE in this expansion of desugaring of `await` | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
trait T { | ||
type A; | ||
fn foo(&self) -> Self::A { | ||
panic!() | ||
} | ||
} | ||
|
||
struct S<X>(std::marker::PhantomData<X>); | ||
|
||
impl<X> T for S<X> { | ||
type A = X; | ||
} | ||
|
||
fn main() { | ||
S(std::marker::PhantomData).foo(); //~ ERROR type annotations needed | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @estebank if we wanted to say more about where the type parameter came from, we would augment this enum with the
DefId
of the parameter instead of its name (I imagine we can extract the name -- as well as the context -- from thatDefId
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #67277 to track this