Skip to content

TERM=dumb is not respected for warnings in diagnostic annotations #50645

Closed
@andreastt

Description

@andreastt

It appears the TERM=dumb environment variable is not respected by librustc_errors’ diagnostic annotations for warnings, hints, fatal errors, et al.

The below example of compiling a random program I’ve authored shows that the string “Compiling” correctly does not get colourised. This is because it uses termcolor’s ColorChoice::Auto which cancels colourisation because it checks if the terminal is dumb.

Farther down in the example, the string starting with “warning” emits a lot of escape sequences for colourisation.

For reference, so-called “dumb terminals” are terminals that only recognise a limited subset of escape sequences. In my particular case it is the monochrome rc shell.

% TERM=dumb cargo build
   Compiling build_const v0.2.0
   Compiling cfg-if v0.1.2
   Compiling matches v0.1.6
   Compiling cc v1.0.9
   Compiling num-traits v0.2.0
   Compiling version_check v0.1.3
   Compiling adler32 v1.0.2
   Compiling void v1.0.2
   Compiling unicode-normalization v0.1.5
   Compiling libc v0.2.39
   Compiling percent-encoding v1.0.0
   Compiling lazy_static v1.0.0
   Compiling safemem v0.2.0
   Compiling byteorder v1.2.1
   Compiling typeable v0.1.2
   Compiling language-tags v0.2.2
   Compiling traitobject v0.1.0
   Compiling semver-parser v0.7.0
   Compiling regex-syntax v0.4.1
   Compiling unicode-width v0.1.4
   Compiling httparse v1.2.3
   Compiling utf8-ranges v1.0.0
   Compiling strsim v0.6.0
   Compiling unicode-segmentation v1.1.0
   Compiling bitflags v1.0.1
   Compiling geckodriver v0.20.1 (file:///home/ato/src/gecko/testing/geckodriver)
   Compiling podio v0.1.5
   Compiling rustc-serialize v0.3.24
   Compiling log v0.4.1
   Compiling unreachable v1.0.0
   Compiling unicode-bidi v0.3.4
   Compiling crc v1.7.0
   Compiling base64 v0.6.0
   Compiling unicase v1.4.2
   Compiling num-traits v0.1.43
   Compiling miniz_oxide v0.1.2
   Compiling memchr v1.0.2
   Compiling rand v0.3.18
   Compiling num_cpus v1.7.0
   Compiling time v0.1.38
   Compiling term_size v0.3.0
   Compiling semver v0.6.0
   Compiling thread_local v0.3.5
   Compiling num-integer v0.1.35
   Compiling textwrap v0.9.0
   Compiling aho-corasick v0.6.3
   Compiling log v0.3.9
   Compiling rust-ini v0.10.2
   Compiling miniz_oxide_c_api v0.1.2
   Compiling bzip2-sys v0.1.6
   Compiling idna v0.1.4
   Compiling tempdir v0.3.5
   Compiling cookie v0.10.1
   Compiling msdos_time v0.1.5
   Compiling num-iter v0.1.34
   Compiling num v0.1.40
   Compiling mozprofile v0.3.0 (file:///home/ato/src/gecko/testing/mozbase/rust/mozprofile)
   Compiling mime v0.2.6
   Compiling regex v0.2.2
   Compiling clap v2.29.0
   Compiling chrono v0.2.25
   Compiling flate2 v1.0.1
   Compiling mozrunner v0.6.1 (file:///home/ato/src/gecko/testing/mozbase/rust/mozrunner)
   Compiling bzip2 v0.3.2
   Compiling url v1.7.0
   Compiling uuid v0.1.18
   Compiling zip v0.3.1
   Compiling hyper v0.10.13
   Compiling mozversion v0.1.3 (file:///home/ato/src/gecko/testing/mozbase/rust/mozversion)
   Compiling webdriver v0.35.0 (file:///home/ato/src/gecko/testing/webdriver)
�[0m�[1m�[33mwarning�[0m�[0m�[1m: variant is never constructed: `Quit`�[0m
�[0m  �[0m�[0m�[1m�[38;5;12m--> �[0m�[0mtesting/webdriver/src/server.rs:23:5�[0m
�[0m   �[0m�[0m�[1m�[38;5;12m|�[0m
�[0m�[1m�[38;5;12m23�[0m�[0m �[0m�[0m�[1m�[38;5;12m| �[0m�[0m    Quit�[0m
�[0m   �[0m�[0m�[1m�[38;5;12m| �[0m�[0m    �[0m�[0m�[1m�[33m^^^^�[0m
�[0m   �[0m�[0m�[1m�[38;5;12m|�[0m
�[0m   �[0m�[0m�[1m�[38;5;12m= �[0m�[0m�[1mnote�[0m�[0m: #[warn(dead_code)] on by default�[0m

    Finished dev [optimized + debuginfo] target(s) in 58.60 secs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions