Skip to content

cargo directly piping rustc output generates confusion with --explain #1554

Closed
rust-lang/rust
#25381
@huonw

Description

@huonw
fn foo() {
    match () {
        () => {}
        _ => {}
    }
}
cargo build
   Compiling error-explain v0.1.0 (file:///home/huon/projects/test-rust/error-explain)
src/lib.rs:4:9: 4:10 error: unreachable pattern [E0001]
src/lib.rs:4         _ => {}
                     ^
src/lib.rs:4:9: 4:10 help: pass `--explain E0001` to see a detailed explanation
error: aborting due to previous error
Could not compile `error-explain`.

To learn more, run the command again with --verbose.

The error message looks a lot like cargo build --explain ... should work, but it's really rustc telling the user to pass that flag to rustc, and cargo is just dumping rustc's output straight out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.A-toolingArea: interaction with other tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions