Some feature wrongly considered invalid
Hello,
Current behavior
Some features are considered invalid, but are in fact valid, and documented on the crate's doc.rs page. For example :
Expected behavior
Features that are listed in docs.rs don't trigger an "Invalid feature" diagnostic
Additional context/Screenshots

Neovim version
nvim --version
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Thanks for the great plugin. Cheers.
So the Cargo.toml of diesel looks like this:
[dependencies.uuid]
features = ["use_std"]
optional = true
version = ">=0.2.0, <0.7.0"
[dependencies.uuidv07]
optional = true
package = "uuid"
version = ">=0.7.0, <0.9.0"
but when fetching dependencies from crates.io all we get is:
{
"crate_id": "uuid",
"default_features": true,
"downloads": 0,
"features": [
"use_std"
],
"id": 2871490,
"kind": "normal",
"optional": true,
"req": ">=0.2.0, <0.7.0",
"target": null,
"version_id": 427827
},
{
"crate_id": "uuid",
"default_features": true,
"downloads": 0,
"features": [],
"id": 2871491,
"kind": "normal",
"optional": true,
"req": ">=0.7.0, <0.9.0",
"target": null,
"version_id": 427827
}
The dependency alias isn't accessible using the api.
I don't see an easy way to retrieve that information for now. Until I found some way to work around this I see two options:
- Don't push diagnostics for invalid features
- Live with false positives
It probably makes sense to let the user choose using a config flag called diagnostics.invalid_features.
And document why that is an option.
For uuid there was a bug in parsing dependencies. That should be fixed by the linked PR.
Thanks for looking into this. Can confirm the serde feature for uuid is OK now
For the diesel one, I don't know if that's actionable but one could get the optional dependencies out of the cargo metadata output as a way to filter out errors maybe :
❯ cargo metadata --format-version=1 | jq -r '.packages[] | select(.name=="diesel") | .dependencies[] | select((.optional==true) and (.rename != null and .rename != "")) | .rename'
uuidv07
I think it's worth looking into this, since that would also allow a way to retrieve metadata for path- and git-dependencies.
So I added a flag to disable invalid feature diagnostics until this is properly fixed.
Linking https://github.com/rust-lang/crates.io/issues/1539, just so I remember