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

Give recursion limit errors a span #135629

Open
oli-obk opened this issue Jan 17, 2025 · 8 comments · May be fixed by #138456
Open

Give recursion limit errors a span #135629

oli-obk opened this issue Jan 17, 2025 · 8 comments · May be fixed by #138456
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jan 17, 2025

For example in https://github.com/rust-lang/rust/blob/master/tests/ui/infinite/infinite-struct.rs we get an error like

error: reached the recursion limit finding the struct tail for `Take`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

We could pass in the obligation cause to struct_tail_raw and use its span for the main message and report a note for the obligation

Originally posted by @oli-obk in #135464 (comment)

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 17, 2025
@oli-obk oli-obk added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-diagnostics Area: Messages for errors, warnings, and lints and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 17, 2025
@tanvincible
Copy link
Contributor

Hello @oli-obk! I'd like to take a stab at it.

@rustbot claim

@tanvincible
Copy link
Contributor

Hello @oli-obk! Could you please provide some instructions on how I should proceed to tackle this issue?

@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 21, 2025

My plan would be to look at all calls to struct_tail_raw and check if there's an ObligationCause (or an Obligation containing one) nearby and pass that in. For the sites that have none, I'd just pass in an ObligationCause::misc() with a span that's nearby. Then I'd (in two separate commits), first use the span of the obligation to make the error point to that span instead of a DUMMY_SP, and second, check where other code annotates a Diag with an ObligationCause and call that code. The second step requires creating an error instead of emitting it (different method on the same dcx) and then mutating the Diag before emitting it. As the second step is more involved and I'd need to do research myself to figure it out, you can either dig into it, or just land the main span improvement first.

@tanvincible
Copy link
Contributor

Thanks! I'd try to land the main span improvement first.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 21, 2025

In that case you could even avoid passing an obligation and just pass a span (which you sometimes get from an obligation) to struct_tail_raw

@JumpiiX
Copy link

JumpiiX commented Mar 12, 2025

Hello @tanvincible , I noticed this issue has been assigned to you for some time, and I’d love to contribute. Are you still actively working on it, or would you mind if I take over? Let me know. Thanks!

@tanvincible
Copy link
Contributor

Hello @JumpiiX! I am sorry, I got busy and forgot to release the issue assignment. Feel free to take over the issue.

@rustbot release-assignment

@JumpiiX
Copy link

JumpiiX commented Mar 12, 2025

@rustbot claim

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 E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants