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 @@ -2067,7 +2067,7 @@ fn test() {
2067
2067
// Direct Constructor with args
2068
2068
// Builder
2069
2069
// Constructor
2070
- // fn with param that returns itself
2070
+ // Others
2071
2071
expect ! [ [ r#"
2072
2072
fn fn_direct_ctr() [type_could_unify]
2073
2073
fn fn_ctr_with_args(…) [type_could_unify]
@@ -2078,6 +2078,48 @@ fn test() {
2078
2078
"# ] ] ,
2079
2079
) ;
2080
2080
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
+
2081
2123
// Generic 1
2082
2124
check_relevance (
2083
2125
r#"
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ fn compute_associated_fn(
199
199
// let _: u32 = foo.$0; // baz is preferred as it returns expected u32
200
200
CompletionRelevanceAssociatedFnType :: ReturnsExpectedType
201
201
} else if ret_type. display ( db) . to_string ( ) . ends_with ( "Builder" ) {
202
- // -> [..]Builder
202
+ // fn([..]) -> [..]Builder
203
203
CompletionRelevanceAssociatedFnType :: Builder
204
204
} else if returns_self_wrapped {
205
205
// fn([..]) -> Result<A>
You can’t perform that action at this time.
0 commit comments