Skip to content
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

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

Closed
sanmai-NL opened this issue Aug 10, 2018 · 6 comments · Fixed by #6188
Closed

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

sanmai-NL opened this issue Aug 10, 2018 · 6 comments · Fixed by #6188
Labels
C-bug Category: Clippy is not doing the correct thing T-cargo Type: cargo related

Comments

@sanmai-NL
Copy link
Contributor

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.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 13, 2018

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

@sanmai-NL
Copy link
Contributor Author

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

@dotellie
Copy link

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.jparrowsec.cn-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 😅

@hcpl
Copy link

hcpl commented Nov 12, 2018

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

@mykmelez
Copy link

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.

@geigerzaehler
Copy link

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

@phansch phansch added C-bug Category: Clippy is not doing the correct thing T-cargo Type: cargo related labels Apr 25, 2020
bors added a commit that referenced this issue Oct 22, 2020
Add --no-deps option to avoid running on path dependencies in workspaces

Since rust-lang/cargo#8758 has hit nightly, this allows us to address the second bullet point and [the concern related to `--fix`](rust-lang/cargo#8143 (comment)) in the [RUSTC_WORKSPACE_WRAPPER tracking issue](rust-lang/cargo#8143).

As a reminder stabilizing that env var will solve #4612 (Clippy not running after `cargo check` in stable) and would allow to stabilize the `--fix` option in Clippy.

changelog: Add `--no-deps` option to avoid running on path dependencies in workspaces

Fixes #3025
@bors bors closed this as completed in a2d9925 Dec 9, 2020
Conzel added a commit to Conzel/zipnet that referenced this issue Nov 19, 2021
Clippy lints cannot be fixed by the packages that import the library
reiimplementations directly, this is a known problem.

See rust-lang/rust-clippy#3025.
Conzel added a commit to Conzel/zipnet that referenced this issue Mar 24, 2022
Clippy lints cannot be fixed by the packages that import the library
reiimplementations directly, this is a known problem.

See rust-lang/rust-clippy#3025.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing T-cargo Type: cargo related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants