about summary refs log tree commit diff
diff options
context:
space:
mode:
authorroife <roifewu@gmail.com>2024-12-10 02:47:52 +0800
committerroife <roifewu@gmail.com>2024-12-10 02:47:52 +0800
commitab6382e4609a94c095b4df409a8ab1c0da953c1d (patch)
tree76a8782e691c1c9336740a5b1c9571d895ff3931
parent91adfec2f0fd4e3a84acf644436a50b4b1f487d8 (diff)
downloadrust-ab6382e4609a94c095b4df409a8ab1c0da953c1d.tar.gz
rust-ab6382e4609a94c095b4df409a8ab1c0da953c1d.zip
minor: enhance name suggestion for `Arc<T>` and `Rc<T>`
-rw-r--r--src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs b/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs
index 2679cbef61b..b3ecc26cb22 100644
--- a/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs
+++ b/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs
@@ -29,7 +29,7 @@ const USELESS_NAME_PREFIXES: &[&str] = &["from_", "with_", "into_"];
 /// # Examples
 /// `Option<Name>` -> `Name`
 /// `Result<User, Error>` -> `User`
-const WRAPPER_TYPES: &[&str] = &["Box", "Option", "Result"];
+const WRAPPER_TYPES: &[&str] = &["Box", "Arc", "Rc", "Option", "Result"];
 
 /// Prefixes to strip from methods names
 ///
@@ -859,6 +859,32 @@ fn foo() { $0(bar())$0; }
     }
 
     #[test]
+    fn arc_value() {
+        check(
+            r#"
+struct Arc<T>(*const T);
+struct Seed;
+fn bar() -> Arc<Seed> {}
+fn foo() { $0(bar())$0; }
+"#,
+            "seed",
+        );
+    }
+
+    #[test]
+    fn rc_value() {
+        check(
+            r#"
+struct Rc<T>(*const T);
+struct Seed;
+fn bar() -> Rc<Seed> {}
+fn foo() { $0(bar())$0; }
+"#,
+            "seed",
+        );
+    }
+
+    #[test]
     fn ref_call() {
         check(
             r#"