Skip to content

Commit 6540616

Browse files
committed
fix: generic with multiple args Result<T, E>
1 parent f987286 commit 6540616

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
@@ -2084,12 +2084,14 @@ fn test() {
20842084
struct AStruct<T: Default>(T);
20852085
struct AStructBuilder;
20862086
struct Res<T>(T);
2087+
struct Res2<T, E>{t: T, e: E};
20872088
20882089
impl<T: Default> AStruct<T> {
20892090
fn fn_no_ret(&self) {}
20902091
fn fn_ctr_with_args(input: T) -> AStruct<T> { AStruct(input) }
20912092
fn fn_direct_ctr() -> Self { AStruct(<_>::default()) }
20922093
fn fn_ctr() -> Res<Self> { Res(Self::fn_direct_ctr()) }
2094+
fn fn_ctr2() -> Res2<Self, u32> { Res2 { t: <_>::default(), e: 0 } }
20932095
fn fn_other() -> Res<u32> { Res(0) }
20942096
fn fn_builder() -> AStructBuilder { AStructBuilder }
20952097
}
@@ -2103,6 +2105,7 @@ fn test() {
21032105
fn fn_ctr_with_args(…) [type_could_unify]
21042106
fn fn_builder() [type_could_unify]
21052107
fn fn_ctr() [type_could_unify]
2108+
fn fn_ctr2() [type_could_unify]
21062109
fn fn_other() [type_could_unify]
21072110
me fn_no_ret(…) [type_could_unify]
21082111
"#]],
@@ -2114,12 +2117,14 @@ fn test() {
21142117
struct AStruct<T: Default>(T);
21152118
struct AStructBuilder;
21162119
struct Res<T>(T);
2120+
struct Res2<T, E>{t: T, e: E};
21172121
21182122
impl<T: Default> AStruct<T> {
21192123
fn fn_no_ret(&self) {}
21202124
fn fn_ctr_with_args(input: T) -> AStruct<T> { AStruct(input) }
21212125
fn fn_direct_ctr() -> Self { AStruct(<_>::default()) }
21222126
fn fn_ctr() -> Res<Self> { Res(Self::fn_direct_ctr()) }
2127+
fn fn_ctr2() -> Res2<Self, u32> { Res2 { t: <_>::default(), e: 0 } }
21232128
fn fn_other() -> Res<u32> { Res(0) }
21242129
fn fn_builder() -> AStructBuilder { AStructBuilder }
21252130
}
@@ -2133,6 +2138,7 @@ fn test() {
21332138
fn fn_ctr_with_args(…) []
21342139
fn fn_builder() []
21352140
fn fn_ctr() []
2141+
fn fn_ctr2() []
21362142
fn fn_other() []
21372143
me fn_no_ret(…) []
21382144
"#]],

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

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

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

190190
(ret_self_only || ret_self_wrapped, ret_self_wrapped)

0 commit comments

Comments
 (0)