Skip to content

Commit f987286

Browse files
committed
more tests for generic
1 parent b603303 commit f987286

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

crates/ide-completion/src/render.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ fn main() {
20422042
}
20432043

20442044
#[test]
2045-
fn associated_fn_relevanes() {
2045+
fn associated_fn_relevances() {
20462046
check_relevance(
20472047
r#"
20482048
struct AStruct;
@@ -2078,7 +2078,7 @@ fn test() {
20782078
"#]],
20792079
);
20802080

2081-
// Generic
2081+
// Generic 1
20822082
check_relevance(
20832083
r#"
20842084
struct AStruct<T: Default>(T);
@@ -2095,7 +2095,6 @@ impl<T: Default> AStruct<T> {
20952095
}
20962096
20972097
fn test() {
2098-
//let a : Res<AStruct<u32>> = self::AStruct::fn_ctr();
20992098
let a = self::AStruct::<u32>::$0;
21002099
}
21012100
"#,
@@ -2108,6 +2107,36 @@ fn test() {
21082107
me fn_no_ret(…) [type_could_unify]
21092108
"#]],
21102109
);
2110+
2111+
// Generic 2
2112+
check_relevance(
2113+
r#"
2114+
struct AStruct<T: Default>(T);
2115+
struct AStructBuilder;
2116+
struct Res<T>(T);
2117+
2118+
impl<T: Default> AStruct<T> {
2119+
fn fn_no_ret(&self) {}
2120+
fn fn_ctr_with_args(input: T) -> AStruct<T> { AStruct(input) }
2121+
fn fn_direct_ctr() -> Self { AStruct(<_>::default()) }
2122+
fn fn_ctr() -> Res<Self> { Res(Self::fn_direct_ctr()) }
2123+
fn fn_other() -> Res<u32> { Res(0) }
2124+
fn fn_builder() -> AStructBuilder { AStructBuilder }
2125+
}
2126+
2127+
fn test() {
2128+
let a : Res<AStruct<u32>> = AStruct::$0;
2129+
}
2130+
"#,
2131+
expect![[r#"
2132+
fn fn_direct_ctr() []
2133+
fn fn_ctr_with_args(…) []
2134+
fn fn_builder() []
2135+
fn fn_ctr() []
2136+
fn fn_other() []
2137+
me fn_no_ret(…) []
2138+
"#]],
2139+
);
21112140
}
21122141

21132142
#[test]

0 commit comments

Comments
 (0)