Skip to content

Commit 4494f87

Browse files
authored
Merge pull request rust-lang#20792 from A4-Tacks/minor-fix-make-extract-ty-alias
minor: Fix using `make::ty` for extract_type_alias
2 parents 8f312c2 + 8607cfe commit 4494f87

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_type_alias.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) ->
6161
generics.map(|it| make::generic_param_list(it.into_iter().cloned()));
6262

6363
// Replace original type with the alias
64-
let ty_args = generic_params
65-
.as_ref()
66-
.map_or(String::new(), |it| it.to_generic_args().to_string());
67-
// FIXME: replace with a `ast::make` constructor
68-
let new_ty = make::ty(&format!("Type{ty_args}")).clone_for_update();
64+
let ty_args = generic_params.as_ref().map(|it| it.to_generic_args().generic_args());
65+
let new_ty = if let Some(ty_args) = ty_args {
66+
make::generic_ty_path_segment(make::name_ref("Type"), ty_args)
67+
} else {
68+
make::path_segment(make::name_ref("Type"))
69+
}
70+
.clone_for_update();
6971
edit.replace(ty.syntax(), new_ty.syntax());
7072

7173
// Insert new alias

0 commit comments

Comments
 (0)