Skip to content

Limit to specific package in workspace, also excluding its dependencies #3025

Closed

Description

@sanmai-NL

Running Clippy on a specific package in a workspace with cargo clippy -p package_in_workspace works, thanks to #2585. It appears, however, that this does not exclude dependency crates within the same workspace. So if these deps cause any Clippy errors, compilation will be aborted and the targeted package won’t be checked. That’s a hindrance for gradually resolving Clippy suggestions across a large code base in a workspace.

Activity

  1. oli-obk commented on Aug 13, 2018

    @oli-obk
    Contributor

    We're reusing cargo check infrastructure. Can you check whether cargo check has the same issue?

  2. sanmai-NL commented on Aug 13, 2018

    @sanmai-NL
    ContributorAuthor

    How could I best verify that? This suggests cargo check has the same issue, no?

    cargo check -p package_in_workspace_2
       Compiling syn v0.14.8                                                                                                                     
       Compiling serde_derive v1.0.71
        Checking package_in_workspace_1 v0.1.0 (file:///path/to/package_in_workspace_1)
        Checking package_in_workspace_2 v0.1.0 (file:///path/to/package_in_workspace_2)
        Finished dev [unoptimized + debuginfo] target(s) in 12.36s
    
  3. dotellie commented on Nov 11, 2018

    @dotellie

    Is this issue being worked on? We currently can't run clippy on Amethyst because we have dependencies using experimental clippy features.

    error[E0658]: scoped lint `clippy::len_without_is_empty` is experimental (see issue #44690)
       --> /home/ellie/.cargo/registry/src/github.com-1ecc6299db9ec823/slice-deque-0.1.14/src/lib.rs:136:9
        |
    136 |         clippy::len_without_is_empty,
        |
    

    ... is just an example of one of the many errors we get by default.

    If this is an unrelated error then I apologize but I would still be happy for someone to point me in the right direction 😅

  4. hcpl commented on Nov 12, 2018

    @hcpl

    @magnonellie I think you used clippy from stable which doesn't support clippy::lint syntax, only lint. Beta and nightly should support that now.

  5. mykmelez commented on Mar 29, 2019

    @mykmelez

    A workaround appears to be (assuming PACKAGE and PATH_TO_PACKAGE are set appropriately):

    cargo clean
    cargo check -p $PACKAGE
    touch $PATH_TO_PACKAGE/src/lib.rs
    cargo clippy -p $PACKAGE
    

    I would have thought this would work:

    cargo clean
    cargo check -p $PACKAGE
    cargo clean -p $PACKAGE
    cargo clippy -p $PACKAGE
    

    But clippy doesn't seem to check the package in that case (at least it doesn't warn me about any problems in it), even though cargo clean supposedly supports the -p flag.

  6. geigerzaehler commented on Oct 21, 2019

    @geigerzaehler

    cargo check suffers from the same problem. The problem is that cargo does not distinguish between local dependencies inside our outside of the workspace. For both --cap-lints=allow is not set like it is for remote dependencies. This results in cargo check complaining about all lints in local packages. See rust-lang/cargo#5998

  7. added
    C-bugCategory: Clippy is not doing the correct thing
    T-cargoType: cargo related
    on Apr 25, 2020
  8. added a commit that references this issue on Oct 22, 2020
    5139104
  9. added a commit that references this issue on Dec 9, 2020
    a2d9925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-cargoType: cargo related

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions