From 9c03cbb49945efbde60d0d46daa4e087aa469d86 Mon Sep 17 00:00:00 2001 From: roife Date: Tue, 10 Dec 2024 02:47:52 +0800 Subject: [PATCH] minor: enhance name suggestion for `Arc` and `Rc` --- .../ide-db/src/syntax_helpers/suggest_name.rs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/ide-db/src/syntax_helpers/suggest_name.rs b/crates/ide-db/src/syntax_helpers/suggest_name.rs index 2679cbef61..b3ecc26cb2 100644 --- a/crates/ide-db/src/syntax_helpers/suggest_name.rs +++ b/crates/ide-db/src/syntax_helpers/suggest_name.rs @@ -29,7 +29,7 @@ const USELESS_NAME_PREFIXES: &[&str] = &["from_", "with_", "into_"]; /// # Examples /// `Option` -> `Name` /// `Result` -> `User` -const WRAPPER_TYPES: &[&str] = &["Box", "Option", "Result"]; +const WRAPPER_TYPES: &[&str] = &["Box", "Arc", "Rc", "Option", "Result"]; /// Prefixes to strip from methods names /// @@ -858,6 +858,32 @@ fn foo() { $0(bar())$0; } ); } + #[test] + fn arc_value() { + check( + r#" +struct Arc(*const T); +struct Seed; +fn bar() -> Arc {} +fn foo() { $0(bar())$0; } +"#, + "seed", + ); + } + + #[test] + fn rc_value() { + check( + r#" +struct Rc(*const T); +struct Seed; +fn bar() -> Rc {} +fn foo() { $0(bar())$0; } +"#, + "seed", + ); + } + #[test] fn ref_call() { check(