Skip to content

Commit 9c03cbb

Browse files
committed
minor: enhance name suggestion for Arc<T> and Rc<T>
1 parent 99a6ecd commit 9c03cbb

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

crates/ide-db/src/syntax_helpers/suggest_name.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const USELESS_NAME_PREFIXES: &[&str] = &["from_", "with_", "into_"];
2929
/// # Examples
3030
/// `Option<Name>` -> `Name`
3131
/// `Result<User, Error>` -> `User`
32-
const WRAPPER_TYPES: &[&str] = &["Box", "Option", "Result"];
32+
const WRAPPER_TYPES: &[&str] = &["Box", "Arc", "Rc", "Option", "Result"];
3333

3434
/// Prefixes to strip from methods names
3535
///
@@ -858,6 +858,32 @@ fn foo() { $0(bar())$0; }
858858
);
859859
}
860860

861+
#[test]
862+
fn arc_value() {
863+
check(
864+
r#"
865+
struct Arc<T>(*const T);
866+
struct Seed;
867+
fn bar() -> Arc<Seed> {}
868+
fn foo() { $0(bar())$0; }
869+
"#,
870+
"seed",
871+
);
872+
}
873+
874+
#[test]
875+
fn rc_value() {
876+
check(
877+
r#"
878+
struct Rc<T>(*const T);
879+
struct Seed;
880+
fn bar() -> Rc<Seed> {}
881+
fn foo() { $0(bar())$0; }
882+
"#,
883+
"seed",
884+
);
885+
}
886+
861887
#[test]
862888
fn ref_call() {
863889
check(

0 commit comments

Comments
 (0)