From a3fd2faba5b0736fd51c7b94cae55e0a9609cdb0 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 28 Feb 2021 20:44:09 +0100 Subject: Remove Substs from Ty::ForeignType --- crates/hir_ty/src/display.rs | 7 +------ crates/hir_ty/src/lib.rs | 5 +---- crates/hir_ty/src/lower.rs | 4 ++-- crates/hir_ty/src/method_resolution.rs | 2 +- crates/hir_ty/src/traits/chalk/mapping.rs | 9 ++++----- 5 files changed, 9 insertions(+), 18 deletions(-) (limited to 'crates/hir_ty') 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 { projection_ty.hir_fmt(f)?; } } - Ty::ForeignType(type_alias, parameters) => { + Ty::ForeignType(type_alias) => { let type_alias = f.db.type_alias_data(*type_alias); write!(f, "{}", type_alias.name)?; - if parameters.len() > 0 { - write!(f, "<")?; - f.write_joined(&*parameters.0, ", ")?; - write!(f, ">")?; - } } Ty::OpaqueType(opaque_ty_id, parameters) => { 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 { Closure { def: DefWithBodyId, expr: ExprId, substs: Substs }, /// Represents a foreign type declared in external blocks. - ForeignType(TypeAliasId, Substs), + ForeignType(TypeAliasId), /// A pointer to a function. Written as `fn() -> i32`. /// @@ -755,7 +755,6 @@ impl Ty { | Ty::Tuple(_, substs) | Ty::OpaqueType(_, substs) | Ty::AssociatedType(_, substs) - | Ty::ForeignType(_, substs) | Ty::Closure { substs, .. } => { assert_eq!(substs.len(), new_substs.len()); *substs = new_substs; @@ -779,7 +778,6 @@ impl Ty { | Ty::Tuple(_, substs) | Ty::OpaqueType(_, substs) | Ty::AssociatedType(_, substs) - | Ty::ForeignType(_, substs) | Ty::Closure { substs, .. } => Some(substs), _ => None, } @@ -797,7 +795,6 @@ impl Ty { | Ty::Tuple(_, substs) | Ty::OpaqueType(_, substs) | Ty::AssociatedType(_, substs) - | Ty::ForeignType(_, substs) | Ty::Closure { substs, .. } => Some(substs), _ => None, } 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 { let resolver = t.resolver(db.upcast()); let ctx = TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); - let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST); if db.type_alias_data(t).is_extern { - Binders::new(substs.len(), Ty::ForeignType(t, substs)) + Binders::new(0, Ty::ForeignType(t)) } else { + let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST); let type_ref = &db.type_alias_data(t).type_ref; let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error)); 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 { Ty::Adt(def_id, _) => { return mod_to_crate_ids(def_id.module(db.upcast())); } - Ty::ForeignType(type_alias_id, _) => { + Ty::ForeignType(type_alias_id) => { return mod_to_crate_ids(type_alias_id.lookup(db.upcast()).module(db.upcast())); } 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 { chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) } - Ty::ForeignType(type_alias, _) => { + Ty::ForeignType(type_alias) => { let foreign_type = TypeAliasAsForeignType(type_alias); let foreign_type_id = foreign_type.to_chalk(db); chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner) @@ -221,10 +221,9 @@ impl ToChalk for Ty { Ty::Closure { def, expr, substs: from_chalk(db, subst) } } - chalk_ir::TyKind::Foreign(foreign_def_id) => Ty::ForeignType( - from_chalk::(db, foreign_def_id).0, - Substs::empty(), - ), + chalk_ir::TyKind::Foreign(foreign_def_id) => { + Ty::ForeignType(from_chalk::(db, foreign_def_id).0) + } chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME } -- cgit v1.2.3