Dumps unbounded amounts of data in diagnostics (27M in three lines for one error!) for large input lines (and thinks about them for minutes first)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
(The actual data in my use-case is indices in a 100³ gilbert curve but isn't relevant here.)
$ { echo '['; seq $(( 100 * 100 * 100 )) | sed 's/.*/(0,0,0),/'; echo ']'; } > 100.rs
$ tr '\n' ' ' < 100.rs > 100s.rs
const GRID_SIZE: usize = 100;
static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100s.rs");
fn main() {}
this is the good state
$ time rustc bugowcy.rs
warning: constant `GRID_SIZE` is never used
--> bugowcy.rs:1:7
|
1 | const GRID_SIZE: usize = 100;
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: static `GRID_GILBERT` is never used
--> bugowcy.rs:2:8
|
2 | static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100s.rs");
| ^^^^^^^^^^^^
warning: 2 warnings emitted
real 0m31.891s
user 0m0.000s
sys 0m0.015s
Change line 2 to
static GRID_GILBERT: &[(u8,u8,u8)] = include!("100s.rs");
to trigger
Current output
$ time rustc bugowcy.rs > err 2>&1
real 2m12.617s
user 0m0.000s
sys 0m0.015s
$ wc -cl err
16 27000433 err
$ less -S err
error[E0308]: mismatched types
--> 100s.rs:1:1
|
1 | [ (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>
|
= note: expected reference `&'static [(u8, u8, u8)]`
found array `[({integer}, {integer}, {integer}); 1000000]`
help: consider borrowing here
|
1 | &[ (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), >
| +
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
Yes that is 27 megabytes of diagnostic output, basically repeating the input thrice (twice verbatim, once with ^^^^s).
Desired output
Either a bounded line output or just a bailout. Honestly just a bailout. It'd be nice if it took like 30s instead of 2:20 💀
Rationale and extra context
I think in this case (and in general) having rustc churn for two full minutes is. Not good. And value to the user is bigger when you get the error without source-level diagnostics.
Rust Version
$ rustc --version --verbose
rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-pc-windows-gnu
release: 1.84.1
LLVM version: 19.1.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic with rustc using bugowcy.rs and the generated 100s.rs input, comparing the owned-array and borrowed-slice declarations. Start by tracing the compiler's handling of the E0308 diagnostic and its source-level rendering. Done means the same error completes promptly without emitting unbounded repeated source text, while retaining a useful bounded diagnostic or bailout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100