-
Notifications
You must be signed in to change notification settings - Fork 13.4k
WIP: check that required_consts really contains all required consts #75445
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Maybe it's const-prop again? EDIT: oh you're checking that |
@oli-obk is it possible that for No it's not ConstProp. The PR already contains a special constprop hack as usual (this is getting tedious^^), but the remaining failures have a stack trace like
Query stack:
|
Ah. I just remembered. We do probe const eval really early and this may cause
|
But it's not a TooGeneric:
If anything, the referenced constant failed with
Also why does the query stack say it is "const-evaluating |
Oh, doing this during codegen will be hard because it doesn't actually stop compiling a function when encountering a bad constant! rust/src/librustc_codegen_ssa/mir/mod.rs Line 199 in 4745cbe
That seems rather strange to me? There's no meaningful codegen in this case, we should just leave the function body empty or so... but we don't even |
does hint at this happening. I think we should start collecting some numbers on whether this scheme really is useful or not, but that's a different story. Anyway, back to this PR, idk how this is happening, we should be inserting all constants that we couldn't evaluate, so while there could be more constants added to MIR later (I don't know of this), seems unlikely, we already handle inlining correctly, I think the likely case is that there are constants that fail to eval early that don't end up in the list. This may be true for constants in types, maybe we're not looking at repeat lengths? |
Jup, we're not checking repeat lengths:
|
Also |
it's |
you can fix the query stack printing by adjusting rust/src/librustc_middle/query/mod.rs Line 682 in 3cfc7fe
GlobalId I think.
|
I got a span for the const that fails to evaluate: --> /home/r/src/rust/rustc/src/test/ui/consts/const_unsafe_unreachable_ub.rs:17:14
|
LL | assert_eq!(BAR, true);
| ^^^ Doesn't look like an array length to me? |
056b3c8
to
d43b5fc
Compare
omg, promoteds are created after |
cc @spastorino ooops |
Ah, found a real bug then. :) Can one of you take over fixing that bug? That sounds like it is beyond my comfort zone. |
jup. I checked out your PR locally, feel free to close this PR, I'll open a new one that includes your commit |
I'll add another commit that does a similar check for codegen -- or do you prefer to land that separately? |
Pushed the codegen change. It leads to errors like
|
9658098
to
3c72df0
Compare
3c72df0
to
b9f8c52
Compare
All right, closing as @oli-obk is taking over. |
To this end, assert that evaluating const operands never fails (as they all should have been checked as part of
required_consts
).I am going to try to find the right spot for codegen to add a similar check.
However, this also currently does not work -- const-eval triggers the new assertion. I am not sure how that is possible. (My previous theory made no sense.)
Cc @oli-obk