Stream: t-compiler/rust-analyzer

Topic: Field resolution error


Jonas Schievink [he/him] (Feb 09 2021 at 16:56, on Zulip):

Hmm, is this a new bug? screenshot-2021-02-09-175322.png

Jonas Schievink [he/him] (Feb 09 2021 at 16:56, on Zulip):

block does show up in autocomplete

Laurențiu (Feb 09 2021 at 17:04, on Zulip):

Not completely new, at least:

image.png

Laurențiu (Feb 09 2021 at 17:05, on Zulip):

But it doesn't show up in autocomplete for me.

Florian Diebold (Feb 09 2021 at 18:05, on Zulip):

does this actually compile? I'd guess the type of def_map isn't known when you're doing def_map.block. it's inferred later, but too late for the field access

Jonas Schievink [he/him] (Feb 09 2021 at 18:06, on Zulip):

This was reduced from code in nameres, which does compile

Jonas Schievink [he/him] (Feb 09 2021 at 18:08, on Zulip):

Specifically this place: https://github.com/rust-analyzer/rust-analyzer/blob/98b82859551555a1b0671c75307d56a17aa545b6/crates/hir_def/src/nameres/collector.rs#L1455

Florian Diebold (Feb 09 2021 at 18:08, on Zulip):

that's a bit too reduced then, I think

Jonas Schievink [he/him] (Feb 09 2021 at 18:08, on Zulip):

and also fn crate_root in nameres.rs

Jonas Schievink [he/him] (Feb 09 2021 at 18:09, on Zulip):

They both use with_ancestor_maps, maybe that's the culprit

Florian Diebold (Feb 09 2021 at 18:14, on Zulip):

for some reason solving <&DefMap as Index<Idx<ModuleData>>>::Output seems to fail

Florian Diebold (Feb 09 2021 at 18:15, on Zulip):

even though it seems to work in other places

Florian Diebold (Feb 09 2021 at 18:16, on Zulip):

hmm no annotating the map parameter as &DefMap fixes it, so it's probably a closure inference problem after all

Florian Diebold (Feb 09 2021 at 18:18, on Zulip):

making the closure an impl instead of dyn fixes it

Florian Diebold (Feb 09 2021 at 18:21, on Zulip):

hmm ah yeah I think we just don't really handle unifying types with dyn types, and mostly it doesn't matter, but here it does

Florian Diebold (Feb 09 2021 at 18:21, on Zulip):

this will probably only be fixed by switching to Chalk types completely and using their unification code

Jonas Schievink [he/him] (Feb 09 2021 at 18:40, on Zulip):

ah, I see

Jonas Schievink [he/him] (Feb 09 2021 at 18:41, on Zulip):

I was afraid this was related to inner item handling since I noticed it during that time

Last update: Jul 29 2021 at 22:00UTC