Skip to content
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

Show more of the overlong type on type-length error #76777

Closed
wants to merge 1 commit into from

Conversation

kornelski
Copy link
Contributor

@kornelski kornelski commented Sep 16, 2020

The long type-length error trims the type too much, and makes it very hard to identify where the offending type comes from (like in #76785).

Longer type length won't be pretty in terminals, but may help diagnosing the problem.

@rust-highfive
Copy link
Collaborator

r? @ecstatic-morse

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2020
@jyn514 jyn514 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-diagnostics Area: Messages for errors, warnings, and lints labels Sep 16, 2020
@ecstatic-morse
Copy link
Contributor

I don't run into these errors often, but I would rather have the short version of the error for both of the cases in the test suite. Brevity can also be helpful for debugging. Presumably 256 was chosen because it gives good results for the case in #76785? It seems that the problem there is more about where the break occurs. What about tracking delimiters (<, (, { and [) until the character threshold is reached?

@eddyb wants to remove this class of errors entirely. Maybe they have a stronger opinion than I do?

@kornelski
Copy link
Contributor Author

kornelski commented Sep 17, 2020

Test files are autogenerated by the "bless" command, so I don't think I can trim them.

I know it looks messy, but it is an inherently messy error. If it doesn't show the long ugly type, then it's not known what the ugly type is about.

I can't think of a simple heuristic to display only "interesting" part of a type. It's not as easy as skipping punctuation, since opaque types are also noise and have non-trivial syntax. Trying to pretty-print a 350MB-long type would be difficult, and might end up with something silly like a million spaces of indentation.

@kornelski
Copy link
Contributor Author

kornelski commented Sep 17, 2020

Oh, I have an idea! rustc could write the full multi-megabyte type name to a temp file on disk, and the error message can print the file name.

Implemented in #76843

@kornelski kornelski closed this Sep 17, 2020
@kornelski kornelski deleted the longerlongtypes branch September 17, 2020 23:41
RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 20, 2020
…c-morse

Let user see the full type of type-length limit error

Seeing the full type of the error is sometimes essential to diagnosing the problem, but the type itself is too long to be displayed in the terminal in a useful fashion. This change solves this dilemma by writing the full offending type name to a file, and displays this filename as a note.

> note: the full type name been written to '$TEST_BUILD_DIR/issues/issue-22638/issue-22638.long-type.txt'

Closes rust-lang#76777
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 21, 2020
…morse

Let user see the full type of type-length limit error

Seeing the full type of the error is sometimes essential to diagnosing the problem, but the type itself is too long to be displayed in the terminal in a useful fashion. This change solves this dilemma by writing the full offending type name to a file, and displays this filename as a note.

> note: the full type name been written to '$TEST_BUILD_DIR/issues/issue-22638/issue-22638.long-type.txt'

Closes rust-lang#76777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants