]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/lib.rs
Add lowering of array lengths in types
[rust.git] / crates / hir_ty / src / lib.rs
index 6b5006f5dc106dff8550428a8e62876ea4a48a45..be3f55bdf3e76f1041aa40a58c0161223c0b0ec7 100644 (file)
@@ -7,25 +7,23 @@ macro_rules! eprintln {
 }
 
 mod autoderef;
-pub mod primitive;
-pub mod traits;
-pub mod method_resolution;
-mod op;
-mod lower;
-pub(crate) mod infer;
-pub(crate) mod utils;
-mod chalk_cast;
-mod chalk_ext;
 mod builder;
-mod walk;
-mod tls;
+mod chalk_db;
+mod chalk_ext;
+mod infer;
 mod interner;
+mod lower;
 mod mapping;
-mod chalk_db;
-
-pub mod display;
+mod op;
+mod tls;
+mod utils;
+mod walk;
 pub mod db;
 pub mod diagnostics;
+pub mod display;
+pub mod method_resolution;
+pub mod primitive;
+pub mod traits;
 
 #[cfg(test)]
 mod tests;
@@ -39,7 +37,11 @@ macro_rules! eprintln {
     interner::HasInterner,
     UintTy,
 };
-use hir_def::{expr::ExprId, type_ref::Rawness, TypeParamId};
+use hir_def::{
+    expr::ExprId,
+    type_ref::{ConstScalar, Rawness},
+    TypeParamId,
+};
 
 use crate::{db::HirDatabase, display::HirDisplay, utils::generics};
 
@@ -58,6 +60,7 @@ macro_rules! eprintln {
     to_foreign_def_id, to_placeholder_idx,
 };
 pub use traits::TraitEnvironment;
+pub use utils::all_super_traits;
 pub use walk::TypeWalk;
 
 pub use chalk_ir::{
@@ -100,6 +103,10 @@ macro_rules! eprintln {
 pub type ConcreteConst = chalk_ir::ConcreteConst<Interner>;
 
 pub type ChalkTraitId = chalk_ir::TraitId<Interner>;
+pub type TraitRef = chalk_ir::TraitRef<Interner>;
+pub type QuantifiedWhereClause = Binders<WhereClause>;
+pub type QuantifiedWhereClauses = chalk_ir::QuantifiedWhereClauses<Interner>;
+pub type Canonical<T> = chalk_ir::Canonical<T>;
 
 pub type FnSig = chalk_ir::FnSig<Interner>;
 
@@ -124,14 +131,14 @@ pub fn param_idx(db: &dyn HirDatabase, id: TypeParamId) -> Option<usize> {
     generics(db.upcast(), id.parent).param_idx(id)
 }
 
-pub fn wrap_empty_binders<T>(value: T) -> Binders<T>
+pub(crate) fn wrap_empty_binders<T>(value: T) -> Binders<T>
 where
     T: Fold<Interner, Result = T> + HasInterner<Interner = Interner>,
 {
     Binders::empty(&Interner, value.shifted_in_from(&Interner, DebruijnIndex::ONE))
 }
 
-pub fn make_only_type_binders<T: HasInterner<Interner = Interner>>(
+pub(crate) fn make_only_type_binders<T: HasInterner<Interner = Interner>>(
     num_vars: usize,
     value: T,
 ) -> Binders<T> {
@@ -159,14 +166,6 @@ pub fn make_canonical<T: HasInterner<Interner = Interner>>(
     Canonical { value, binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds) }
 }
 
-pub type TraitRef = chalk_ir::TraitRef<Interner>;
-
-pub type QuantifiedWhereClause = Binders<WhereClause>;
-
-pub type QuantifiedWhereClauses = chalk_ir::QuantifiedWhereClauses<Interner>;
-
-pub type Canonical<T> = chalk_ir::Canonical<T>;
-
 /// A function signature as seen by type inference: Several parameter types and
 /// one return type.
 #[derive(Clone, PartialEq, Eq, Debug)]
@@ -175,6 +174,8 @@ pub struct CallableSig {
     is_varargs: bool,
 }
 
+has_interner!(CallableSig);
+
 /// A polymorphic function signature.
 pub type PolyFnSig = Binders<CallableSig>;
 
@@ -238,6 +239,8 @@ pub struct ReturnTypeImplTraits {
     pub(crate) impl_traits: Vec<ReturnTypeImplTrait>,
 }
 
+has_interner!(ReturnTypeImplTraits);
+
 #[derive(Clone, PartialEq, Eq, Debug, Hash)]
 pub(crate) struct ReturnTypeImplTrait {
     pub(crate) bounds: Binders<Vec<QuantifiedWhereClause>>,
@@ -251,7 +254,9 @@ pub fn dummy_usize_const() -> Const {
     let usize_ty = chalk_ir::TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(&Interner);
     chalk_ir::ConstData {
         ty: usize_ty,
-        value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: () }),
+        value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst {
+            interned: ConstScalar::Unknown,
+        }),
     }
     .intern(&Interner)
 }