Skip to content

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) #137680

Open
@nabijaczleweli

Description

@nabijaczleweli

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions