-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[ICE]: StyledBuffer::replace panics with --diagnostic-width <= 10 #154258
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-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.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityLow priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-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.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityLow priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Meta
rustc --version --verbose:Error output
Full backtrace
Trigger conditions
unused_mutwarning where the variable name is 7+ characters (the lint's underline spans 12+ display columns)--diagnostic-widthis 10 or less (including 0, the auto-detected value when there is no TTY)This is hit in practice by non-interactive environments: CI without a PTY,
wsl -einvocations, piped output through tools that don't allocate a terminal, etc.The crash also produces a secondary
delayed_bugaboutOpaqueTypeKey/ProvisionalHiddenType, but this is collateral damage from the panic aborting the borrow checker -- not an independent type system bug.Regression
Regression in 1.94.0 (works on 1.93.0). Nightly bisect (regressed nightly-2025-11-23) points to #148984 which upgraded
annotate-snippetsfrom 0.11.5 to 0.12.9. The vulnerableStyledBuffer::replacemethod was introduced in the 0.12.x series.Update: Regression is 1.91.0 -> 1.92.0, not 1.93.0 -> 1.94.0. See this comment for details.
Root cause
The bug is in
annotate-snippets0.12.10-0.12.13 (still present on main), not in rustc itself. The span-trimming logic inannotate_snippets::renderer::rendercomputes an inverted range whenterm_widthis 0, andStyledBuffer::replacepanics on it.Filed upstream: rust-lang/annotate-snippets-rs#391
Workarounds
Reproducer repo
https://github.com/furkanmamuk/rustc-ice-diagnostic-width-panic