Stream: t-compiler/wg-rls-2.0

Topic: Fun bug


matklad (Apr 18 2020 at 20:02, on Zulip):

image.png

Here, we somehow fail to resolve .enumerate() (because impl trait syntax is involved), but somehow we manage to correctly resolve the .map call. I don't know how to explain this :D

std::Veetaha (Apr 18 2020 at 20:24, on Zulip):

This is simple, Watson, idx type is deduced from usage.

matklad (Apr 18 2020 at 20:24, on Zulip):

But how is the .map type deduced?

std::Veetaha (Apr 18 2020 at 20:25, on Zulip):

From symbol index?

matklad (Apr 18 2020 at 20:25, on Zulip):

Like, the inlay hint says Map<{unknown}, |...| -> Ty>

matklad (Apr 18 2020 at 20:25, on Zulip):

Symbol index is not used during type inference. And I bet there are a bunch of maps

std::Veetaha (Apr 18 2020 at 20:28, on Zulip):

Bruh, isn't symbol index kinda the last resort? Maybe you are lucky to get exactly Iterator.map...

Florian Diebold (Apr 18 2020 at 22:50, on Zulip):

we find Iterator::map as a candidate, get an ambiguous result for the trait solving (because we don't have any self type / it's a variable), so we use it

Florian Diebold (Apr 18 2020 at 22:50, on Zulip):

during method resolution, it's enough if the self type may implement the trait

std::Veetaha (Apr 20 2020 at 18:44, on Zulip):

Fun fact: ra manages to infer the type where rustc bails...
Screenshot-from-2020-04-20-21-43-05.png

Florian Diebold (Apr 20 2020 at 19:06, on Zulip):

well, you might note it doesn't resolve contains, so it didn't infer the type at that point either

Florian Diebold (Apr 20 2020 at 19:07, on Zulip):

if we emitted diagnostics for this, we would as well at that point

Florian Diebold (Apr 20 2020 at 19:08, on Zulip):

both RA and rustc continue afterwards and find out the type, but by then it's too late

Florian Diebold (Apr 20 2020 at 19:10, on Zulip):

you might actually be able to see that by doing something like let () = is_derive_registrar_symbol; later, though rustc might be too smart about emitting type errors when there were errors further up, not sure

Florian Diebold (Apr 20 2020 at 19:10, on Zulip):

we could totally offer a quick fix for this though :thinking:

Florian Diebold (Apr 20 2020 at 19:11, on Zulip):

in fact the assist for it already exists, doesn't it

Last update: May 29 2020 at 17:55UTC