Skip to content

Commit 331c737

Browse files
committed
Experiment with projection
1 parent 652dba9 commit 331c737

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

src/test/mod.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,43 @@ fn hello_world() {
8989
)
9090
}
9191

92+
#[test]
93+
fn test_something() {
94+
crate::assert_ok!(
95+
//@check-pass
96+
[
97+
crate Foo {
98+
99+
trait Id {
100+
type This: [];
101+
}
102+
103+
impl<ty T> Id for T {
104+
type This = T;
105+
}
106+
107+
fn bar(()) -> () = minirust(v1) -> v0 {
108+
let v0: ();
109+
let v1: ();
110+
let v2:
111+
112+
bb0: {
113+
statements {
114+
local(v0) = load(local(v1));
115+
}
116+
}
117+
118+
119+
};
120+
121+
}
122+
]
123+
124+
expect_test::expect!["()"]
125+
)
126+
127+
}
128+
92129
#[test]
93130
fn basic_where_clauses_pass() {
94131
crate::assert_ok!(

tests/projection.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,42 @@ fn projection_equality() {
116116
expect_test::expect!["{Constraints { env: Env { variables: [?ty_1], bias: Soundness, pending: [] }, known_true: true, substitution: {?ty_1 => u32} }, Constraints { env: Env { variables: [?ty_1], bias: Soundness, pending: [] }, known_true: true, substitution: {?ty_1 => <S as Trait1>::Type} }}"],
117117
);
118118
}
119+
120+
121+
const TEST_TY_IS_INT: &str = "[
122+
crate test {
123+
trait Id {
124+
type This: [];
125+
}
126+
127+
impl<ty T> Id for T {
128+
type This = T;
129+
}
130+
}
131+
]";
132+
133+
134+
#[test]
135+
fn test_ty_is_int() {
136+
test_where_clause(
137+
TEST_TY_IS_INT,
138+
"{} => { <u16 as Id>::This = u16 }",
139+
)
140+
.assert_ok(expect_test::expect!["{Constraints { env: Env { variables: [], bias: Soundness, pending: [] }, known_true: true, substitution: {} }}"]);
141+
142+
143+
test_where_clause(
144+
TEST_TY_IS_INT,
145+
"{} => { @is_int(<u16 as Id>::This) }",
146+
)
147+
.assert_err(expect_test::expect![[r#"
148+
judgment `prove { goal: {@ is_int(<u16 as Id>::This)}, assumptions: {}, env: Env { variables: [], bias: Soundness, pending: [] }, decls: decls(222, [trait Id <ty> ], [impl <ty> Id(^ty0_0)], [], [alias <ty> <^ty0_0 as Id>::This = ^ty0_0], [], [], {Id}, {}) }` failed at the following rule(s):
149+
failed at (src/file.rs:LL:CC) because
150+
judgment `prove_wc_list { goal: {@ is_int(<u16 as Id>::This)}, assumptions: {}, env: Env { variables: [], bias: Soundness, pending: [] } }` failed at the following rule(s):
151+
the rule "some" failed at step #0 (src/file.rs:LL:CC) because
152+
judgment `prove_wc { goal: @ is_int(<u16 as Id>::This), assumptions: {}, env: Env { variables: [], bias: Soundness, pending: [] } }` failed at the following rule(s):
153+
the rule "ty is int" failed at step #0 (src/file.rs:LL:CC) because
154+
judgment had no applicable rules: `is_int { goal: <u16 as Id>::This, assumptions: {}, env: Env { variables: [], bias: Soundness, pending: [] } }`"#]]);
155+
156+
}
157+

0 commit comments

Comments
 (0)