aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/display.rs7
-rw-r--r--crates/hir_ty/src/lib.rs5
-rw-r--r--crates/hir_ty/src/lower.rs4
-rw-r--r--crates/hir_ty/src/method_resolution.rs2
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs9
5 files changed, 9 insertions, 18 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 666bb1f9d..4a25a49e3 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -471,14 +471,9 @@ impl HirDisplay for Ty {
471 projection_ty.hir_fmt(f)?; 471 projection_ty.hir_fmt(f)?;
472 } 472 }
473 } 473 }
474 Ty::ForeignType(type_alias, parameters) => { 474 Ty::ForeignType(type_alias) => {
475 let type_alias = f.db.type_alias_data(*type_alias); 475 let type_alias = f.db.type_alias_data(*type_alias);
476 write!(f, "{}", type_alias.name)?; 476 write!(f, "{}", type_alias.name)?;
477 if parameters.len() > 0 {
478 write!(f, "<")?;
479 f.write_joined(&*parameters.0, ", ")?;
480 write!(f, ">")?;
481 }
482 } 477 }
483 Ty::OpaqueType(opaque_ty_id, parameters) => { 478 Ty::OpaqueType(opaque_ty_id, parameters) => {
484 match opaque_ty_id { 479 match opaque_ty_id {
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 3d134453f..4c0ebcfe3 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -169,7 +169,7 @@ pub enum Ty {
169 Closure { def: DefWithBodyId, expr: ExprId, substs: Substs }, 169 Closure { def: DefWithBodyId, expr: ExprId, substs: Substs },
170 170
171 /// Represents a foreign type declared in external blocks. 171 /// Represents a foreign type declared in external blocks.
172 ForeignType(TypeAliasId, Substs), 172 ForeignType(TypeAliasId),
173 173
174 /// A pointer to a function. Written as `fn() -> i32`. 174 /// A pointer to a function. Written as `fn() -> i32`.
175 /// 175 ///
@@ -755,7 +755,6 @@ impl Ty {
755 | Ty::Tuple(_, substs) 755 | Ty::Tuple(_, substs)
756 | Ty::OpaqueType(_, substs) 756 | Ty::OpaqueType(_, substs)
757 | Ty::AssociatedType(_, substs) 757 | Ty::AssociatedType(_, substs)
758 | Ty::ForeignType(_, substs)
759 | Ty::Closure { substs, .. } => { 758 | Ty::Closure { substs, .. } => {
760 assert_eq!(substs.len(), new_substs.len()); 759 assert_eq!(substs.len(), new_substs.len());
761 *substs = new_substs; 760 *substs = new_substs;
@@ -779,7 +778,6 @@ impl Ty {
779 | Ty::Tuple(_, substs) 778 | Ty::Tuple(_, substs)
780 | Ty::OpaqueType(_, substs) 779 | Ty::OpaqueType(_, substs)
781 | Ty::AssociatedType(_, substs) 780 | Ty::AssociatedType(_, substs)
782 | Ty::ForeignType(_, substs)
783 | Ty::Closure { substs, .. } => Some(substs), 781 | Ty::Closure { substs, .. } => Some(substs),
784 _ => None, 782 _ => None,
785 } 783 }
@@ -797,7 +795,6 @@ impl Ty {
797 | Ty::Tuple(_, substs) 795 | Ty::Tuple(_, substs)
798 | Ty::OpaqueType(_, substs) 796 | Ty::OpaqueType(_, substs)
799 | Ty::AssociatedType(_, substs) 797 | Ty::AssociatedType(_, substs)
800 | Ty::ForeignType(_, substs)
801 | Ty::Closure { substs, .. } => Some(substs), 798 | Ty::Closure { substs, .. } => Some(substs),
802 _ => None, 799 _ => None,
803 } 800 }
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 8295f4c31..84734bc0b 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -1100,10 +1100,10 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
1100 let resolver = t.resolver(db.upcast()); 1100 let resolver = t.resolver(db.upcast());
1101 let ctx = 1101 let ctx =
1102 TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); 1102 TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
1103 let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
1104 if db.type_alias_data(t).is_extern { 1103 if db.type_alias_data(t).is_extern {
1105 Binders::new(substs.len(), Ty::ForeignType(t, substs)) 1104 Binders::new(0, Ty::ForeignType(t))
1106 } else { 1105 } else {
1106 let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
1107 let type_ref = &db.type_alias_data(t).type_ref; 1107 let type_ref = &db.type_alias_data(t).type_ref;
1108 let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error)); 1108 let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error));
1109 Binders::new(substs.len(), inner) 1109 Binders::new(substs.len(), inner)
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 422e61f0a..ff8ce5599 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -235,7 +235,7 @@ impl Ty {
235 Ty::Adt(def_id, _) => { 235 Ty::Adt(def_id, _) => {
236 return mod_to_crate_ids(def_id.module(db.upcast())); 236 return mod_to_crate_ids(def_id.module(db.upcast()));
237 } 237 }
238 Ty::ForeignType(type_alias_id, _) => { 238 Ty::ForeignType(type_alias_id) => {
239 return mod_to_crate_ids(type_alias_id.lookup(db.upcast()).module(db.upcast())); 239 return mod_to_crate_ids(type_alias_id.lookup(db.upcast()).module(db.upcast()));
240 } 240 }
241 Ty::Scalar(Scalar::Bool) => lang_item_crate!("bool"), 241 Ty::Scalar(Scalar::Bool) => lang_item_crate!("bool"),
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 09e5a82b8..c17c19638 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -55,7 +55,7 @@ impl ToChalk for Ty {
55 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) 55 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
56 } 56 }
57 57
58 Ty::ForeignType(type_alias, _) => { 58 Ty::ForeignType(type_alias) => {
59 let foreign_type = TypeAliasAsForeignType(type_alias); 59 let foreign_type = TypeAliasAsForeignType(type_alias);
60 let foreign_type_id = foreign_type.to_chalk(db); 60 let foreign_type_id = foreign_type.to_chalk(db);
61 chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner) 61 chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner)
@@ -221,10 +221,9 @@ impl ToChalk for Ty {
221 Ty::Closure { def, expr, substs: from_chalk(db, subst) } 221 Ty::Closure { def, expr, substs: from_chalk(db, subst) }
222 } 222 }
223 223
224 chalk_ir::TyKind::Foreign(foreign_def_id) => Ty::ForeignType( 224 chalk_ir::TyKind::Foreign(foreign_def_id) => {
225 from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0, 225 Ty::ForeignType(from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0)
226 Substs::empty(), 226 }
227 ),
228 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME 227 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME
229 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME 228 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME
230 } 229 }