-
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
ICE with Const Generic expression inside array declaration #60619
Comments
Recommended: P-medium due to unstable incomplete feature. |
Thanks for the report. (This only ICEs with the feature gate, so there's no need to raise the priority on this.) |
Not on beta though, but I guess #60277 will land in beta soon-ish so it shouldn't ICE there anymore? |
I'm currently looking into this. That said, if someone else wants to work on this, let me know. |
This can also be reproduced with the following code:
Due to this, I think that this is related to the const parameter being in braces in the array length. |
If that's the case, it might be related to #60717. |
@varkor Are you sure about that PR/issue number ? To my untrained eye, the linked ancient PR seems largely unrelated to the issue at hand. |
Thanks, I had missed off the final character 😄 |
Updating to latest master which includes #60717 fixes this for my minified case, but there seems to be an additional issue here as the original case still fails. |
The original issue will continue to fail because the expression |
Ah, I see, that makes sense. it sounds like #60717 was a bit of a hack, or rather that our AST conversion code is a bit of a hack as it stands now. It seems like we need to either drill into |
Yes, I think this is the case. We're being very strict about parameters: at the moment, we only allow quantification directly over a parameter, rather than being in any more complex expression.
At what point are you thinking this should happen? Ideally we want to permit parameters everywhere, but at the moment, I'm assuming we hit this path: rust/src/librustc_mir/interpret/operand.rs Line 527 in b3207d5
which means we haven't substituted the parameter early enough. I'm not sure when it's supposed to be being substituted, though. |
You are correct at where we are throwing that error. |
Ok, I've spent some more time looking into this as I've had time. The multiplication with the const param (and hence the error) is attempted to be evaluated as part of well-formedness checking of the struct. The expression containing the const param attempted to be evaluated, found to be too generic as it hasn't been monomorphized (and never will in this code as it isn't used), and the const evaluator returns saying it is too generic. For raw const params everything is kosher as the what determines whether to try to evaluate a const only checks for rust/src/librustc/traits/project.rs Line 402 in 5245803
Now, because the rust/src/librustc_typeck/check/wfcheck.rs Line 49 in 5245803
This is because an obligation that the expression can be const eval'd got added when const evaluation failed, and we cannot prove that it can be evaluated. To say that I am out of my comfort zone here is an understatement. That said, I think the problem here is that we are treating all I should have known this would not be an easy one to fix... |
This is probably the same issue as #61368. |
I spoke to @eddyb about these sorts of issues: it seems we need to wait for lazy normalisation before we can handle them, unfortunately. |
This is an instance of #43408, please use that as the canonical issue. |
The message is now:
|
Closing as duplicate of #43408 (which should probably be updated to mention not just array lengths but any const expressions in types). |
Found an ICE with the following code:
Results in "no errors encountered even though
delay_span_bug
issued" on current nightly.Playground link.
The ICE still happens regardless of the
LEN * 2
being in a block, in parenthesis, or even as a standalone expression. Interestingly, refactoring out the array into a seperate struct solves the issue.cc @varkor @yodaldevoid
The text was updated successfully, but these errors were encountered: