-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
Comments
To replicate the experience of doing this, you can download err.gz and then do $ sleep 138; zcat err.gz |
I believe there is a similar open ticket for this. Edit: #125581. Note that the rendering output already trims the output to fit the terminal width when possible. Namely, when there are spans for code that is wider than the terminal, we remove "margins" to the left and right. But that logic operates under the assumption that if there are spans, people want to see them and their associated code, so there's a bounding box on the left-most span and the right-most span, from which the trimming cannot go past. And as an extension of that, there's no logic to trim code from a single, long, span (like the one being presented here). I believe we can do that, likely only if there's a single span, or if the output is so extreme (like in this case) that there's no point on trying to do pretty output. One option would be for cases where there are spans that are >3 times the terminal width to trim the middle of them, as long as they don't overlap with another span, and only for that line. This doesn't keep the shape of the user's code as they wrote it, but it is better than nothing. For suggestions, the situation is a bit harder as well, because we currently don't trim those, because we want people to be able to copy-paste from that ouptut, but it might be that we want to apply a similar heuristic of "if there's only one code change in a long line of code, and it is wider than N times the terminal, trim to the right while still including the code change". I think that the compile time slowdown is likely unrelated to the verbosity, likely some accidentally quadratic code in the suggestion machinery for this error. |
…al width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of rust-lang#137680 (missing handling of the long suggestion). Fix rust-lang#125581.
…al width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of rust-lang#137680 (missing handling of the long suggestion). Fix rust-lang#125581.
On long spans, trim the middle of them to make them fit in the terminal width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of rust-lang#137680 (missing handling of the long suggestion). Fix rust-lang#125581. --- Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic. --- `-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
…al width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of rust-lang#137680 (missing handling of the long suggestion). Fix rust-lang#125581.
On long spans, trim the middle of them to make them fit in the terminal width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of rust-lang#137680 (missing handling of the long suggestion). Fix rust-lang#125581. --- Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic. --- `-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
Rollup merge of rust-lang#137757 - estebank:trim-spans, r=davidtwco On long spans, trim the middle of them to make them fit in the terminal width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of rust-lang#137680 (missing handling of the long suggestion). Fix rust-lang#125581. --- Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic. --- `-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
Code
(The actual data in my use-case is indices in a 100³ gilbert curve but isn't relevant here.)
this is the good state
Change line 2 to
to trigger
Current output
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
The text was updated successfully, but these errors were encountered: