Auto merge of #12695 - xuhongxu96:fix-12140, r=jonas-schievink

Complete type param/associated type in trait generic arg per arg index

- Fix #12140
- Also fix tidy check does not work for marks in multiline
This commit is contained in:
bors 2022-07-06 23:58:52 +00:00
commit c296e77767
5 changed files with 347 additions and 50 deletions

View file

@ -47,6 +47,7 @@ pub struct LifetimeParamData {
pub struct ConstParamData {
pub name: Name,
pub ty: Interned<TypeRef>,
pub has_default: bool,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
@ -70,6 +71,13 @@ impl TypeOrConstParamData {
}
}
pub fn has_default(&self) -> bool {
match self {
TypeOrConstParamData::TypeParamData(x) => x.default.is_some(),
TypeOrConstParamData::ConstParamData(x) => x.has_default,
}
}
pub fn type_param(&self) -> Option<&TypeParamData> {
match self {
TypeOrConstParamData::TypeParamData(x) => Some(x),
@ -232,7 +240,11 @@ impl GenericParams {
let ty = const_param
.ty()
.map_or(TypeRef::Error, |it| TypeRef::from_ast(lower_ctx, it));
let param = ConstParamData { name, ty: Interned::new(ty) };
let param = ConstParamData {
name,
ty: Interned::new(ty),
has_default: const_param.default_val().is_some(),
};
self.type_or_consts.alloc(param.into());
}
}