-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix ICE and report a human readable error #55071
The head ref may contain hidden characters: "const_cast_\u{1F368}"
Conversation
@@ -163,6 +163,10 @@ fn check_rvalue( | |||
_ => check_operand(tcx, mir, operand, span), | |||
} | |||
} | |||
Rvalue::Cast(_, _, _) => Err(( | |||
span, | |||
"only int casts are allowed in const fn".into(), |
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.
"int casts" doesn't seem like the right description here, not all Misc
casts involved integers -- do they?
There are not so many kinds of casts, so depending on that you could make it say "unsizing casts" or "function pointer casts".
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.
Also, can you add a test case for this code branch?
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.
I'm not sure if I can, but I'll try
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.
Don't let it be a blocker, but it'd be nice to have error cases so that later we can give them all their own error code and a good extended description.
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.
I managed to get to the unsizing errors. Everything else errors out early due to fn pointers not being allowed
This comment has been minimized.
This comment has been minimized.
lgtm++ |
)), | ||
Rvalue::Cast(CastKind::ClosureFnPointer, _, _) => Err(( | ||
span, | ||
"closures are not allowed in const fn".into(), |
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.
This is not just having a closure, but then casting it to fn()
(I think). The message should contain the word "cast" one way or another.
I would have just grouped it with the other two fn ptr casts.
r=me with that nit fixed. |
@bors r=RalfJung |
📌 Commit 38f3ad4 has been approved by |
Fix ICE and report a human readable error fixes rust-lang#55063 r? @RalfJung
Fix ICE and report a human readable error fixes rust-lang#55063 r? @RalfJung
Rollup of 7 pull requests Successful merges: - #54300 (Updated RELEASES.md for 1.30.0) - #55013 ([NLL] Propagate bounds from generators) - #55071 (Fix ICE and report a human readable error) - #55144 (Cleanup resolve) - #55166 (Don't warn about parentheses on `match (return)`) - #55169 (Add a `copysign` function to f32 and f64) - #55178 (Stabilize slice::chunks_exact(), chunks_exact_mut(), rchunks(), rchunks_mut(), rchunks_exact(), rchunks_exact_mut())
fixes #55063
r? @RalfJung