Add diagnostic for _ expressions (typed holes)

This commit is contained in:
Lukas Wirth 2023-05-28 13:30:34 +02:00
parent 150082b0e3
commit 8bc826dd53
9 changed files with 368 additions and 61 deletions

View file

@ -194,6 +194,19 @@ impl TyBuilder<()> {
params.placeholder_subst(db)
}
pub fn unknown_subst(db: &dyn HirDatabase, def: impl Into<GenericDefId>) -> Substitution {
let params = generics(db.upcast(), def.into());
Substitution::from_iter(
Interner,
params.iter_id().map(|id| match id {
either::Either::Left(_) => TyKind::Error.intern(Interner).cast(Interner),
either::Either::Right(id) => {
unknown_const_as_generic(db.const_param_ty(id)).cast(Interner)
}
}),
)
}
pub fn subst_for_def(
db: &dyn HirDatabase,
def: impl Into<GenericDefId>,