diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs index 136b9a55b94..ae084c86c2f 100644 --- a/crates/ide_assists/src/handlers/extract_variable.rs +++ b/crates/ide_assists/src/handlers/extract_variable.rs @@ -54,7 +54,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option let var_name = match &field_shorthand { Some(it) => it.to_string(), - None => suggest_name::variable(&to_extract, &ctx.sema), + None => suggest_name::for_variable(&to_extract, &ctx.sema), }; let expr_range = match &field_shorthand { Some(it) => it.syntax().text_range().cover(to_extract.syntax().text_range()), diff --git a/crates/ide_assists/src/handlers/replace_impl_trait_with_generic.rs b/crates/ide_assists/src/handlers/replace_impl_trait_with_generic.rs index 26a0e81f0ea..899c773df5a 100644 --- a/crates/ide_assists/src/handlers/replace_impl_trait_with_generic.rs +++ b/crates/ide_assists/src/handlers/replace_impl_trait_with_generic.rs @@ -29,7 +29,7 @@ pub(crate) fn replace_impl_trait_with_generic( "Replace impl trait with generic", target, |edit| { - let type_param_name = suggest_name::generic_parameter(&impl_trait_type); + let type_param_name = suggest_name::for_generic_parameter(&impl_trait_type); let generic_param_list = fn_ .generic_param_list() diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs index c8487846d7e..b3aabeab37a 100644 --- a/crates/ide_assists/src/utils/suggest_name.rs +++ b/crates/ide_assists/src/utils/suggest_name.rs @@ -57,7 +57,7 @@ const USELESS_METHODS: &[&str] = &[ "iter_mut", ]; -pub(crate) fn generic_parameter(ty: &ast::ImplTraitType) -> SmolStr { +pub(crate) fn for_generic_parameter(ty: &ast::ImplTraitType) -> SmolStr { let c = ty .type_bound_list() .and_then(|bounds| bounds.syntax().text().char_at(0.into())) @@ -83,7 +83,8 @@ pub(crate) fn generic_parameter(ty: &ast::ImplTraitType) -> SmolStr { /// It also applies heuristics to filter out less informative names /// /// Currently it sticks to the first name found. -pub(crate) fn variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> String { +// FIXME: Microoptimize and return a `SmolStr` here. +pub(crate) fn for_variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> String { // `from_param` does not benifit from stripping // it need the largest context possible // so we check firstmost @@ -284,7 +285,7 @@ mod tests { frange.range, "selection is not an expression(yet contained in one)" ); - let name = variable(&expr, &sema); + let name = for_variable(&expr, &sema); assert_eq!(&name, expected); }