Skip to content

Commit

Permalink
Merge pull request #18649 from roife/fix-issue-18648
Browse files Browse the repository at this point in the history
minor: enhance name suggestion for `Arc<T>` and `Rc<T>`
  • Loading branch information
lnicola authored Dec 10, 2024
2 parents 54879d9 + 9c03cbb commit 7b4b83b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion crates/ide-db/src/syntax_helpers/suggest_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -858,6 +858,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(
Expand Down

0 comments on commit 7b4b83b

Please sign in to comment.