Skip to content

Commit 6e5a569

Browse files
committed
add more comments
1 parent ded9342 commit 6e5a569

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/coherence.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use formality_macros::test;
55

66
#[test]
77
fn test_u32_i32_impls() {
8+
// Test that we permit impls for distinct types.
89
expect_test::expect![[r#"
910
Ok(
1011
(),
@@ -23,6 +24,7 @@ fn test_u32_i32_impls() {
2324

2425
#[test]
2526
fn test_u32_u32_impls() {
27+
// Test that we detect duplicate impls.
2628
expect_test::expect![[r#"
2729
Err(
2830
"duplicate impl in current crate: impl <> Foo < > for (rigid (scalar u32)) where [] { }",
@@ -41,6 +43,7 @@ fn test_u32_u32_impls() {
4143

4244
#[test]
4345
fn test_u32_T_impls() {
46+
// Test that we detect overlap involving generic parameters.
4447
expect_test::expect![[r#"
4548
Err(
4649
"impls may overlap: `impl <> Foo < > for (rigid (scalar u32)) where [] { }` vs `impl <ty> Foo < > for ^ty0_0 where [] { }`",
@@ -59,6 +62,10 @@ fn test_u32_T_impls() {
5962

6063
#[test]
6164
fn test_u32_T_where_T_Not_impls() {
65+
// Test that, within a crate, we are able to rely on the fact
66+
// that `u32: Not` is not implemented.
67+
//
68+
// See also test_foo_crate_cannot_assume_CoreStruct_does_not_impl_CoreTrait
6269
expect_test::expect![[r#"
6370
Ok(
6471
(),
@@ -79,6 +86,8 @@ fn test_u32_T_where_T_Not_impls() {
7986

8087
#[test]
8188
fn test_u32_T_where_T_Is_impls() {
89+
// Test that we detect "indirect" overlap -- here `Foo` is implemented for `u32`
90+
// and also all `T: Is`, and `u32: Is`.
8291
expect_test::expect![[r#"
8392
Err(
8493
"impls may overlap: `impl <> Foo < > for (rigid (scalar u32)) where [] { }` vs `impl <ty> Foo < > for ^ty0_0 where [^ty0_0 : Is < >] { }`",
@@ -100,6 +109,7 @@ fn test_u32_T_where_T_Is_impls() {
100109

101110
#[test]
102111
fn test_u32_not_u32_impls() {
112+
// Test that a positive and negative impl for the same type (`u32`, here) is rejected.
103113
expect_test::expect![[r#"
104114
Err(
105115
Error {

0 commit comments

Comments
 (0)