about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@users.noreply.github.com>2024-12-10 07:05:36 +0000
committerGitHub <noreply@github.com>2024-12-10 07:05:36 +0000
commit95670acff171f66d880faf798c7c9ee0ef8e97e0 (patch)
treeb7c0b85805b7383246ab02619be0b7ec01e57389 /src/tools/rust-analyzer/crates
parentedbfa31401f1c03bf07473181830b4c17af844d0 (diff)
parentab6382e4609a94c095b4df409a8ab1c0da953c1d (diff)
downloadrust-95670acff171f66d880faf798c7c9ee0ef8e97e0.tar.gz
rust-95670acff171f66d880faf798c7c9ee0ef8e97e0.zip
Merge pull request #18649 from roife/fix-issue-18648
minor: enhance name suggestion for `Arc<T>` and `Rc<T>`
Diffstat (limited to 'src/tools/rust-analyzer/crates')
-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#"