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

cargo lints: clippy dumps cargo metadata errors/warnigs into stderr #6508

Open
matthiaskrgr opened this issue Dec 27, 2020 · 1 comment
Open
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@matthiaskrgr
Copy link
Member

I noticed this by checking syn-1.0.54 downloaded from crates.io.

When I run cargo clippy -- --cap-lints warn -Wclippy::cargo, it looks like there is output leaking from cargo-metadata into the clippy warning such as the "warning: could not read ... Downloading crates.." stuff.

   Compiling proc-macro2 v1.0.24
    Checking unicode-xid v0.2.1
   Compiling syn v1.0.54 (/home/matthias/vcs/github/rust-clippy/target/crater/crates/syn-1.0.54)
warning: package `syn` is missing `package.keywords` metadata
  |
  = note: `-W clippy::cargo-common-metadata` implied by `-W clippy::cargo`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata

    Checking quote v1.0.8
warning: could not read cargo metadata: Error during execution of `cargo metadata`:  Downloading crates ...
  Downloaded syn-test-suite v0.0.0
error: failed to verify the checksum of `syn-test-suite v0.0.0`

  |
  = note: `-W clippy::multiple-crate-versions` implied by `-W clippy::cargo`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

warning: 2 warnings emitted

warning: package `syn` is missing `package.keywords` metadata
  |
  = note: `-W clippy::cargo-common-metadata` implied by `-W clippy::cargo`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata

warning: could not read cargo metadata: Error during execution of `cargo metadata`:  Downloading crates ...
  Downloaded syn-test-suite v0.0.0
error: failed to verify the checksum of `syn-test-suite v0.0.0`

  |
  = note: `-W clippy::multiple-crate-versions` implied by `-W clippy::cargo`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

warning: 2 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 6.24s

clippy @ 0154965

@matthiaskrgr matthiaskrgr added the C-bug Category: Clippy is not doing the correct thing label Dec 27, 2020
@matthiaskrgr
Copy link
Member Author

Turns this actually printed by clippy:

#[macro_export]
macro_rules! unwrap_cargo_metadata {
    ($cx: ident, $lint: ident, $deps: expr) => {{
        let mut command = cargo_metadata::MetadataCommand::new();
        if !$deps {
            command.no_deps();
        }

        match command.exec() {
            Ok(metadata) => metadata,
            Err(err) => {
                span_lint($cx, $lint, DUMMY_SP, &format!("could not read cargo metadata: {}", err));
                return;
            },
        }
    }};
}

@matthiaskrgr matthiaskrgr changed the title cargo lints: cargo metadata output leaks into clippy warnings? cargo lints: clippy dumps cargo metadata errors/warnigs into stderr? Feb 10, 2021
@matthiaskrgr matthiaskrgr changed the title cargo lints: clippy dumps cargo metadata errors/warnigs into stderr? cargo lints: clippy dumps cargo metadata errors/warnigs into stderr Feb 10, 2021
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
Projects
None yet
Development

No branches or pull requests

1 participant