Stream: t-compiler/help

Topic: associated types in UFCS calls via HIR


Steven Fackler (Apr 06 2020 at 00:58, on Zulip):

Does anyone know what I'm doing wrong here trying to create a call to Future::poll in HIR? https://github.com/rust-lang/rust/commit/5eb7eed0300eaeca84aeab57b61c40369375874f

The synthesized code hits an error saying that the associated Output type needs to be specified:

error[E0191]: the value of the associated type `Output` (from trait `std::future::Future`) must be specified
  --> /home/sfackler/code/rust/src/test/ui/async-await/async-with-closure.rs:21:5
   |
LL |     get_future(messages).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `get_future(messages).await<Output = Type>`
eddyb (Apr 06 2020 at 01:12, on Zulip):

@Steven Fackler are you creating <Future>::poll or Future::poll?

eddyb (Apr 06 2020 at 01:13, on Zulip):

the former isn't what it looks like :P

eddyb (Apr 06 2020 at 01:13, on Zulip):

it's <dyn Future>::poll which is why it wants the associated type specified

Steven Fackler (Apr 06 2020 at 01:13, on Zulip):

Yeah, I want to be making Future::poll

eddyb (Apr 06 2020 at 01:13, on Zulip):

Future in Future::poll is like a module, not like a type

Steven Fackler (Apr 06 2020 at 01:14, on Zulip):

ah right I don't want QPath::TypeRelative

eddyb (Apr 06 2020 at 01:14, on Zulip):

so it's a regular path, not qualified at all (from the point of view of the compiler)

eddyb (Apr 06 2020 at 01:14, on Zulip):

right

eddyb (Apr 06 2020 at 01:15, on Zulip):

look at how Iterator::next is called for for loops and copy that, I guess?

Steven Fackler (Apr 06 2020 at 01:15, on Zulip):

ah yeah good call

Steven Fackler (Apr 06 2020 at 01:15, on Zulip):

thanks!

eddyb (Apr 06 2020 at 01:16, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/librustc_ast_lowering/expr.rs#L1091

eddyb (Apr 06 2020 at 01:16, on Zulip):

yeah so it just looks like a module path

Last update: Sep 28 2020 at 14:45UTC