-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Miri: improve spans of required_const failures #75396
Conversation
To do better, we'd have to either
In the light of this chaos, I am not sure I want to add yet another pub loc: Option<mir::Location>, by something of a type like |
Yes, I also prefer that proposal. Although |
Or rather, |
All right, I implemented that now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with nits
@bors r=oli-obk |
📌 Commit 8fc28352e8f99df9a8fd965587ffccc3bd682dcd has been approved by |
@bors r- |
Hu, a test failure but local runs don't show anything?? |
Ah looks like that test was changed recently even though it already existed before... very strange. |
Also how horrible is GitHub? Why can I not go to the git log from https://github.com/rust-lang/rust/blob/d45dcb509527d847c7c3bf459a0e796801067b33/src/test/ui/consts/uninhabited-const-issue-61744.stderr ? I thought that used to be possible? |
Hm, that test also did not change recently. So it must be some other change on the rustc side that makes it such that in combination with this PR, the output for that test changes. WTF. |
Oh I see, this is a stack overflow, so it likely interacts with #75338. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(wow GitHub is really making my life as hard as possible today. now it started a review...)
M::after_stack_push(self)?; | ||
self.frame_mut().loc = Ok(mir::Location::START); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's about the order of these two lines: for errors that happen during after_stack_push
, so we want to use the span of the first statement, or the span of the entire body? IMO the latter makes more sense, the first statement has nothing to do with this.
For the stack overflow, probably the best span to use would be that of the call site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, the body's span is good here, though it's actually the call site's fault. But lets leave such refactorings (using the call site span) to the future, I remember trying something similar a while back and it just complicated the span scheme even more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this wouldn't even be that hard I think... we can just call cur_span
before pushing the new frame, then we should get the call site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just not clear to me that we always want the call site. The callee could also be responsible for the problem -- in fact I'd usually think they are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at runtime the decision whose job it is to create the stack frame is an ABI decision, but that doesn't really make sense for CTFE. But I also think your alluding to a different thing? If an required_const will fail regardless of the concrete generic parameters, then that's indeed the function's fault and not the caller's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an required_const will fail regardless of the concrete generic parameters, then that's indeed the function's fault and not the caller's
Yes, that is one possible scenario I had in mind where blaming the caller seems wrong.
📌 Commit fd32fe9 has been approved by |
⌛ Testing commit fd32fe9 with merge 5c8f1c241f7babd2356f080b77258174dcbf5da6... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-actions |
Seems spurious to me... I hope.^^ |
⌛ Testing commit fd32fe9 with merge 0ac354c868c8238b48198d9bac75bd17719505e3... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-actions |
@rust-lang/infra
Any idea what is happening? |
@bors treeclosed=1000 |
Fixing CI in #75450. |
☀️ Test successful - checks-actions, checks-azure |
In #75339 I added a loop evaluating all consts required by a function body. Unfortunately, if one of their evaluations fails, then the span used for that was that of the first statement in the function body, which happened to work form some existing test but is not sensible in general.
This PR changes it to point to the whole function instead, which is at least not wrong.
r? @oli-obk