Skip to content

Commit 1507c90

Browse files
committed
more tests for generic
1 parent 5164917 commit 1507c90

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
@@ -2045,7 +2045,7 @@ fn main() {
20452045
}
20462046

20472047
#[test]
2048-
fn associated_fn_relevanes() {
2048+
fn associated_fn_relevances() {
20492049
check_relevance(
20502050
r#"
20512051
struct AStruct;
@@ -2081,7 +2081,7 @@ fn test() {
20812081
"#]],
20822082
);
20832083

2084-
// Generic
2084+
// Generic 1
20852085
check_relevance(
20862086
r#"
20872087
struct AStruct<T: Default>(T);
@@ -2098,7 +2098,6 @@ impl<T: Default> AStruct<T> {
20982098
}
20992099
21002100
fn test() {
2101-
//let a : Res<AStruct<u32>> = self::AStruct::fn_ctr();
21022101
let a = self::AStruct::<u32>::$0;
21032102
}
21042103
"#,
@@ -2111,6 +2110,36 @@ fn test() {
21112110
me fn_no_ret(…) [type_could_unify]
21122111
"#]],
21132112
);
2113+
2114+
// Generic 2
2115+
check_relevance(
2116+
r#"
2117+
struct AStruct<T: Default>(T);
2118+
struct AStructBuilder;
2119+
struct Res<T>(T);
2120+
2121+
impl<T: Default> AStruct<T> {
2122+
fn fn_no_ret(&self) {}
2123+
fn fn_ctr_with_args(input: T) -> AStruct<T> { AStruct(input) }
2124+
fn fn_direct_ctr() -> Self { AStruct(<_>::default()) }
2125+
fn fn_ctr() -> Res<Self> { Res(Self::fn_direct_ctr()) }
2126+
fn fn_other() -> Res<u32> { Res(0) }
2127+
fn fn_builder() -> AStructBuilder { AStructBuilder }
2128+
}
2129+
2130+
fn test() {
2131+
let a : Res<AStruct<u32>> = AStruct::$0;
2132+
}
2133+
"#,
2134+
expect![[r#"
2135+
fn fn_direct_ctr() []
2136+
fn fn_ctr_with_args(…) []
2137+
fn fn_builder() []
2138+
fn fn_ctr() []
2139+
fn fn_other() []
2140+
me fn_no_ret(…) []
2141+
"#]],
2142+
);
21142143
}
21152144

21162145
#[test]

0 commit comments

Comments
 (0)