-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Move try_to_bits
from Const
to Valtree
#136130
base: master
Are you sure you want to change the base?
Move try_to_bits
from Const
to Valtree
#136130
Conversation
Some changes occurred in compiler/rustc_sanitizers cc @rust-lang/project-exploit-mitigations, @rcvalle |
This comment has been minimized.
This comment has been minimized.
b53347c
to
312a32f
Compare
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.
IMO we should eventually add a proper type for type-level const values rather that use a tuple of (Ty, ValTree)
everywhere, but this PR is already an improvement :)
312a32f
to
23ed79b
Compare
Currently, I introduced the proper type ( |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: FedericoBruzzone <[email protected]>
23ed79b
to
9783e80
Compare
struct ValTreeAndTy<'tcx> { | ||
valtree: ty::ValTree<'tcx>, | ||
ty: Ty<'tcx>, | ||
} |
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.
cc @BoxyUwU this is a practical type we could use in more places, and implement methods like try_to_bits
directly on, to avoid having to pass the type separately
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.
Ah yeah sorry this was intended to be follow up work from the original PR that removed Ty
from ty::Const
but it just didn't wind up happening 👍
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 have a branch that implements this PR's approach more globally (master...lukas-code:rust:typed-valtree), will send PR soon.
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 will look at that PR as soon as possible.
This PR is a follow-up to #135158
What's in this PR?
try_to_bits
: Transitioned fromConst
toValtree
.validate_const_with_value
: Renamed toextract_valtree_and_ty
for better clarity.Benefits
Valtree
avoids the need to re-evaluate aConst
, improving efficiency where this re-evaluation was previously performed. For instance, in:TooGeneric
variant toLayoutError
and emitUnknown
#135158).r? @lukas-code @oli-obk