Skip to content

Use the type-level constant value ty::Value where needed #136430

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

FedericoBruzzone
Copy link
Contributor

@FedericoBruzzone FedericoBruzzone commented Feb 2, 2025

Follow-up to #136180

Summary

This PR refactors functions to accept a single type-level constant value ty::Value instead of separate ty::ValTree and ty::Ty parameters:

  • valtree_to_const_value: now takes ty::Value
  • pretty_print_const_valtree: now takes ty::Value
  • Uses pretty_print_const_valtree for formatting valtrees when visit_const_operand
  • Moves try_to_raw_bytes from ty::Valtree to ty::Value

r? @lukas-code @oli-obk

@rustbot rustbot added 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 Feb 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2025

Some changes occurred to the CTFE machinery

cc @rust-lang/wg-const-eval

Some changes occurred in match checking

cc @Nadrieril

@oli-obk
Copy link
Contributor

oli-obk commented Feb 2, 2025

Everything but const_to_pat seems fine to me. There may be avenues for further improvements/deduplications, but I haven't come up with anything obviously improving things yet

@FedericoBruzzone
Copy link
Contributor Author

In const_to_pat we sometimes end up in some cases recreating a ty::Value, which is not great.
Let's wait for more feedback, while I try to see if we can do better.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 2, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 2, 2025

📌 Commit 709a63a has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Feb 3, 2025

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 3, 2025
Signed-off-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
Signed-off-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
@FedericoBruzzone FedericoBruzzone changed the title Refactor using the type-level constant value ty::Value Use the type-level constant value ty::Value where needed Feb 3, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Feb 3, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 3, 2025

📌 Commit 00c61a8 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 3, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 3, 2025
… r=oli-obk

Use the type-level constant value `ty::Value` where needed

**Follow-up to rust-lang#136180**

### Summary

This PR refactors functions to accept a single type-level constant value `ty::Value` instead of separate `ty::ValTree` and `ty::Ty` parameters:

- `valtree_to_const_value`: now takes `ty::Value`
- `pretty_print_const_valtree`: now takes `ty::Value`
- Uses `pretty_print_const_valtree` for formatting valtrees  when `visit_const_operand`
- Moves `try_to_raw_bytes` from `ty::Valtree` to `ty::Value`

---

r? `@lukas-code` `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 4, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#136289 (OnceCell & OnceLock docs: Using (un)initialized consistently)
 - rust-lang#136299 (Ignore NLL boring locals in polonius diagnostics)
 - rust-lang#136411 (Omit argument names from function pointers that do not have argument names)
 - rust-lang#136430 (Use the type-level constant value `ty::Value` where needed)
 - rust-lang#136476 (Remove generic `//@ ignore-{wasm,wasm32,emscripten}` in tests)
 - rust-lang#136484 (Notes on types/traits used for in-memory query caching)
 - rust-lang#136493 (platform-support: document CPU baseline for x86-32 targets)
 - rust-lang#136498 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7e0118c into rust-lang:master Feb 4, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 4, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 4, 2025
Rollup merge of rust-lang#136430 - FedericoBruzzone:follow-up-136180, r=oli-obk

Use the type-level constant value `ty::Value` where needed

**Follow-up to rust-lang#136180**

### Summary

This PR refactors functions to accept a single type-level constant value `ty::Value` instead of separate `ty::ValTree` and `ty::Ty` parameters:

- `valtree_to_const_value`: now takes `ty::Value`
- `pretty_print_const_valtree`: now takes `ty::Value`
- Uses `pretty_print_const_valtree` for formatting valtrees  when `visit_const_operand`
- Moves `try_to_raw_bytes` from `ty::Valtree` to `ty::Value`

---

r? ``@lukas-code`` ``@oli-obk``
@FedericoBruzzone FedericoBruzzone deleted the follow-up-136180 branch February 4, 2025 13:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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