Skip to content

Commit 86c5f84

Browse files
committed
Tests covering how WellFormedTraitRef checks the trait's parameters
missing_dependent_where_clause fails (see #189)
1 parent 0e53834 commit 86c5f84

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/test/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod coherence_overlap;
55
mod consts;
66
mod decl_safety;
77
mod functions;
8+
mod well_formed_trait_ref;
89

910
#[test]
1011
fn parser() {

src/test/well_formed_trait_ref.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#![allow(non_snake_case)]
2+
3+
#[test]
4+
fn dependent_where_clause() {
5+
crate::assert_ok!(
6+
//@check-pass
7+
[
8+
crate foo {
9+
trait Trait1 {}
10+
11+
trait Trait2 {}
12+
13+
struct S1<ty T> where T: Trait1 {
14+
dummy: T,
15+
}
16+
17+
struct S2<ty T> where T: Trait1, S1<T> : Trait2 {
18+
dummy: T,
19+
}
20+
}
21+
]
22+
23+
expect_test::expect!["()"]
24+
)
25+
}
26+
27+
#[test]
28+
fn missing_dependent_where_clause() {
29+
crate::assert_err!(
30+
[
31+
crate foo {
32+
trait Trait1 {}
33+
34+
trait Trait2 {}
35+
36+
struct S1<ty T> where T: Trait1 {
37+
dummy: T,
38+
}
39+
40+
struct S2<ty T> where S1<T> : Trait2 {
41+
dummy: T,
42+
}
43+
}
44+
]
45+
46+
[ /* TODO */ ]
47+
48+
expect_test::expect![[r#"..."#]]
49+
)
50+
}

0 commit comments

Comments
 (0)