Clippy output in CI is not readable #366

Open
opened 2022-08-29 15:30:29 +00:00 by lx · 1 comment
Owner

When Clippy fails, we get the output in some JSON blob like this

error: builder for '/nix/store/hihh36nw0g0vpl40qa9fx8k9z73a3yci-crate-garage_rpc-0.7.0.drv' failed with exit code 101;
       last 14 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/w24l7iy13ajl3c0w3iqbgg3hajfp4zfd-rpc
       > source root is rpc
       > patching sources
       > configuring
       > building
       >
       > --- BUILDING WITH CLIPPY ---
       >
       >    Compiling garage_rpc v0.7.0 (/build/rpc)
       > {"reason":"compiler-message","package_id":"garage_rpc 0.7.0 (path+file:///build/rpc)","manifest_path":"/build/rpc/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"garage_rpc","src_path":"/build/rpc/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},"message":{"rendered":"error: this expression borrows a reference (`&garage_util::data::FixedBytes32`) that is immediately dereferenced by the compiler\n   --> rpc_helper.rs:407:49\n    |\n407 |                 let peer_zone = match ring.layout.node_role(&to) {\n    |                                                             ^^^ help: change this to: `to`\n    |\n    = note: `-D clippy::needless-borrow` implied by `-D warnings`\n    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow\n\n","children":[{"children":[],"code":null,"level":"note","message":"`-D clippy::needless-borrow` implied by `-D warnings`","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"change this to","rendered":null,"spans":[{"byte_end":11925,"byte_start":11922,"column_end":52,"column_start":49,"expansion":null,"file_name":"rpc_helper.rs","is_primary":true,"label":null,"line_end":407,"line_start":407,"suggested_replacement":"to","suggestion_applicability":"MachineApplicable","text":[{"highlight_end":52,"highlight_start":49,"text":"\t\t\t\tlet peer_zone = match ring.layout.node_role(&to) {"}]}]}],"code":{"code":"clippy::needless_borrow","explanation":null},"level":"error","message":"this expression borrows a reference (`&garage_util::data::FixedBytes32`) that is immediately dereferenced by the compiler","spans":[{"byte_end":11925,"byte_start":11922,"column_end":52,"column_start":49,"expansion":null,"file_name":"rpc_helper.rs","is_primary":true,"label":null,"line_end":407,"line_start":407,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":52,"highlight_start":49,"text":"\t\t\t\tlet peer_zone = match ring.layout.node_role(&to) {"}]}]}}
       > {"reason":"compiler-message","package_id":"garage_rpc 0.7.0 (path+file:///build/rpc)","manifest_path":"/build/rpc/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"garage_rpc","src_path":"/build/rpc/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},"message":{"rendered":"error: aborting due to previous error\n\n","children":[],"code":null,"level":"error","message":"aborting due to previous error","spans":[]}}
       > {"reason":"build-finished","success":false}
       > error: could not compile `garage_rpc` due to 2 previous errors

It would be nice instead to have a properly formatted Clippy output like this:

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/rpc/rpc_helper.rs:407:49
    |
407 |                 let peer_zone = match ring.layout.node_role(&to) {
    |                                                             ^^^ help: change this to: `to`
    |
    = note: `#[warn(clippy::needless_borrow)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: `garage_rpc` (lib) generated 1 warning

(this isn't very high priority, we get the nice output if we run cargo clippy outside of Nix)

When Clippy fails, we get the output in some JSON blob like this ``` error: builder for '/nix/store/hihh36nw0g0vpl40qa9fx8k9z73a3yci-crate-garage_rpc-0.7.0.drv' failed with exit code 101; last 14 log lines: > unpacking sources > unpacking source archive /nix/store/w24l7iy13ajl3c0w3iqbgg3hajfp4zfd-rpc > source root is rpc > patching sources > configuring > building > > --- BUILDING WITH CLIPPY --- > > Compiling garage_rpc v0.7.0 (/build/rpc) > {"reason":"compiler-message","package_id":"garage_rpc 0.7.0 (path+file:///build/rpc)","manifest_path":"/build/rpc/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"garage_rpc","src_path":"/build/rpc/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},"message":{"rendered":"error: this expression borrows a reference (`&garage_util::data::FixedBytes32`) that is immediately dereferenced by the compiler\n --> rpc_helper.rs:407:49\n |\n407 | let peer_zone = match ring.layout.node_role(&to) {\n | ^^^ help: change this to: `to`\n |\n = note: `-D clippy::needless-borrow` implied by `-D warnings`\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow\n\n","children":[{"children":[],"code":null,"level":"note","message":"`-D clippy::needless-borrow` implied by `-D warnings`","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"change this to","rendered":null,"spans":[{"byte_end":11925,"byte_start":11922,"column_end":52,"column_start":49,"expansion":null,"file_name":"rpc_helper.rs","is_primary":true,"label":null,"line_end":407,"line_start":407,"suggested_replacement":"to","suggestion_applicability":"MachineApplicable","text":[{"highlight_end":52,"highlight_start":49,"text":"\t\t\t\tlet peer_zone = match ring.layout.node_role(&to) {"}]}]}],"code":{"code":"clippy::needless_borrow","explanation":null},"level":"error","message":"this expression borrows a reference (`&garage_util::data::FixedBytes32`) that is immediately dereferenced by the compiler","spans":[{"byte_end":11925,"byte_start":11922,"column_end":52,"column_start":49,"expansion":null,"file_name":"rpc_helper.rs","is_primary":true,"label":null,"line_end":407,"line_start":407,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":52,"highlight_start":49,"text":"\t\t\t\tlet peer_zone = match ring.layout.node_role(&to) {"}]}]}} > {"reason":"compiler-message","package_id":"garage_rpc 0.7.0 (path+file:///build/rpc)","manifest_path":"/build/rpc/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"garage_rpc","src_path":"/build/rpc/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},"message":{"rendered":"error: aborting due to previous error\n\n","children":[],"code":null,"level":"error","message":"aborting due to previous error","spans":[]}} > {"reason":"build-finished","success":false} > error: could not compile `garage_rpc` due to 2 previous errors ``` It would be nice instead to have a properly formatted Clippy output like this: ``` warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/rpc/rpc_helper.rs:407:49 | 407 | let peer_zone = match ring.layout.node_role(&to) { | ^^^ help: change this to: `to` | = note: `#[warn(clippy::needless_borrow)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow warning: `garage_rpc` (lib) generated 1 warning ``` (this isn't very high priority, we get the nice output if we run `cargo clippy` outside of Nix)
lx added the
scope
build
label 2022-08-29 15:30:38 +00:00
Owner
Might be fixed: https://github.com/cargo2nix/cargo2nix/issues/239
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/garage#366
No description provided.