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
commit 7b4b83ba91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
///
@ -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(