Stream: t-compiler/rust-analyzer

Topic: sysroot dependencies

Florian Diebold (Jun 13 2019 at 19:50, on Zulip):

So, I found the reason why we don't find the impl<T> Deref for Arc<T> -- we can't resolve core::ops::Deref from alloc because we don't have a dependency from alloc to core. We currently only have dependencies from std to other crates in the sysroot. I assume this is just an oversight? I'll try hard-coding the alloc -> core dependency as well and see what happens.

matklad (Jun 13 2019 at 21:00, on Zulip):

Yeah, that's an oversight. The question is, how we should infer the dependencies? I'd say just hard-coding them would be good enough: we did that in IntelliJ, and, while ocassionally this was annoying when the sysroot was restructured, in general its a low-maintainance thing

Florian Diebold (Jun 13 2019 at 21:04, on Zulip):

how does rustc actually know the dependencies? does cargo pass them to it somehow?

matklad (Jun 13 2019 at 21:15, on Zulip):

I think sysroot crates use extern crate. So, rustc sees extern crate foo and looks for foo in sysroot

matklad (Jun 13 2019 at 21:15, on Zulip):

in other words, the deps are sort-of ambiently defined

matklad (Jun 13 2019 at 21:16, on Zulip):

To faithully mimic it, we must add something like sysroot: FxHashMap<Name, Crate> to CrateGraph. But I think that sysroot concept is not really necessary, and I prefer to just expliceitelly list what depends on what

Florian Diebold (Jun 13 2019 at 21:41, on Zulip):

oh, right... yeah, I agree then

Florian Diebold (Jun 13 2019 at 21:42, on Zulip):

though it might be not too hard to write a tool which automatically outputs the dependencies in the sysroot :thinking:

matklad (Jun 13 2019 at 21:44, on Zulip):

Yeah, I think one even can perhaps run cargo metadata in rustc and extract that info. Altenatively, one can copy-paste from :D

simulacrum (Jun 14 2019 at 00:45, on Zulip):

FWIW sysroot deps will hopefully soon be in dep-info

simulacrum (Jun 14 2019 at 00:46, on Zulip):

w/o sysroot you don't really get to "just compile" crates that depend on alloc/std/core/proc_macro unless you explicitly always give crates access to them

simulacrum (Jun 14 2019 at 00:46, on Zulip):

at least in the rustc model

Last update: Jul 24 2021 at 21:15UTC