Stream: t-compiler/wg-rls-2.0

Topic: Find out if a `CrateId` is from crates.io/sysroot


Jonas Schievink (Jul 01 2020 at 11:25, on Zulip):

When I have a FileId, I can query the owning SourceRoot, which knows whether it's "static" (from crates.io/sysroot) via is_library. Is there a way to get the same info when I only have a CrateId/CrateData and no SourceDatabaseExt (since I'm in ra_hir_ty)?

matklad (Jul 01 2020 at 11:37, on Zulip):

The answer is that you shouldn't be asking such questions :-)

matklad (Jul 01 2020 at 11:38, on Zulip):

Why do you need this info?

matklad (Jul 01 2020 at 11:38, on Zulip):

More seriously, the Ext setup is specifically so that the compiler doesn't know too much

Jonas Schievink (Jul 01 2020 at 11:39, on Zulip):

As an optimization. I want to generate a small-and-expensive-to-recompute index for static crates, and a heavy-but-fast-to-recompute index for workspace crates.

matklad (Jul 01 2020 at 11:40, on Zulip):

Index here is ImportMap?

Jonas Schievink (Jul 01 2020 at 11:41, on Zulip):

No, something like CrateImplDefs, an index of impls

matklad (Jul 01 2020 at 11:43, on Zulip):

Uhu.... At the moment, our model definitely doesn't allow for that. I am not sure if it should -- seems like this would inevitably add two different code paths, which would need to be unified

Jonas Schievink (Jul 01 2020 at 11:43, on Zulip):

ImportMap is only consulted for direct dependencies, while for impls we have to look at all transitive deps

matklad (Jul 01 2020 at 11:44, on Zulip):

Do you think that a call might be helpful?

Jonas Schievink (Jul 01 2020 at 11:46, on Zulip):

Yeah, that might help

matklad (Jul 01 2020 at 12:17, on Zulip):

Conclusion: impls_from_deps_query is only directly called for leaf crates, so we can maybe speed it up by first computing an FxHashSet<CrateId> transitive closure of dep crates, and then invoking non-transiive version of the query.

matklad (Jul 01 2020 at 12:19, on Zulip):

A futher optimization would create a query for transitive closure / self. That way, we'll have to do only two hashmap lookups (local crate/some dep), but we won't have to recompure the closure for deps on modifications

Last update: Sep 27 2020 at 13:45UTC