Stream: t-compiler/rust-analyzer

Topic: rust-analyzer does not work on most of libcore


Jonas Schievink [he/him] (Sep 06 2020 at 12:24, on Zulip):

libcore contains a lot of modules with #[cfg(not(test))] on them, but r-a analysis seems to happen with cfg(test) enabled, breaking it on most of libcore.

Is there any way around this? I'm assuming it's on by default to allow analysis in test modules

Jonas Schievink [he/him] (Sep 06 2020 at 12:31, on Zulip):

Luckily these cfgs don't seem to be actually necessary, so I can remove them for now

Jonas Schievink [he/him] (Sep 06 2020 at 12:31, on Zulip):

In my ideal world rust-analyzer would magically work with all cfg possibilities at the same time, but that's probably going to remain a pipe dream for the foreseeable future :)

bjorn3 (Sep 06 2020 at 12:33, on Zulip):

Jonas Schievink said:

Luckily these cfgs don't seem to be actually necessary, so I can remove them for now

They are necessary when testing I think, as otherwise things would conflict with the libcore included through libtest.

Jonas Schievink [he/him] (Sep 06 2020 at 12:39, on Zulip):

Doesn't look like it. The comments point to https://github.com/rust-lang/rust/issues/65860, which hasn't been done yet.

Jonas Schievink [he/him] (Sep 06 2020 at 15:08, on Zulip):

Opened https://github.com/rust-lang/rust/pull/76409, let's see if that works

woody77 (Sep 14 2020 at 22:34, on Zulip):

rust-analyzer, with a Cargo.toml project, will set test when it's processing sources (but not when processing the stdlib itself (as an injected dependency of the project).

You might have an easier time with RA in the stdlib if you generated a rust-project.json for it (where you can be really explicit about all of the folders and features).

Last update: Jul 26 2021 at 14:15UTC