-
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 const-fn check in const_eval #118004
Fix const-fn check in const_eval #118004
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
call_source.from_hir_call(), | ||
None, | ||
); | ||
if let call_kind::CallKind::FnCall { fn_trait_id: _, self_ty } = |
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.
You could use let-chains here :)
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.
made it more readable now
We should probably just rip out the trait method call logic here and solely rely on effect checks. I don't like making const checks have more special casing logic, but also won't review in detail until January. So I don't have anything useful to say about the code change cc @fee1-dead |
if let call_kind::CallKind::FnCall { fn_trait_id: _, self_ty } = | ||
call_kind | ||
&& let FnDef(def_id, ..) = self_ty.kind() | ||
&& tcx.is_const_fn_raw(*def_id) |
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.
is_const_fn_raw
only checks whether the function is const
, and not whether it is const
-stable. We'd need a test to check whether this would silently allow calling functions that are not const-stable.
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.
how do we do that kind of check ?
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 other parts of the const checking code already check for const stability, so the first step would be creating an auxiliary ui test where upstream has a const-unstable function and downstream tries to call that function without the feature enabled (following the snippet for this ICE). If it already passes, then great. If it doesn't, we can change this from is_const_fn_raw
to is_const_fn
Yes, that would be the goal. I did leave a comment up there |
After looking a little bit into this, it looks like the actual ICE isn't because we aren't doing enough checks here, but probably because of something deeper than that. If I recall correctly, we used to remap the callee |
@rustbot author |
☔ The latest upstream changes (presumably #118692) made this pull request unmergeable. Please resolve the merge conflicts. |
@ouz-a any updates on this? |
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. @rustbot label: +S-inactive |
We were unable to capture constness of the
f
and ended up with ICE, this PR checks constness of thecallee
. I also don't understand why we are not checking constness via callingcall_kind
and capturingFnCall
.Fixes #117795