Stream: t-compiler/wg-rls-2.0

Topic: Closures vs. function names type inference


Brennan Vincent (May 31 2020 at 17:46, on Zulip):

The type of x is correctly resolved as Option<Option<i32>>:

let x = iter::repeat(5).map(|x| Some(x)).next();

Whereas here, it can't be resolved:

let x = iter::repeat(5).map(Some).next();
Brennan Vincent (May 31 2020 at 17:46, on Zulip):

I'm not sure whether this is a known issue. I'm having trouble finding it in the GitHub issues.

Brennan Vincent (May 31 2020 at 17:47, on Zulip):

(Nothing special about enum constructors here; the same behavior holds with normal functions)

matklad (May 31 2020 at 17:47, on Zulip):

I think that would be https://github.com/rust-analyzer/rust-analyzer/issues/4281

Brennan Vincent (May 31 2020 at 17:49, on Zulip):

This is particularly bad for our codebase since we have a style guideline not to introduce unnecessary closures in cases like this. @matklad is this an easy fix that you could give me pointers to? I can try to do it if so.

matklad (May 31 2020 at 17:51, on Zulip):

I don't think this has an easy fix, it needs some groundwork on the chalk's side (see the linked chalk issues in the issue)

Brennan Vincent (May 31 2020 at 17:52, on Zulip):

Ok, thanks for letting me know.

Last update: Sep 27 2020 at 14:00UTC