Skip to content

Some feature wrongly considered invalid #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
clement-buchart opened this issue Jan 3, 2022 · 6 comments
Closed

Some feature wrongly considered invalid #14

clement-buchart opened this issue Jan 3, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@clement-buchart
Copy link

Hello,

Current behavior

Some features are considered invalid, but are in fact valid, and documented on the crate's doc.rs page.
For example :

  • the "uuidv07" of crate diesel v1.4.8
  • the "serde" feature of create uuid v0.8.2

Expected behavior

Features that are listed in docs.rs don't trigger an "Invalid feature" diagnostic

Additional context/Screenshots

image

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.

@clement-buchart clement-buchart added the bug Something isn't working label Jan 3, 2022
@saecki
Copy link
Owner

saecki commented Jan 4, 2022

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.

@saecki saecki mentioned this issue Jan 4, 2022
@saecki
Copy link
Owner

saecki commented Jan 4, 2022

For uuid there was a bug in parsing dependencies. That should be fixed by the linked PR.

@clement-buchart
Copy link
Author

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

@saecki
Copy link
Owner

saecki commented Jan 4, 2022

I think it's worth looking into this, since that would also allow a way to retrieve metadata for path- and git-dependencies.

@saecki
Copy link
Owner

saecki commented Jan 15, 2022

So I added a flag to disable invalid feature diagnostics until this is properly fixed.

@saecki
Copy link
Owner

saecki commented Dec 17, 2023

Linking rust-lang/crates.io#1539, just so I remember

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants