Skip to content

Commit a2afb95

Browse files
committed
fix: generic with multiple args Result<T, E>
1 parent 1507c90 commit a2afb95

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/ide-completion/src/render.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,12 +2087,14 @@ fn test() {
20872087
struct AStruct<T: Default>(T);
20882088
struct AStructBuilder;
20892089
struct Res<T>(T);
2090+
struct Res2<T, E>{t: T, e: E};
20902091
20912092
impl<T: Default> AStruct<T> {
20922093
fn fn_no_ret(&self) {}
20932094
fn fn_ctr_with_args(input: T) -> AStruct<T> { AStruct(input) }
20942095
fn fn_direct_ctr() -> Self { AStruct(<_>::default()) }
20952096
fn fn_ctr() -> Res<Self> { Res(Self::fn_direct_ctr()) }
2097+
fn fn_ctr2() -> Res2<Self, u32> { Res2 { t: <_>::default(), e: 0 } }
20962098
fn fn_other() -> Res<u32> { Res(0) }
20972099
fn fn_builder() -> AStructBuilder { AStructBuilder }
20982100
}
@@ -2106,6 +2108,7 @@ fn test() {
21062108
fn fn_ctr_with_args(…) [type_could_unify]
21072109
fn fn_builder() [type_could_unify]
21082110
fn fn_ctr() [type_could_unify]
2111+
fn fn_ctr2() [type_could_unify]
21092112
fn fn_other() [type_could_unify]
21102113
me fn_no_ret(…) [type_could_unify]
21112114
"#]],
@@ -2117,12 +2120,14 @@ fn test() {
21172120
struct AStruct<T: Default>(T);
21182121
struct AStructBuilder;
21192122
struct Res<T>(T);
2123+
struct Res2<T, E>{t: T, e: E};
21202124
21212125
impl<T: Default> AStruct<T> {
21222126
fn fn_no_ret(&self) {}
21232127
fn fn_ctr_with_args(input: T) -> AStruct<T> { AStruct(input) }
21242128
fn fn_direct_ctr() -> Self { AStruct(<_>::default()) }
21252129
fn fn_ctr() -> Res<Self> { Res(Self::fn_direct_ctr()) }
2130+
fn fn_ctr2() -> Res2<Self, u32> { Res2 { t: <_>::default(), e: 0 } }
21262131
fn fn_other() -> Res<u32> { Res(0) }
21272132
fn fn_builder() -> AStructBuilder { AStructBuilder }
21282133
}
@@ -2136,6 +2141,7 @@ fn test() {
21362141
fn fn_ctr_with_args(…) []
21372142
fn fn_builder() []
21382143
fn fn_ctr() []
2144+
fn fn_ctr2() []
21392145
fn fn_other() []
21402146
me fn_no_ret(…) []
21412147
"#]],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn compute_associated_fn(
188188

189189
// the second checks are needed when Self has generic args
190190
let ret_self_only = ret_ty == self_type || ret_ty.starts_with(&format!("{self_type}<"));
191-
let ret_self_wrapped = ret_ty.ends_with(&format!("<{self_type}>"))
191+
let ret_self_wrapped = ret_ty.contains(&format!("<{self_type}"))
192192
|| ret_ty.contains(&format!("<{self_type}<"));
193193

194194
(ret_self_only || ret_self_wrapped, ret_self_wrapped)

0 commit comments

Comments
 (0)