惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
S
Schneier on Security
N
News | PayPal Newsroom
T
Threatpost
Cloudbric
Cloudbric
H
Heimdal Security Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google Online Security Blog
Google Online Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
V
Vulnerabilities – Threatpost
The Last Watchdog
The Last Watchdog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
L
LINUX DO - 最新话题
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Hacker News
The Hacker News
O
OpenAI News
人人都是产品经理
人人都是产品经理
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
C
Cisco Blogs
GbyAI
GbyAI
J
Java Code Geeks
L
LangChain Blog
I
Intezer
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
美团技术团队
The Register - Security
The Register - Security
Help Net Security
Help Net Security
WordPress大学
WordPress大学
Y
Y Combinator Blog
T
Tor Project blog
M
MIT News - Artificial intelligence
爱范儿
爱范儿
TaoSecurity Blog
TaoSecurity Blog
V
Visual Studio Blog
T
Threat Research - Cisco Blogs
P
Palo Alto Networks Blog
月光博客
月光博客
T
Tenable Blog
S
Securelist
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
DataBreaches.Net

The Rust Programming Language Forum - Latest topics

Beginner building a Rust backend framework (AI-assisted) — feedback appreciated C++ to Rust -- Exceptions Re-exporting a trait with a custom derive_macro Gold linker is deprecated Why is using PhantomData valid in this case? Code review for Static Pool Allocator Looking for a pool based allocator Why is this legal? What does it mean for Rustc to run "out of TLS keys"? Using async/await internally with no internal runtime, but exposing a nonblocking poll API — is this a reasonable design? Testing functions that use randomness `cargo-path`: improve coding agents&#39; ability to find Rust documentation Rust task runners Lifetime weird case Windows - USB device not detected A random rustc-ice-[...].txt file appeared Develop rust where the environment is setup in a docker Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 20 bytes, but got alloc238 which is only 1 byte from the end of the allocation Unbug 0.5 - Runtime debug assertions Is there a tiny error in section 6.2 Reference types? Lifetime woes implementing ratatui::Widget for a reference Rusqlite + Chrono: How do I simplify code to obtain chrono datetime value From OOP to Rust – struggling with code organization and data structure design Way to avoid a self-referential struct Rust RF and audio resources/communities Whyhttp - HTTP mocks that fail where the bug actually is Using tokio channel permits in a tower service Arc::increment_strong_count design question (cross-post) `&T`, `&mut T`, `Pin<&mut T>` and `&Cell<T>`: Ways of Borrowing a `T` Ratatui detect arrow key press and release Feedback about post in medium Debugger not showing/offering variables? nestrs: a NestJS-style framework for Rust built on Axum and Tower Confusion about struct variance with &mut dyn Narwhal v0.6.0 – message broker for edge apps, now with channel persistence Quiche client sent message not received at the server side "mysql" "Packets out of sync" - workaround Consistency f64 and std::Simd<f64, N> Signal semantics for Rust Snowflake-gen 1.0 - Configurable Snowflake ID generator with thread-local global API How do I do hmr in rust Diving into Rust: My Journey So Far and a Few Hiccups Celerity 0.1.1: pure Rust ZMTP 3.1 with a sans-IO core, Tokio transport, and CURVE-RS How to call struct method as function pointer in loop Loops inside loops and mutable reference on Iterator VSCode - rust-analyzer - annoying re-builds due to RUSTC_BOOTSTRAP changed Borsh v1.6.1 example What's everyone working on this week (17/2026)? Cargo test's verbose output - can I quiet it? Sem: semantic entity level version control CLI built with tree-sitter How do i get all the words in a string and convert it into a vector? Looking for feedback on my first tokenizer in Rust Frostmirror - (lightweight airgap alternative inspired from panamax and romt) - an offline cargo repository for airgap system that can be deployed through a docker image Does "ill-formed, no diagnostic required" exist in Rust? If a program is built with software floating-point emulation, is it affected by hardware floating-point environment? Rustc-link-lib static library How does crates.io and docs.rs store crates? Various input in one line error[E0080]: index out of bounds error when trying to install LuaCAD CSV to SQLite - Is it better to write records as they are being read Looking for feedback for a graph-based task scheduler Confusion: struct directly followed by impl? This is my first project. I invented a new algorithm that even AI don't know. It's about bigint. And I'm 15. Thanks for watching. By the way, my crate named `nna` Associate a struct with every enum variant Which Windows env var is responsible for DNS resolition? Clap completion question Is RMW operation less prone to reading stale values than a pure load? Crates with excluded proprietary parts Why are builds of my crate's test not consistent (cargo build vs cargo test vs VSCode-Test-Explorer) Why there is no downcast method Type inference of generic parameters How to make Rust as vertical as possible? Cyw43 on STM32H723 Typing is fun! Another crate for self-referential structs How to use build-analysis feature? Why can't I upgrade a known-exclusive &T to &mut T? Issues with Boxed trait objects Rust-analyzer Language Server Loops with accumulated state confuse me LoMux: Adobe Media Encoder Alternative (First Rust Project) Cbor-core: A deterministic CBOR::Core encoder/decoder Numa - a DNS resolver from scratch How should I deal with copying and renaming in monitoring of files? Request get to api.github.com Compiler Preprocessing Optimization Lifetime trait bounds issue High-Performance API Gateway Implemented a Rust-based CLI tool that supports Ollama's local LLMs Egui_tracing 0.3 — a live tracing/log viewer widget for egui apps Elevation-kit capstone project Panic-free-friendly standard library Work around library with private trait in public trait bound My custom Tab implementation with Slint How to express this complex struct definition which uses closures and multiple layers of higher-ranked lifetimes in Rust? 30K lines of no_std Rust: a bare-metal ARM64 hypervisor that replaces Google's Hafnium SPMC Imperartive or functional? Any improvements? Loop unrolling in manually written loops vs iterators (AVX512) Announcing cachekit 0.7 — pluggable cache policies and arena-backed primitives Need some suggestions Having Multiple Mutable References via Iterators
Why Windows rustc uses a different color scheme?
MOCKBA · 2026-04-18 · via The Rust Programming Language Forum - Latest topics

April 17, 2026, 11:39pm 1

I do Rust development on RPi 4, and rustc out looks great.

Screenshot17-4-2026153732pi

It looks same good when the dark mode selected. However when I occasionally switch to Windows 11 machine, rustc out looks terrible:

Screenshot17-4-2026153811win-pc

You can see that error messages use almost white hard coded color. Probably it looks good for the dark theme, but not good for the light one. Can somebody advise rustc team to reconsider color scheme for rustc and make it unified for all platforms?

Jesper April 18, 2026, 12:16am 2

I think it is the terminal profile rather than rustc that is the problem - have you tried changing it? (settings -> profiles -> colors).

You can also turn colors off - to see the invisible text:
rustc --color=never

MOCKBA April 18, 2026, 12:37am 3

Switching color off is a work around. As for now, I just select the message to see it in inverse color, but it's annoying. Anyway, not so many people do Rust development on Windows, and the issue isn't a big deal.

steffahn April 18, 2026, 1:00am 4

I believe rustc should be sending the exact same ansi escape sequences to either terminal here, on your Raspberry Pi, or on Windows, so it’s actually just the color scheme differences between these terminals of yours that make the difference, nothing rustc controls directly.

2 Likes

steffahn April 18, 2026, 1:17am 5

I’ve copied an example output line from an error message including the ecape sequences I got, and here’s some Rust code that should print the same kind of colored text, so you can double-check if that matches the behavior, if you like :slight_smile:

fn main() {
    println!("\x1b[1m\x1b[91merror[E0601]\x1b[0m\x1b[1m: `main` function not found in crate `foobar`\x1b[0m");
}

The text consists of:

  • escape sequence \x1b[1m
  • escape sequence \x1b[91m
  • text error[E0601]
  • escape sequence \x1b[0m
  • escape sequence \x1b[1m
  • text : `main` function not found in crate `foobar`
  • escape sequence \x1b[0m

Here, \x1b is the way to represent the ASCII character “ESC” (with hex code 1b) in Rust string.

The sequence ESC [ is called the “control sequence introducer” (short “CSI”) and all escape sequences we see here start with it.

Moreover, all of our sequences are of the form CSI n m for some integer number n, and you can find a listing of the meaning of sequences of this form here; in particular:

CSI 1 m: “Bold or increased intensity”
CSI 91 m: “Set bright foreground color” - specifically for “Bright Red”
CSI 0 m: “Reset“ (All attributes become turned off)

Thus, the whole text can be interpreted as follows:

  • CSI 1 m: “Bold or increased intensity”
  • CSI 91 m: “Set bright foreground color” - specifically for “Bright Red”
  • text error[E0601]
  • CSI 0 m: “Reset“ (All attributes become turned off)
  • CSI 1 m: “Bold or increased intensity”
  • text : `main` function not found in crate `foobar`
  • CSI 0 m: “Reset“ (All attributes become turned off)

Notice how the rust compiler is thus not hardcoding any color at all. It just says “make this bold”, basically. Assuming you can confirm the same behavior with my simplified println example, then the problem really is only up to your terminal, and how it’s implemented and/or configured :wink:

I do recall that some terminal applications do allow you to configure each color in your color scheme (the 8/16 basic ANSI colors) separately between the choice of color for normal text, vs. the choice of color for bold text.

Double-checking my own terminal (Konsole on linux), it looks like - specifically - they allow you to configure an “intense” color separately (I assume this is also what the “… or increased intensity” part of that escape code description relates to). Maybe you configured or some other way ended up a color scheme somehow without specifying a fitting “intense” variant of the default foreground color that has sufficient contrast for the default (non-intense) background.

3 Likes

MOCKBA April 18, 2026, 2:59am 6

Thank you for the so detailed answer. I captured out on Linux and Windows terminals:

Linux:

e[1me[91merrore[0me[1m: unexpected token: )e[0m

Windows:

e[1me[91merrore[0me[1me[97m: unexpected token: )e[0m

You can see that the ANSI codes are almost identical except that Windows uses high intensity - WHITE. It's obviously hardly visible. It looks like rustc uses a separate branch for coloring out on Windows. My desire that rustc merged the branches if it's possible.

As a temporary work around, I consider to reduce intense of white background on my terminal, maybe using something as #dddddd. Any other suggestions?

2 Likes

steffahn April 18, 2026, 3:03am 7

Oh, that’s interesting indeed! I don’t have a Windows PC at hand at the moment to double-check, but if there’s really such a difference, we should be able to find the relevant code and see if there’s any good reason for why it’s done this way.

For completeness: Did you also test if just printlning an output without that added e[97m (e.g. with something like the fn main() I shared in my previous reply) on your Windows machine would indeed result in the desired behavior?

Edit1: So it looks like rustc is generally using the anstream crate for some functionality.

Moreover, it looks like the annotate-snippets crate is also used.

I’m still some ways off finding where the actual color codes come from in the end.

Edit2: Looks like annotate-snippets uses anstyle to define color and boldness choices.

Edit3: I found the case distinction / branching here:

Edit4: That logic came into annotate-snippets in

which references relevant code points in older versions of rustc

Edit5: Okay, I’ve found the original source of the decision to special-case Windows colors (skiping some in-between refactorings later that seems to have preserved the original logic):

I do assume that this special-casing might potentially only make sense though in older Windows versions before they had ANSI-code support (assuming that bold text in terminals is properly supported there nowadays). So I guess it’s worth opening an issue about this – I’m not quite sure whether it’s more fitting on rust-lang/rust or on rust-lang/annotate-snippets-rs. :slight_smile:

11 Likes

epage April 18, 2026, 11:19am 8

Annotate-snippets is where the issue should go though it would likely take some more investigation before it any PR could be posted.

MOCKBA

April 19, 2026, 12:31am 9

Synopsis

rustc out with errors on a console with a light background looks like below:

Screenshot18-4-202616350win-pc

The error message is hardly visible, because the bright white is used for it.

Here are ANSI color codes used by Windows rustc:

e[1me[91merrore[0me[1me[97m: unexpected token: `)`e[0m

As you can see - 97 ANSI code is used.

The view with dark background looks good though:

Screenshot18-4-202616374win-pc

Here are rustc raw arguments:

"rustc" ["--color", "always", "-L", "all=..\crates", "--extern", "simcli", "--edition", "2024", "-o", "simtee", "C:\Users\sunil\projects\simtee\src\tee.rs"]

And rustc version is : rustc 1.94.1 (e408947bf 2026-03-25)

When Linux/MacOS computer is used in the same scenario, the light color background screen looks like:

Screenshot18-4-2026163932pi

And the dark color terminal looks like:

Screenshot18-4-2026164028pi

As you can see, ANSI codes look like:

e[1me[91merrore[0me[1m: unexpected token: `)`e[0m

There is no the bright white color code, therefore the image looks good for any background.

The raw command to run rustc is:

"rustc" ["--color", "always", "-L", "all=../crates", "--extern", "simcli", "--edition", "2024", "-o", "simtee", "/home/sunil/projects/simtee/src/tee.rs"]

And rustc version is : rustc 1.93.0 (254b59607 2026-01-19)

How to fix

Remove extra ANSI code on Windows.

Windows at least documents support for bold:

I'll have to take a stab to see how effective it is in the legacy console and the "new" terminal.

There's some OSC "dynamic colors" codes and $COLORFGBG that supposedly provide the current colors, basically to detect if you're in a light or dark terminal, but it doesn't look like Windows supports either of them (at least it's not documented.)

steffahn April 19, 2026, 12:16pm 11

It looks like the old way of setting terminal colors in Windows

only supported concrete colors and intensity:

(3 bits for the color, 1 bit for intensity; no way to set “generic” color [i.e. just add intensity without also hard-coding the color])

The question this doesn’t answer is whether or not boldness and such features are correctly rendered on standard cmd.exe nowadays, yet reading things such as this GitHub issue on neovim

Bold and italic text works correctly in the powershell or cmd, but not in Neovim.

suggests they do work.

Barring of course some actual testing before such a change is shipped stably, this sounds to me like we should remove the Windows special-casing, except possibly for the cases where the old Winapi approach may still exist as a fallback. Furthermore, it sounds like the ANSI sequence support exists since Windows 10 (and AFAICT we don’t really support older Windows versions for rustc, anyway).[1]

  1. Of course “support” in principle does not necessarily guarantee that text marked just bold but without colors set, through an ANSI sequence, will also actually display differently, hence the need for testing :innocent: ↩︎

khimru April 19, 2026, 12:26pm 12

It's windows. Nothing is ever simple there. In Windows 11 there are both old and new terminals. And while you may distinguish them@MOCKBA would probably break the detection by attempts to “secure” things.

steffahn April 19, 2026, 12:45pm 13

Meh… you could also say it’s terminals, nothing is ever simple there. Also most of the replies in the issue you linked there seem to be interested in other terminal capabilities like true color[1] not

My thinking was that a detection should usually only enable a specific special-case handling designed for “cmd.exe on Windows” or something, and not deviate from the normal behavior (across all other OSs) otherwise. In that case, any special setup would result in the more “normal” (and in this case also the more desired) behavior.

Regarding the question if detection for support of ANSI codes at all works as intended, that’s already the casee apparently, given @MOCKBA did report having gotten out text with ANSI codes.

Besides standalone terminals, I can imagine e.g. the current situation can similarly negatively affect users of IDEs on Windows (if they dare to have a light color scheme, the contrast may be off completely — otherwise, it’s still unnecessary that the ANSI codes sent to e.g. vscode isn’t 100% equivalent across platforms, even if the differences are more subtle[2].)

Looking back at the screenshots of @MOCKBA, it looks like an “same IDE on different platforms” situation might actually be the very thing that’s happening here, anyway :slight_smile:

  1. … there’s actually conspicuously little mention of other concrete capabilities of interest in the thread ↩︎

  2. assuming vscode will display colored terminal things consistently cross-platform ↩︎