-
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 cast in fixed-length vector #10618
Comments
klutzy suggests this might be related to #9942. |
I was looking into #5900 and this looks like a somewhat similar problem. The issue is that middle::const_eval::eval_const_expr_partial's ExprCast arm, which gets hit as a part of the call to check_item (here, specifically, check_fn), wants the ExprCast's parent id to already be in the type context but nothing has put it there yet. In #5900 this is because the enum doesn't get checked before the struct; here, it doesn't look like its order dependent, there's just nothing pushing that expression into the context. |
This gets to the ICE through a more direct code path:
|
I tried a couple of different ways to squash this, and still don't think this is ideal, but I wanted to get it out for feedback. Closes #5900 Closes #9942 There are a few scenarios where the compiler tries to evaluate CastExprs without the corresponding types being available yet in the type context: #10618, #5900, #9942 This PR takes the approach of having eval_const_expr_partial's CastExpr arm fall back to a limited ast_ty_to_ty call that only checks for (a subset of) valid const types, when the direct type lookup fails. It's kind of hacky, so I understand if you don't want to take this as is. I'd need a little mentoring to get this into better shape, as figuring out the proper fix has been a little daunting. I'm also happy if someone else wants to pick this up and run with it. This closes 5900 and 9942, but only moves the goalposts a little on 10618, which now falls over in a later phase of the compiler.
Flagging as needstest (seems to work now) |
[missing_const_for_fn] fix rust-lang#7121 *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: [`missing_const_for_fn`] note about removing const may break compatibility fix rust-lang#7121
The following code:
causes:
in the latest nightly from https://launchpad.net/~hansjorg/+archive/rust.
The text was updated successfully, but these errors were encountered: