Skip to content

rustc output hygiene wrt. stderr/stdout #48301

@sanmai-NL

Description

@sanmai-NL

rustc sometimes emits exclusively human-readable output on stdout. Moreover, it sometimes produces machine-readable output on stderr. It should be the other way around, and at least output writing should be principled.

When compiling a bin target helloworld:

On stdout:

bin: helloworld

This would interfere in parsing JSON messages (--error-format json), for example from Clippy. If only they weren’t mistakenly written on stderr, too ... It seems very simple to fix such little slip-ups, but I couldn’t track down the offending code for this instance.

Another sample of the same issue, from a different angle:

rustc --error-format json

Prints on stderr:

{"message":"no input filename given","code":null,"level":"error","spans":[],"children":[],"rendered":"error: no input filename given\n\n"}

I propose, first, that we decide to guarantee that all JSON will ever be printed on stdout exclusively, and all the rest on stderr exclusively. Second, to implement this by making the appropriate fixes across rustc, Cargo and Clippy.

Meta

rustc 1.25.0-nightly (3ec5a99 2018-02-14)

Related #36516

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions