Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FedericoBruzzone
Copy link
Contributor

This PR is a follow-up to #135158

What's in this PR?

  • Move try_to_bits: Transitioned from Const to Valtree.
  • Rename validate_const_with_value: Renamed to extract_valtree_and_ty for better clarity.

Benefits


r? @lukas-code @oli-obk

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2025

Some changes occurred in compiler/rustc_sanitizers

cc @rust-lang/project-exploit-mitigations, @rcvalle

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@lukas-code lukas-code left a 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 :)

compiler/rustc_symbol_mangling/src/v0.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/consts/valtree.rs Outdated Show resolved Hide resolved
@FedericoBruzzone
Copy link
Contributor Author

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 :)

Currently, I introduced the proper type (ValTreeAndTy) locally to compiler/rustc_ty_utils/src/layout.rs. Let me know if a better solution could be move it externally.

@rust-log-analyzer

This comment has been minimized.

Comment on lines +37 to +40
struct ValTreeAndTy<'tcx> {
valtree: ty::ValTree<'tcx>,
ty: Ty<'tcx>,
}
Copy link
Contributor

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

Copy link
Member

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 👍

Copy link
Member

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.

Copy link
Contributor Author

@FedericoBruzzone FedericoBruzzone Jan 28, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants