Stream: t-compiler/wg-rls-2.0

Topic: rust-analyzer lambda inference


Roland Kuhn (May 16 2020 at 08:11, on Zulip):

I really like rust-analyzer, it is fast and displays very helpful inline information. One area where it fails me (on nightly) is when using named functions in lambda positions, or when using a pattern in the argument list of a lambda — in those cases, the result type is {unknown}. Is there a ticket for this already or am I doing something unusual? (casual search didn’t reveal one, but there are so many tickets … )

stream
    .map(my_function) // this trips it up
    .map(|x, (a, b)| ... ) // this also
matklad (May 16 2020 at 08:17, on Zulip):

https://github.com/rust-analyzer/rust-analyzer/issues/4281

matklad (May 16 2020 at 08:17, on Zulip):

probably this

Roland Kuhn (May 16 2020 at 08:20, on Zulip):

Ah, right, that definitely looks like what I observed in the first case. Does it also cover the second or shall I open another issue?

matklad (May 16 2020 at 08:24, on Zulip):

I think the second is tripped up because of the first one?

matklad (May 16 2020 at 08:24, on Zulip):

oh, actually, let me check for patterns

Roland Kuhn (May 16 2020 at 08:25, on Zulip):

ah, no, it happens independently, I only wrote that up as a strawman

matklad (May 16 2020 at 08:25, on Zulip):

right, patterns do trip type inference up as well, I don't think we have an issue for that, if you create one with a minimal reproducible example (ideally, without using std), that would be helpful!

matklad (May 16 2020 at 08:25, on Zulip):

(there's also a chance that the issue already exist, but I don't recall one)

Roland Kuhn (May 16 2020 at 08:26, on Zulip):

okay, will try to minimize (of course this happens in our 30'000 LOC source, as always ;-) )

matklad (May 16 2020 at 08:29, on Zulip):

Another useful "small" yak-shave is implementing test-case minimizer :D

Roland Kuhn (May 16 2020 at 08:35, on Zulip):

I got it, submitting issue …

Roland Kuhn (May 16 2020 at 08:40, on Zulip):

https://github.com/rust-analyzer/rust-analyzer/issues/4476

Roland Kuhn (May 16 2020 at 08:40, on Zulip):

so it only happens when the closure takes arguments by reference

Last update: May 29 2020 at 17:50UTC