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

E0320 error huge type name output #79972

Open
minaminao opened this issue Dec 12, 2020 · 5 comments
Open

E0320 error huge type name output #79972

minaminao opened this issue Dec 12, 2020 · 5 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@minaminao
Copy link

minaminao commented Dec 12, 2020

I tried this code:

enum A<T> {
	B,
	C(T, Box<A<(T, T)>>)
}
fn main(){
	A::<i32>::B;
}

Compilation resulted in the E0320 error of 3.7MB:

error[E0320]: overflow while adding drop-check rules for A<i32>
 --> a.rs:6:2
  |
6 |     A::<i32>::B;
  |     ^^^^^^^^^^^
  |
  = note: overflowed on A<(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32)))), ((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))))), (((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32)))), ((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32)))))), ((((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32)))), ((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))))), (((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32)))), ((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))))))), (((((((i32, i32), (i32, i32)), ((i32, i32), (i32, i32))), (((i32, i32

(snip)

Since the error output is very large and taints the terminal, It might be better to use the same error output format as in the recursion limit error. Its format as follows.

In #72412, long type name is omitted:

 error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`

In #76843, the full type name of the omitted type is saved to a file:

= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-67552/issue-67552.long-type.txt'

Meta

rustc --version --verbose:

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-apple-darwin
release: 1.48.0
LLVM version: 11.0

The same error occurs in Ubuntu nightly version.

@minaminao minaminao added the C-bug Category: This is a bug. label Dec 12, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Dec 12, 2020
@minaminao
Copy link
Author

minaminao commented Dec 13, 2020

I would like to implement this!

@rustbot claim

I'm new to contributing to rust-lang/rust, so I'd be glad to get some advice.

Background

I think there are two approaches to omit the type name in the E0320 error output.

  1. Reimplement the same process as shrunk_instance_name in query.rs
    • Q: Where should I implement that process?
      a. As a process in the DropckOutlivesResult::report_overflows function
      b. As a function of DropckOutlivesResult
      c. As a query.rs function
  2. Reuse shrunk_instance_name
    • I think that the problem is that Instance in arguments of shrunk_instance_name is not used in the query.rs at all.

@fee1-dead
Copy link
Member

fee1-dead commented Jul 23, 2023

Hi @minaminao: I'm sad to see that you didn't get any replies here even though you had very well-researched comments and questions. Would you still like to work on this issue? If so I could offer a few pointers. Otherwise I can take over the assignment.

@minaminao
Copy link
Author

@fee1-dead Thanks for your interest in this issue!
I'd forgotten about it until now, sorry. I'd like to work on it, but I have yet to contribute to Rust, so it will take me some time to solve this issue.
If the Rust community wants to resolve this issue quickly, I think it's better that you work on it :)

@fee1-dead
Copy link
Member

fee1-dead commented Jul 24, 2023

Hi @minaminao: all good. I don't think there is any urgency in fixing this issue, so take your time :) As for the approach I think you should try reusing shrunk_instance_name. Since that function takes an Instance, you should change it so that it just takes a String (or preferrably &str) instead. Then you could move the function to somewhere such that both places can use this function, maybe somewhere like rustc_middle::ty::util.

@estebank
Copy link
Contributor

You indeed want to modify fn report_overflows to call tcx.short_ty_string and store both the type string and the file path in DropCheckOverflow and update the corresponding .ftl file. It should be relatively straightforward to accomplish, but if you need help, feel free to reach out!

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 A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants