extract const generic in ArrayType

This commit is contained in:
Kartavya Vashishtha 2022-08-25 13:11:51 +05:30
parent 71c15f2a44
commit 9480b38189
No known key found for this signature in database
GPG key ID: A50012C2324E5DF0

View file

@ -171,6 +171,25 @@ fn collect_used_generics<'gp>(
ast::Type::RefType(ref_) => generics.extend(
ref_.lifetime().and_then(|lt| known_generics.iter().find(find_lifetime(&lt.text()))),
),
ast::Type::ArrayType(ar) => {
if let Some(expr) = ar.expr() {
if let ast::Expr::PathExpr(p) = expr {
if let Some(path) = p.path() {
if let Some(name_ref) = path.as_single_name_ref() {
if let Some(param) = known_generics.iter().find(|gp| {
if let ast::GenericParam::ConstParam(cp) = gp {
cp.name().map_or(false, |n| n.text() == name_ref.text())
} else {
false
}
}) {
generics.push(param);
}
}
}
}
}
},
_ => (),
});
// stable resort to lifetime, type, const