-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Diagnostic infra doesn't respect CLICOLOR_FORCE=1 #148864
Copy link
Copy link
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.D-diagnostic-infraDiagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.D-diagnostic-infraDiagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
We've recently migrated to
anstream/anstylein #147207.When lowering
rustc'sColorConfigtoanstream's/colorchoice'sColorChoice, we utilize a method calledto_color_choicewhich interestingly isn't a straightforward 1:1 mapping as you might've thought:rust/compiler/rustc_errors/src/emitter.rs
Lines 591 to 604 in 95aeb46
Most importantly, instead of mapping
AutotoAuto, it mapsAutotoNeverif STDERR isn't a terminal. I'm not sure why this choice was made. Regardless, it leads to us not fully utilizinganstream's "color capability detection".For instance, it means that
CLICOLOR_FORCE=1(cc https://bixense.com/clicolors/) doesn't work:CLICOLOR_FORCE=1 rustc erroneous.rs 2>&1 >/dev/null | cat1 orCLICOLOR_FORCE=1 rustc erroneous.rs 2>/dev/nulldoesn't force color ascat/ the file is a "non-terminal" and thusto_color_choicemaps it toNeverinstead of askinganstyle-query.Note that most if not all other detection mechanisms of
anstyle-querydo work for rustc/rustdoc. E.g.,NO_COLOR=1suppresses colors,TERM=dumbsuppresses colors, inCI= TERM=dumbCItrumpsTERM, inCLICOLOR= TERM=dumbCLICOLORtrumpsTERMand so on.Footnotes
This bash (or zsh with option multios disabled) snippet redirects the stderr to a "non-terminal" (
cat). ↩