• fmdkdd's avatar
    Use `--message-format=json` flag for rust-cargo checker · 3f05317c
    fmdkdd authored
    To get JSON output, rust-cargo used the `--error-format=json` flag of rustc.
    This had the downside of getting JSON output only from the *last* invocation of
    rustc by cargo.  Crucially, when compiling dependencies with errors, these
    errors would be reported as plain text rather than JSON, resulting in a
    suspicious checker state for rust-cargo.
    In the 1.13 release of Rust, Cargo added the `--message-format=json` to ensure
    all invocations of rustc would return JSON messages.  Unfortunately, the
    `--message-format` flag was not compatible with the `-Zno-trans` option that
    cuts down on compilation time by not generating an
    executable (rust-lang/cargo#3390).  This issue is fixed by release 1.15 of Rust.
    This commit changes rust-cargo to pass the `--message-format` flag instead of
    `--error-format`, ensuring that errors from dependencies are correctly turned
    into `flycheck-error` objects.
    Since Cargo merely encapsulates the JSON messages from rustc, this commits
    extracts the parsing of rustc diagnostics into its own function,
    `flycheck-parse-rustc-diagnostic`, to allow the new `flycheck-parse-cargo-rustc`
    and the existing `flycheck-parse-rust` (renamed `flycheck-parse-rustc`) to parse
    individual diagnostics.
    This commit also adds a test for the behavior that `--message-format` fixes over
    `--error-format`.  This required to instruct the flycheck-ert helpers to fail
    when a flycheck reported a suspicious checker state.
    Previously, a suspicious status would be printed out while running the tests,
    but would not mark the test as failed.
    This commits adds a hook to check for change in checker status and fails the
    test if the checker reports a suspicious status.
flycheck-ert.el 16.5 KB