Skip to content

Inconsistent summary on error count with --message-format=json #14472

@zjp-CN

Description

@zjp-CN

Problem

cargo check emits a good summary on error count, but with --message-format json, the count number is increased by 1 because it seems to include the error summary itself as a new error. This also influences summary count of clippy in the same way.

As for warning count, the former reports the count, but with json format, no count is reported.

Steps

Repoducible repo: https://github.com/os-checker/MRE-cargo-error-count

// src/main.rs
#![deny(warnings)]
fn main() {
    let a = 1;
}
$ cargo check
error: could not compile `cargo-error-count` (bin "cargo-error-count") due to 1 previous error

$ cargo check --message-format json
error: could not compile `cargo-error-count` (bin "cargo-error-count") due to 2 previous errors

Note: this inconsistency might be a bit different on warning report

# with no #![deny(warnings)]
$ cargo check
warning: `cargo-error-count` (bin "cargo-error-count") generated 1 warning

# with no #![deny(warnings)]
$ cargo check --message-format json
# no count reported

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.82.0-nightly (0d8d22f83 2024-08-08)
release: 1.82.0-nightly
commit-hash: 0d8d22f83b066503f6b2b755925197e959e58b4f
commit-date: 2024-08-08
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/3.3.1)
ssl: OpenSSL 3.3.1 4 Jun 2024
os: Ubuntu 22.4.0 (jammy) [64-bit]

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.A-json-outputArea: JSON message outputC-bugCategory: bugE-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions