Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakis
Refractor a few more types to `rustc_type_ir` In the continuation of #79169, ~~blocked on that PR~~. This PR: - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance` - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler. ~~I will split up that commit to make this easier to review and to have a better commit history.~~ EDIT: done, I split the PR in commits of 200-ish lines each r? `````@nikomatsakis````` cc `````@jackh726`````
This commit is contained in:
commit
446edd1e1a
46 changed files with 818 additions and 565 deletions
|
@ -2,13 +2,11 @@ use std::convert::TryFrom;
|
|||
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
use rustc_apfloat::{Float, FloatConvert};
|
||||
use rustc_ast::FloatTy;
|
||||
use rustc_attr as attr;
|
||||
use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar};
|
||||
use rustc_middle::mir::CastKind;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty, TypeAndMut};
|
||||
use rustc_middle::ty::{self, FloatTy, Ty, TypeAndMut};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{Integer, LayoutOf, Variants};
|
||||
|
||||
|
@ -203,8 +201,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
match *cast_ty.kind() {
|
||||
Int(_) | Uint(_) | RawPtr(_) => {
|
||||
let size = match *cast_ty.kind() {
|
||||
Int(t) => Integer::from_attr(self, attr::IntType::SignedInt(t)).size(),
|
||||
Uint(t) => Integer::from_attr(self, attr::IntType::UnsignedInt(t)).size(),
|
||||
Int(t) => Integer::from_int_ty(self, t).size(),
|
||||
Uint(t) => Integer::from_uint_ty(self, t).size(),
|
||||
RawPtr(_) => self.pointer_size(),
|
||||
_ => bug!(),
|
||||
};
|
||||
|
@ -235,7 +233,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
match *dest_ty.kind() {
|
||||
// float -> uint
|
||||
Uint(t) => {
|
||||
let size = Integer::from_attr(self, attr::IntType::UnsignedInt(t)).size();
|
||||
let size = Integer::from_uint_ty(self, t).size();
|
||||
// `to_u128` is a saturating cast, which is what we need
|
||||
// (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
|
||||
let v = f.to_u128(size.bits_usize()).value;
|
||||
|
@ -244,7 +242,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
// float -> int
|
||||
Int(t) => {
|
||||
let size = Integer::from_attr(self, attr::IntType::SignedInt(t)).size();
|
||||
let size = Integer::from_int_ty(self, t).size();
|
||||
// `to_i128` is a saturating cast, which is what we need
|
||||
// (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
|
||||
let v = f.to_i128(size.bits_usize()).value;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use std::convert::TryFrom;
|
||||
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_ast::FloatTy;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{InterpResult, Scalar};
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, FloatTy, Ty};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue