qnighy / clippy-reviewdog-filter

A filter for integrating Clippy with Reviewdog
3 stars 3 forks source link

Broken deserialize package_id in Rust 1.77.0 project #190

Closed sksat closed 6 months ago

sksat commented 7 months ago

In Rust 1.77.0 project, cargo clippy --message-format json | clippy-reviewdog-filter panicked by I/O error when reading input: Custom { kind: InvalidData, error: Error("missing fieldversion", line: 0, column: 0) }.

.package_id format changed like below. Rust 1.76.0: "package_id": "registry+https://github.com/rust-lang/crates.io-index#libc@0.2.150", Rust 1.77.0: "package_id": "libc 0.2.150 (registry+https://github.com/rust-lang/crates.io-index)",

It comes from Package Id Spec stabilization (ref: https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-177-2024-03-21).

sksat commented 7 months ago

To solve this problem, I think following deserialize strategies seem to exist.

  1. Try deserialize with Package ID spec -> fallback to deserialize with original format
  2. Receive Rust version as a command line argument and change .package_id deserialize behaviour
  3. Get Rust version from runtime (In this choice, it whould be better to change it as a cargo subcommand)
sksat commented 7 months ago

cargo-util-schemas crate could be useful!

https://docs.rs/cargo-util-schemas/latest/cargo_util_schemas/core/struct.PackageIdSpec.html https://github.com/rust-lang/cargo/blob/e52e360061cacbbeac79f7f1215a7a90b6f08442/src/cargo/core/mod.rs#L17