From 9480b38189f1246fc96a58036fcfbc5527ae6516 Mon Sep 17 00:00:00 2001 From: Kartavya Vashishtha Date: Thu, 25 Aug 2022 13:11:51 +0530 Subject: [PATCH] extract const generic in ArrayType --- .../src/handlers/extract_type_alias.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/ide-assists/src/handlers/extract_type_alias.rs b/crates/ide-assists/src/handlers/extract_type_alias.rs index c0586169bc..0e031a793b 100644 --- a/crates/ide-assists/src/handlers/extract_type_alias.rs +++ b/crates/ide-assists/src/handlers/extract_type_alias.rs @@ -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(<.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