1
Fork 0

check the types in ty::Value to value conversion

and remove `ty::Const::try_to_scalar` because it becomes redundant
This commit is contained in:
Lukas Markeffsky 2025-01-27 11:16:19 +00:00
parent 10fc0b159e
commit 0055fb92db
7 changed files with 75 additions and 22 deletions

View file

@ -51,8 +51,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TransformTy<'tcx> {
// Transforms a ty:Ty for being encoded and used in the substitution dictionary.
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
match t.kind() {
ty::Array(..)
| ty::Closure(..)
ty::Closure(..)
| ty::Coroutine(..)
| ty::CoroutineClosure(..)
| ty::CoroutineWitness(..)
@ -67,6 +66,13 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TransformTy<'tcx> {
| ty::Tuple(..)
| ty::UnsafeBinder(_) => t.super_fold_with(self),
// Don't transform the type of the array length and keep it as `usize`.
// This is required for `try_to_target_usize` to work correctly.
&ty::Array(inner, len) => {
let inner = self.fold_ty(inner);
Ty::new_array_with_const_len(self.tcx, inner, len)
}
ty::Bool => {
if self.options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
// Note: on all platforms that Rust's currently supports, its size and alignment