Skip to content

Commit 9d6061f

Browse files
committed
Fix some TODOs
1 parent 6b9d05d commit 9d6061f

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

crates/ra_hir_ty/src/infer/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
587587
self.write_method_resolution(tgt_expr, func);
588588
(ty, self.db.value_ty(func.into()), Some(generics(self.db, func.into())))
589589
}
590-
// TODO fix this
591590
None => (receiver_ty, Binders::new(0, Ty::Unknown), None),
592591
};
593592
let substs = self.substs_for_method_call(def_generics, generic_args, &derefed_receiver_ty);

crates/ra_hir_ty/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,20 @@ pub enum Ty {
287287
/// trait and all its parameters are fully known.
288288
Projection(ProjectionTy),
289289

290-
/// A type parameter; for example, `T` in `fn f<T>(x: T) {}
291-
// TODO fix documentation
290+
/// A placeholder for a type parameter; for example, `T` in `fn f<T>(x: T)
291+
/// {}` when we're type-checking the body of that function. In this
292+
/// situation, we know this stands for *some* type, but don't know the exact
293+
/// type.
292294
Param(TypeParamId),
293295

294-
/// A bound type variable. Used during trait resolution to represent Chalk
295-
/// variables, and in `Dyn` and `Opaque` bounds to represent the `Self` type.
296-
// TODO fix documentation
296+
/// A bound type variable. This is used in various places: when representing
297+
/// some polymorphic type like the type of function `fn f<T>`, the type
298+
/// parameters get turned into variables; during trait resolution, inference
299+
/// variables get turned into bound variables and back; and in `Dyn` the
300+
/// `Self` type is represented with a bound variable as well.
297301
Bound(u32),
298302

299-
/// A type variable used during type checking. Not to be confused with a
300-
/// type parameter.
303+
/// A type variable used during type checking.
301304
Infer(InferTy),
302305

303306
/// A trait object (`dyn Trait` or bare `Trait` in pre-2018 Rust).

crates/ra_hir_ty/src/lower.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,13 @@ pub(crate) fn ty_query(db: &impl HirDatabase, def: TyDefId) -> Binders<Ty> {
890890
}
891891
}
892892

893-
pub(crate) fn ty_recover(_db: &impl HirDatabase, _cycle: &[String], _def: &TyDefId) -> Binders<Ty> {
894-
// TODO still need correct number of binders here
895-
Binders::new(0, Ty::Unknown)
893+
pub(crate) fn ty_recover(db: &impl HirDatabase, _cycle: &[String], def: &TyDefId) -> Binders<Ty> {
894+
let num_binders = match *def {
895+
TyDefId::BuiltinType(_) => 0,
896+
TyDefId::AdtId(it) => generics(db, it.into()).len(),
897+
TyDefId::TypeAliasId(it) => generics(db, it.into()).len(),
898+
};
899+
Binders::new(num_binders, Ty::Unknown)
896900
}
897901

898902
pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Binders<Ty> {

0 commit comments

Comments
 (0)