Skip to content

Commit c4a1079

Browse files
committed
integrate coherence mode into test
1 parent 99906c6 commit c4a1079

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ rustc_private=true
1111
[dev-dependencies]
1212
pretty_assertions = "1.3.0"
1313
expect-test = "1.4.0"
14+
formality-macros = { version = "0.1.0", path = "crates/formality-macros" }
15+
formality-core = { version = "0.1.0", path = "crates/formality-core" }
1416

1517
[dependencies]
1618
anyhow = "1"

crates/formality-check/src/coherence.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ impl Check<'_> {
4242
Ok(())
4343
}
4444

45+
#[tracing::instrument(level = "Debug", skip(self))]
4546
fn overlap_check(&self, impl_a: &TraitImpl, impl_b: &TraitImpl) -> Fallible<()> {
4647
let mut env = Env::default();
4748

@@ -53,7 +54,7 @@ impl Check<'_> {
5354

5455
// If the parameters from the two impls cannot be equal, then they do not overlap.
5556
if let Ok(()) = self.prove_not_goal(
56-
&env,
57+
&env.with_coherence_mode(true),
5758
(&a.where_clauses, &b.where_clauses),
5859
Wcs::all_eq(&trait_ref_a.parameters, &trait_ref_b.parameters),
5960
) {
@@ -62,7 +63,7 @@ impl Check<'_> {
6263

6364
// If we can disprove the where clauses, then they do not overlap.
6465
if let Ok(()) = self.prove_not_goal(
65-
&env,
66+
&env.with_coherence_mode(true),
6667
Wcs::all_eq(&trait_ref_a.parameters, &trait_ref_b.parameters),
6768
(&a.where_clauses, &b.where_clauses),
6869
) {

crates/formality-check/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl Check<'_> {
114114
// we've proven the negation. (This is called the "negation as failure" property,
115115
// and it relies on our solver being complete -- i.e., if there is a solution,
116116
// we'll find it, or at least return ambiguous.)
117-
let mut existential_env = Env::default();
117+
let mut existential_env = Env::default().with_coherence_mode(env.is_in_coherence_mode());
118118
let universal_to_existential: Substitution = env
119119
.variables()
120120
.iter()

tests/coherence.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use formality::test_program_ok;
2+
use formality_macros::test;
23

34
#[test]
45
fn test_u32_i32_impls() {
@@ -145,10 +146,10 @@ fn test_T_where_Foo_not_u32_impls() {
145146
#[allow(non_snake_case)]
146147
fn test_non_local() {
147148
expect_test::expect![[r#"
148-
Ok(
149-
(),
149+
Err(
150+
"impls may overlap: `impl <ty> FooTrait < > for ^ty0_0 where [^ty0_0 : CoreTrait < >] { }` vs `impl <> FooTrait < > for (rigid (adt CoreStruct)) where [] { }`",
150151
)
151-
"#]] // FIXME
152+
"#]]
152153
.assert_debug_eq(&test_program_ok(
153154
"[
154155
crate core {

0 commit comments

Comments
 (0)