File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed
crates/ide-completion/src Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -2070,7 +2070,7 @@ fn test() {
2070
2070
// Direct Constructor with args
2071
2071
// Builder
2072
2072
// Constructor
2073
- // fn with param that returns itself
2073
+ // Others
2074
2074
expect ! [ [ r#"
2075
2075
fn fn_direct_ctr() [type_could_unify]
2076
2076
fn fn_ctr_with_args(…) [type_could_unify]
@@ -2081,6 +2081,48 @@ fn test() {
2081
2081
"# ] ] ,
2082
2082
) ;
2083
2083
2084
+ // Expected 1
2085
+ check_relevance (
2086
+ r#"
2087
+ struct Random;
2088
+
2089
+ impl Random {
2090
+ fn get_i32(&self) -> i32 {}
2091
+ fn get_string(&self) -> String {}
2092
+ }
2093
+
2094
+ fn test() {
2095
+ let r = Random;
2096
+ let name: String = r.$0;
2097
+ }
2098
+ "# ,
2099
+ expect ! [ [ r#"
2100
+ me get_string() [type]
2101
+ me get_i32() [type_could_unify]
2102
+ "# ] ] ,
2103
+ ) ;
2104
+
2105
+ // Expected 2
2106
+ check_relevance (
2107
+ r#"
2108
+ struct Random;
2109
+
2110
+ impl Random {
2111
+ fn get_i32(&self) -> i32 {}
2112
+ fn get_string(&self) -> String {}
2113
+ }
2114
+
2115
+ fn age() -> i32 {
2116
+ let r = Random;
2117
+ r.$0
2118
+ }
2119
+ "# ,
2120
+ expect ! [ [ r#"
2121
+ me get_i32() [type]
2122
+ me get_string() [type_could_unify]
2123
+ "# ] ] ,
2124
+ ) ;
2125
+
2084
2126
// Generic 1
2085
2127
check_relevance (
2086
2128
r#"
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ fn compute_associated_fn(
203
203
// let _: u32 = foo.$0; // baz is preferred as it returns expected u32
204
204
CompletionRelevanceAssociatedFnType :: ReturnsExpectedType
205
205
} else if ret_type. display ( db) . to_string ( ) . ends_with ( "Builder" ) {
206
- // -> [..]Builder
206
+ // fn([..]) -> [..]Builder
207
207
CompletionRelevanceAssociatedFnType :: Builder
208
208
} else if returns_self_wrapped {
209
209
// fn([..]) -> Result<A>
You can’t perform that action at this time.
0 commit comments