Stream: t-compiler/rust-analyzer

Topic: rust-analyzer and features

guigui64 (May 05 2020 at 20:10, on Zulip):

Hi all, I'm using rust-analyzer on vim with coc.nvim (and the coc-rust-analyzer extension).

I have a lib crate (stybulate) in which I want to add a binary to use the lib as a command-line app.
Since I don't want people using my crate as a lib to have to compile the dependencies for the binary (structopt, anyhow etc.), I've created a feature called "build_binary" that is not in the default features and added this feature to the required-features of the [[bin]] section of my Cargo.toml.

Here is the content of my Cargo.toml file:

name = "stybulate"
version = "1.0.0"
authors = ["Guillaume Comte <>"]
edition = "2018"
license = "MIT OR Apache-2.0"
readme = ""
repository = ""
homepage = ""
description = "Tabulate with Style"
categories = ["command-line-interface"]
exclude = ["/.github/", "/scripts/"]

# See more keys and their definitions at

default = ["ansi_term_style"]
ansi_term_style = ["ansi_term"]
build_binary = ["anyhow", "structopt"]

strip-ansi-escapes = "0.1"
unicode-width = "0.1"
ansi_term = { version = "0.12", optional = true }
anyhow = { version = "1.0", optional = true }
structopt = { version = "0.3", optional = true }

name = "stybulate"
required-features = ["build_binary"]

Now, the issue is that rust-analyzer does not give diagnostics on the file and I suspect it is because it does not run cargo check with the --all-features flag. Am I right?
How can I enable the --all-features flag?

matklad (May 05 2020 at 20:13, on Zulip):

rust-analyzer.checkOnSave.extraArgs is the config name. Though, we probably should set --all-features by defaul

matklad (May 05 2020 at 20:22, on Zulip):

(if you want to send a PR, you need to look into flycheck crate ;) )

guigui64 (May 05 2020 at 20:24, on Zulip):

matklad said:

(if you want to send a PR, you need to look into flycheck crate ;) )

What ? I didn't find any crate with that name. I found an emacs extension with that name though...

matklad (May 05 2020 at 20:25, on Zulip):

yup, that't the origin of the name. that's a internal crate in rust-analyzer repo

guigui64 (May 05 2020 at 20:27, on Zulip):

Ok thanks, I will send a PR then

Last update: Jul 29 2021 at 08:00UTC