Rollup merge of #122784 - jswrenn:tag_for_variant, r=compiler-errors

Add `tag_for_variant` query

This query allows for sharing code between `rustc_const_eval` and `rustc_transmutability`. It's a precursor to a PR I'm working on to entirely replace the bespoke layout computations in `rustc_transmutability`.

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2024-03-22 20:31:29 +01:00 committed by GitHub
commit 96be3e7cc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 347 additions and 292 deletions

View file

@ -1062,6 +1062,13 @@ rustc_queries! {
}
}
/// Computes the tag (if any) for a given type and variant.
query tag_for_variant(
key: (Ty<'tcx>, abi::VariantIdx)
) -> Option<ty::ScalarInt> {
desc { "computing variant tag for enum" }
}
/// Evaluates a constant and returns the computed allocation.
///
/// **Do not use this** directly, use the `eval_to_const_value` or `eval_to_valtree` instead.