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

More precise spans for CTFE cycle errors #73283

Closed
RalfJung opened this issue Jun 12, 2020 · 2 comments · Fixed by #97740
Closed

More precise spans for CTFE cycle errors #73283

RalfJung opened this issue Jun 12, 2020 · 2 comments · Fixed by #97740
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

With #72879, CTFE cycle errors lost some of the precision in their span, which was deemed an acceptable consequence of code cleanup. Would be nice to fix that at some point, though.

With our current structure, getting this precision back would be non-trivial, but as a consequence of future cleanup it could become simpler: I have some plans for Allocation API changes, and we might make the methods in memory.rs associated with InterpCx instead of Memory to avoid what is currently a quite annoying split.

@jonas-schievink jonas-schievink added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2020
@RalfJung
Copy link
Member Author

RalfJung commented Jun 4, 2022

I tried improving this, but something happens that I do not understand... I added to step this line

self.tcx.span = self.cur_span();

which should mean self.tcx has up-to-date span information on every interpreter step. But this changes nothing about the output of src/test/ui/consts/recursive-zst-static.rs, which is the one that regressed 2 years ago.

I think the problem is that eval_static_initializer only exists on TyCtxt, so this drops the span info, and then calls TyCtxt::eval_to_allocation_raw which uses a DUMMY_SP.
@oli-obk do we need versions of all these functions in queries.rs that take TyCtxtAt so that we can properly preserve the span?

@RalfJung
Copy link
Member Author

RalfJung commented Jun 4, 2022

do we need versions of all these functions in queries.rs that take TyCtxtAt so that we can properly preserve the span?

Yes, that was it: #97740

@bors bors closed this as completed in 282445a Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants