Merge pull request #18649 from roife/fix-issue-18648

minor: enhance name suggestion for `Arc<T>` and `Rc<T>`
This commit is contained in:
Laurențiu Nicola
2024-12-10 07:05:36 +00:00
committed by GitHub
@@ -29,7 +29,7 @@
/// # 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
///
@@ -858,6 +858,32 @@ fn bar() -> Result<Seed, Error> {}
);
}
#[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(