Skip to content

Commit a3fd2fa

Browse files
committed
Remove Substs from Ty::ForeignType
1 parent 0e995ad commit a3fd2fa

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

crates/hir_ty/src/display.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,9 @@ impl HirDisplay for Ty {
471471
projection_ty.hir_fmt(f)?;
472472
}
473473
}
474-
Ty::ForeignType(type_alias, parameters) => {
474+
Ty::ForeignType(type_alias) => {
475475
let type_alias = f.db.type_alias_data(*type_alias);
476476
write!(f, "{}", type_alias.name)?;
477-
if parameters.len() > 0 {
478-
write!(f, "<")?;
479-
f.write_joined(&*parameters.0, ", ")?;
480-
write!(f, ">")?;
481-
}
482477
}
483478
Ty::OpaqueType(opaque_ty_id, parameters) => {
484479
match opaque_ty_id {

crates/hir_ty/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub enum Ty {
169169
Closure { def: DefWithBodyId, expr: ExprId, substs: Substs },
170170

171171
/// Represents a foreign type declared in external blocks.
172-
ForeignType(TypeAliasId, Substs),
172+
ForeignType(TypeAliasId),
173173

174174
/// A pointer to a function. Written as `fn() -> i32`.
175175
///
@@ -755,7 +755,6 @@ impl Ty {
755755
| Ty::Tuple(_, substs)
756756
| Ty::OpaqueType(_, substs)
757757
| Ty::AssociatedType(_, substs)
758-
| Ty::ForeignType(_, substs)
759758
| Ty::Closure { substs, .. } => {
760759
assert_eq!(substs.len(), new_substs.len());
761760
*substs = new_substs;
@@ -779,7 +778,6 @@ impl Ty {
779778
| Ty::Tuple(_, substs)
780779
| Ty::OpaqueType(_, substs)
781780
| Ty::AssociatedType(_, substs)
782-
| Ty::ForeignType(_, substs)
783781
| Ty::Closure { substs, .. } => Some(substs),
784782
_ => None,
785783
}
@@ -797,7 +795,6 @@ impl Ty {
797795
| Ty::Tuple(_, substs)
798796
| Ty::OpaqueType(_, substs)
799797
| Ty::AssociatedType(_, substs)
800-
| Ty::ForeignType(_, substs)
801798
| Ty::Closure { substs, .. } => Some(substs),
802799
_ => None,
803800
}

crates/hir_ty/src/lower.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,10 +1100,10 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
11001100
let resolver = t.resolver(db.upcast());
11011101
let ctx =
11021102
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
1103-
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
11041103
if db.type_alias_data(t).is_extern {
1105-
Binders::new(substs.len(), Ty::ForeignType(t, substs))
1104+
Binders::new(0, Ty::ForeignType(t))
11061105
} else {
1106+
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
11071107
let type_ref = &db.type_alias_data(t).type_ref;
11081108
let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error));
11091109
Binders::new(substs.len(), inner)

crates/hir_ty/src/method_resolution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl Ty {
235235
Ty::Adt(def_id, _) => {
236236
return mod_to_crate_ids(def_id.module(db.upcast()));
237237
}
238-
Ty::ForeignType(type_alias_id, _) => {
238+
Ty::ForeignType(type_alias_id) => {
239239
return mod_to_crate_ids(type_alias_id.lookup(db.upcast()).module(db.upcast()));
240240
}
241241
Ty::Scalar(Scalar::Bool) => lang_item_crate!("bool"),

crates/hir_ty/src/traits/chalk/mapping.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl ToChalk for Ty {
5555
chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
5656
}
5757

58-
Ty::ForeignType(type_alias, _) => {
58+
Ty::ForeignType(type_alias) => {
5959
let foreign_type = TypeAliasAsForeignType(type_alias);
6060
let foreign_type_id = foreign_type.to_chalk(db);
6161
chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner)
@@ -221,10 +221,9 @@ impl ToChalk for Ty {
221221
Ty::Closure { def, expr, substs: from_chalk(db, subst) }
222222
}
223223

224-
chalk_ir::TyKind::Foreign(foreign_def_id) => Ty::ForeignType(
225-
from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0,
226-
Substs::empty(),
227-
),
224+
chalk_ir::TyKind::Foreign(foreign_def_id) => {
225+
Ty::ForeignType(from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0)
226+
}
228227
chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME
229228
chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME
230229
}

0 commit comments

Comments
 (0)