Skip to content

Commit 5b9da60

Browse files
committed
more test
1 parent 6540616 commit 5b9da60

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

crates/ide-completion/src/render.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ fn test() {
20672067
// Direct Constructor with args
20682068
// Builder
20692069
// Constructor
2070-
// fn with param that returns itself
2070+
// Others
20712071
expect![[r#"
20722072
fn fn_direct_ctr() [type_could_unify]
20732073
fn fn_ctr_with_args(…) [type_could_unify]
@@ -2078,6 +2078,48 @@ fn test() {
20782078
"#]],
20792079
);
20802080

2081+
// Expected 1
2082+
check_relevance(
2083+
r#"
2084+
struct Random;
2085+
2086+
impl Random {
2087+
fn get_i32(&self) -> i32 {}
2088+
fn get_string(&self) -> String {}
2089+
}
2090+
2091+
fn test() {
2092+
let r = Random;
2093+
let name: String = r.$0;
2094+
}
2095+
"#,
2096+
expect![[r#"
2097+
me get_string() [type]
2098+
me get_i32() [type_could_unify]
2099+
"#]],
2100+
);
2101+
2102+
// Expected 2
2103+
check_relevance(
2104+
r#"
2105+
struct Random;
2106+
2107+
impl Random {
2108+
fn get_i32(&self) -> i32 {}
2109+
fn get_string(&self) -> String {}
2110+
}
2111+
2112+
fn age() -> i32 {
2113+
let r = Random;
2114+
r.$0
2115+
}
2116+
"#,
2117+
expect![[r#"
2118+
me get_i32() [type]
2119+
me get_string() [type_could_unify]
2120+
"#]],
2121+
);
2122+
20812123
// Generic 1
20822124
check_relevance(
20832125
r#"

crates/ide-completion/src/render/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn compute_associated_fn(
199199
// let _: u32 = foo.$0; // baz is preferred as it returns expected u32
200200
CompletionRelevanceAssociatedFnType::ReturnsExpectedType
201201
} else if ret_type.display(db).to_string().ends_with("Builder") {
202-
// -> [..]Builder
202+
// fn([..]) -> [..]Builder
203203
CompletionRelevanceAssociatedFnType::Builder
204204
} else if returns_self_wrapped {
205205
// fn([..]) -> Result<A>

0 commit comments

Comments
 (0)