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:
Yuki Okushi 2021-01-28 15:09:02 +09:00 committed by GitHub
commit 446edd1e1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 818 additions and 565 deletions

View file

@ -11,7 +11,6 @@ use std::{slice, vec};
use rustc_ast::attr;
use rustc_ast::util::comments::beautify_doc_string;
use rustc_ast::{self as ast, AttrStyle};
use rustc_ast::{FloatTy, IntTy, UintTy};
use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_feature::UnstableFeatures;
@ -21,7 +20,7 @@ use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::lang_items::LangItem;
use rustc_hir::Mutability;
use rustc_index::vec::IndexVec;
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::Session;
use rustc_span::hygiene::MacroKind;
use rustc_span::source_map::DUMMY_SP;
@ -1456,6 +1455,7 @@ impl GetDefId for Type {
impl PrimitiveType {
crate fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
use ast::{FloatTy, IntTy, UintTy};
match prim {
hir::PrimTy::Int(IntTy::Isize) => PrimitiveType::Isize,
hir::PrimTy::Int(IntTy::I8) => PrimitiveType::I8,
@ -1690,6 +1690,41 @@ impl From<ast::FloatTy> for PrimitiveType {
}
}
impl From<ty::IntTy> for PrimitiveType {
fn from(int_ty: ty::IntTy) -> PrimitiveType {
match int_ty {
ty::IntTy::Isize => PrimitiveType::Isize,
ty::IntTy::I8 => PrimitiveType::I8,
ty::IntTy::I16 => PrimitiveType::I16,
ty::IntTy::I32 => PrimitiveType::I32,
ty::IntTy::I64 => PrimitiveType::I64,
ty::IntTy::I128 => PrimitiveType::I128,
}
}
}
impl From<ty::UintTy> for PrimitiveType {
fn from(uint_ty: ty::UintTy) -> PrimitiveType {
match uint_ty {
ty::UintTy::Usize => PrimitiveType::Usize,
ty::UintTy::U8 => PrimitiveType::U8,
ty::UintTy::U16 => PrimitiveType::U16,
ty::UintTy::U32 => PrimitiveType::U32,
ty::UintTy::U64 => PrimitiveType::U64,
ty::UintTy::U128 => PrimitiveType::U128,
}
}
}
impl From<ty::FloatTy> for PrimitiveType {
fn from(float_ty: ty::FloatTy) -> PrimitiveType {
match float_ty {
ty::FloatTy::F32 => PrimitiveType::F32,
ty::FloatTy::F64 => PrimitiveType::F64,
}
}
}
impl From<hir::PrimTy> for PrimitiveType {
fn from(prim_ty: hir::PrimTy) -> PrimitiveType {
match prim_ty {