@@ -5,6 +5,7 @@ use formality_macros::test;
5
5
6
6
#[ test]
7
7
fn test_u32_i32_impls ( ) {
8
+ // Test that we permit impls for distinct types.
8
9
expect_test:: expect![ [ r#"
9
10
Ok(
10
11
(),
@@ -23,6 +24,7 @@ fn test_u32_i32_impls() {
23
24
24
25
#[ test]
25
26
fn test_u32_u32_impls ( ) {
27
+ // Test that we detect duplicate impls.
26
28
expect_test:: expect![ [ r#"
27
29
Err(
28
30
"duplicate impl in current crate: impl <> Foo < > for (rigid (scalar u32)) where [] { }",
@@ -41,6 +43,7 @@ fn test_u32_u32_impls() {
41
43
42
44
#[ test]
43
45
fn test_u32_T_impls ( ) {
46
+ // Test that we detect overlap involving generic parameters.
44
47
expect_test:: expect![ [ r#"
45
48
Err(
46
49
"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() {
59
62
60
63
#[ test]
61
64
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
62
69
expect_test:: expect![ [ r#"
63
70
Ok(
64
71
(),
@@ -79,6 +86,8 @@ fn test_u32_T_where_T_Not_impls() {
79
86
80
87
#[ test]
81
88
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`.
82
91
expect_test:: expect![ [ r#"
83
92
Err(
84
93
"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() {
100
109
101
110
#[ test]
102
111
fn test_u32_not_u32_impls ( ) {
112
+ // Test that a positive and negative impl for the same type (`u32`, here) is rejected.
103
113
expect_test:: expect![ [ r#"
104
114
Err(
105
115
Error {
0 commit comments