Skip to content

Commit

Permalink
Improve error handling and messaging in compilation tests
Browse files Browse the repository at this point in the history
- Expanded error messaging and debugging suggestions in several unit test files including 'normalize_complex.stderr', 'consume_head.stderr', and 'consume.stderr' related to trait bound not being satisfied and the `Sub<Rhs>` trait not being implemented for certain types.
- Enhanced error messages in 'sponge_creation.stderr' and 'sponge_bad_api.stderr' unit tests, addressing the mismatched expected types and clarification about specific `Sub<B1>` trait implementation.
- Comments have been added to the unit tests module in the Sponge API located in 'lib.rs' for improved clarity.
- Additional test assertions in 'normalize.stderr' unit test validate the trait implementation with `Absorb<U4>` type.
- Introduced a suggestion to use `--verbose` across multiple unit tests to assist debugging efforts by printing full type names.
  • Loading branch information
huitseeker committed Dec 31, 2024
1 parent 25b5a92 commit 927e395
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl<A: SpongeAPI, I: List> Drop for ExtraSponge<A, I> {
}

#[cfg(test)]
/// Unit tests for the Sponge API.
pub mod unit_tests;

#[cfg(test)]
Expand Down
33 changes: 28 additions & 5 deletions src/unit_tests/compilation/consume.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,36 @@ error[E0277]: the trait bound `UTerm: PrivateSub<UInt<UTerm, B1>>` is not satisf
--> src/unit_tests/compilation/consume.rs:9:9
|
9 | Use<iopat![Absorb<U3>, Squeeze<U1>, Absorb<U1>], Absorb<U6>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PrivateSub<UInt<UTerm, B1>>` is not implemented for `UTerm`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PrivateSub<UInt<UTerm, B1>>` is not implemented for `UTerm`, which is required by `Cons<extra_safe::traits::Absorb<UInt<UInt<UTerm, B1>, B1>>, Cons<extra_safe::traits::Squeeze<UInt<UTerm, B1>>, Cons<extra_safe::traits::Absorb<UInt<UTerm, B1>>, Nil>>>: Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
|
= help: the following other types implement trait `PrivateSub<Rhs>`:
<UInt<Ul, B0> as PrivateSub<UInt<Ur, B0>>>
<UInt<Ul, B0> as PrivateSub<UInt<Ur, B1>>>
<UInt<Ul, B1> as PrivateSub<UInt<Ur, B0>>>
<UInt<Ul, B1> as PrivateSub<UInt<Ur, B1>>>
`UInt<Ul, B0>` implements `PrivateSub<UInt<Ur, B0>>`
`UInt<Ul, B0>` implements `PrivateSub<UInt<Ur, B1>>`
`UInt<Ul, B1>` implements `PrivateSub<UInt<Ur, B0>>`
`UInt<Ul, B1>` implements `PrivateSub<UInt<Ur, B1>>`
= note: required for `UInt<UTerm, B1>` to implement `PrivateSub<UInt<UInt<UTerm, B1>, B1>>`
= note: required for `UInt<UInt<UTerm, B1>, B1>` to implement `Sub<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>`
= note: required for `Cons<Absorb<UInt<UInt<UTerm, B1>, B1>>, Cons<Squeeze<UInt<UTerm, B1>>, Cons<Absorb<UInt<UTerm, B1>>, Nil>>>` to implement `Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
= note: the full name for the type has been written to '$DIR/target/tests/trybuild/aarch64-apple-darwin/debug/deps/$CRATE-b4d682b1f57e5d44.long-type-3642229067816383729.txt'
= note: consider using `--verbose` to print the full type name to the console

error[E0277]: the trait bound `UTerm: PrivateSub<UInt<UTerm, B1>>` is not satisfied
--> src/unit_tests/compilation/consume.rs:8:5
|
8 | / assert_type_eq!(
9 | | Use<iopat![Absorb<U3>, Squeeze<U1>, Absorb<U1>], Absorb<U6>>,
10 | | iopat![Squeeze<U1>, Absorb<U1>]
11 | | );
| |_____^ the trait `PrivateSub<UInt<UTerm, B1>>` is not implemented for `UTerm`, which is required by `Cons<extra_safe::traits::Absorb<UInt<UInt<UTerm, B1>, B1>>, Cons<extra_safe::traits::Squeeze<UInt<UTerm, B1>>, Cons<extra_safe::traits::Absorb<UInt<UTerm, B1>>, Nil>>>: Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
|
= help: the following other types implement trait `PrivateSub<Rhs>`:
`UInt<Ul, B0>` implements `PrivateSub<UInt<Ur, B0>>`
`UInt<Ul, B0>` implements `PrivateSub<UInt<Ur, B1>>`
`UInt<Ul, B1>` implements `PrivateSub<UInt<Ur, B0>>`
`UInt<Ul, B1>` implements `PrivateSub<UInt<Ur, B1>>`
= note: required for `UInt<UTerm, B1>` to implement `PrivateSub<UInt<UInt<UTerm, B1>, B1>>`
= note: required for `UInt<UInt<UTerm, B1>, B1>` to implement `Sub<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>`
= note: required for `Cons<Absorb<UInt<UInt<UTerm, B1>, B1>>, Cons<Squeeze<UInt<UTerm, B1>>, Cons<Absorb<UInt<UTerm, B1>>, Nil>>>` to implement `Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
= note: the full name for the type has been written to '$DIR/target/tests/trybuild/aarch64-apple-darwin/debug/deps/$CRATE-b4d682b1f57e5d44.long-type-3642229067816383729.txt'
= note: consider using `--verbose` to print the full type name to the console
= note: this error originates in the macro `assert_type_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
37 changes: 31 additions & 6 deletions src/unit_tests/compilation/consume_head.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,38 @@ error[E0277]: cannot subtract `B1` from `UInt<UTerm, B0>`
9 | Use<iopat![Absorb<U5>, Squeeze<U0>, Absorb<U1>], Absorb<U6>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `UInt<UTerm, B0> - B1`
|
= help: the trait `Sub<B1>` is not implemented for `UInt<UTerm, B0>`
= help: the trait `Sub<B1>` is not implemented for `UInt<UTerm, B0>`, which is required by `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Cons<extra_safe::traits::Squeeze<UTerm>, Cons<extra_safe::traits::Absorb<UInt<UTerm, B1>>, Nil>>>: Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
= help: the following other types implement trait `Sub<Rhs>`:
<UInt<U, B0> as Sub<B1>>
<UInt<U, B> as Sub<B0>>
<UInt<UInt<U, B>, B1> as Sub<B1>>
<UInt<UTerm, B1> as Sub<B1>>
<UInt<Ul, Bl> as Sub<Ur>>
`UInt<U, B0>` implements `Sub<B1>`
`UInt<U, B>` implements `Sub<B0>`
`UInt<UInt<U, B>, B1>` implements `Sub<B1>`
`UInt<UTerm, B1>` implements `Sub<B1>`
`UInt<Ul, Bl>` implements `Sub<Ur>`
= note: required for `UInt<UInt<UTerm, B1>, B0>` to implement `PrivateSub<UInt<UInt<UTerm, B1>, B1>>`
= note: required for `UInt<UInt<UInt<UTerm, B1>, B0>, B1>` to implement `Sub<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>`
= note: required for `Cons<Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Cons<Squeeze<UTerm>, Cons<Absorb<UInt<UTerm, B1>>, Nil>>>` to implement `Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
= note: the full name for the type has been written to '$DIR/target/tests/trybuild/aarch64-apple-darwin/debug/deps/$CRATE-901c64bc5947f6da.long-type-12175079161346788738.txt'
= note: consider using `--verbose` to print the full type name to the console

error[E0277]: cannot subtract `B1` from `UInt<UTerm, B0>`
--> src/unit_tests/compilation/consume_head.rs:8:5
|
8 | / assert_type_eq!(
9 | | Use<iopat![Absorb<U5>, Squeeze<U0>, Absorb<U1>], Absorb<U6>>,
10 | | Nil
11 | | );
| |_____^ no implementation for `UInt<UTerm, B0> - B1`
|
= help: the trait `Sub<B1>` is not implemented for `UInt<UTerm, B0>`, which is required by `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Cons<extra_safe::traits::Squeeze<UTerm>, Cons<extra_safe::traits::Absorb<UInt<UTerm, B1>>, Nil>>>: Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
= help: the following other types implement trait `Sub<Rhs>`:
`UInt<U, B0>` implements `Sub<B1>`
`UInt<U, B>` implements `Sub<B0>`
`UInt<UInt<U, B>, B1>` implements `Sub<B1>`
`UInt<UTerm, B1>` implements `Sub<B1>`
`UInt<Ul, Bl>` implements `Sub<Ur>`
= note: required for `UInt<UInt<UTerm, B1>, B0>` to implement `PrivateSub<UInt<UInt<UTerm, B1>, B1>>`
= note: required for `UInt<UInt<UInt<UTerm, B1>, B0>, B1>` to implement `Sub<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>`
= note: required for `Cons<Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Cons<Squeeze<UTerm>, Cons<Absorb<UInt<UTerm, B1>>, Nil>>>` to implement `Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>>`
= note: the full name for the type has been written to '$DIR/target/tests/trybuild/aarch64-apple-darwin/debug/deps/$CRATE-901c64bc5947f6da.long-type-12175079161346788738.txt'
= note: consider using `--verbose` to print the full type name to the console
= note: this error originates in the macro `assert_type_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
8 changes: 8 additions & 0 deletions src/unit_tests/compilation/normalize.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ error[E0277]: the trait bound `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UT
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Same<Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Nil>>` is not implemented for `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Nil>`
|
= note: this error originates in the macro `assert_type_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Nil>: Same<Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Nil>>` is not satisfied
--> src/unit_tests/compilation/normalize.rs:7:5
|
7 | assert_type_eq!(Norm<iopat![Absorb<U2>, Absorb<U3>]>, iopat![Absorb<U4>]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Same<Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Nil>>` is not implemented for `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Nil>`
|
= note: this error originates in the macro `assert_type_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
11 changes: 11 additions & 0 deletions src/unit_tests/compilation/normalize_complex.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ error[E0277]: the trait bound `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UI
| |_____^ the trait `Same<Cons<extra_safe::traits::Absorb<UInt<UInt<UTerm, B1>, B0>>, Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>, Nil>>>` is not implemented for `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>>, Nil>`
|
= note: this error originates in the macro `assert_type_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>>, Nil>: Same<Cons<extra_safe::traits::Absorb<UInt<UInt<UTerm, B1>, B0>>, Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>, Nil>>>` is not satisfied
--> src/unit_tests/compilation/normalize_complex.rs:7:5
|
7 | / assert_type_eq!(
8 | | Norm<iopat![Absorb<U2>, Squeeze<U0>, Absorb<U3>, Absorb<U3>]>,
9 | | iopat![Absorb<U2>, Absorb<U6>]
10 | | );
| |_____^ the trait `Same<Cons<extra_safe::traits::Absorb<UInt<UInt<UTerm, B1>, B0>>, Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>, Nil>>>` is not implemented for `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>>, Nil>`
|
= note: this error originates in the macro `assert_type_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
12 changes: 6 additions & 6 deletions src/unit_tests/compilation/sponge_bad_api.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ error[E0277]: cannot subtract `B1` from `UInt<UInt<UTerm, B0>, B0>`
89 | extra_sponge.absorb(Array::from_core_array(five_array), &mut Vec::default());
| ^^^^^^ no implementation for `UInt<UInt<UTerm, B0>, B0> - B1`
|
= help: the trait `Sub<B1>` is not implemented for `UInt<UInt<UTerm, B0>, B0>`
= help: the trait `Sub<B1>` is not implemented for `UInt<UInt<UTerm, B0>, B0>`, which is required by `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Cons<extra_safe::traits::Squeeze<UInt<UInt<UTerm, B1>, B1>>, Nil>>: Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>>`
= help: the following other types implement trait `Sub<Rhs>`:
<UInt<U, B0> as Sub<B1>>
<UInt<U, B> as Sub<B0>>
<UInt<UInt<U, B>, B1> as Sub<B1>>
<UInt<UTerm, B1> as Sub<B1>>
<UInt<Ul, Bl> as Sub<Ur>>
`UInt<U, B0>` implements `Sub<B1>`
`UInt<U, B>` implements `Sub<B0>`
`UInt<UInt<U, B>, B1>` implements `Sub<B1>`
`UInt<UTerm, B1>` implements `Sub<B1>`
`UInt<Ul, Bl>` implements `Sub<Ur>`
= note: required for `UInt<UInt<UInt<UTerm, B1>, B0>, B0>` to implement `PrivateSub<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>`
= note: required for `UInt<UInt<UInt<UTerm, B1>, B0>, B0>` to implement `Sub<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>`
= note: required for `Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>, Cons<extra_safe::traits::Squeeze<UInt<UInt<UTerm, B1>, B1>>, Nil>>` to implement `Consume<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>>`
3 changes: 2 additions & 1 deletion src/unit_tests/compilation/sponge_creation.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ error[E0308]: mismatched types
83 | | basic_sponge,
84 | | &mut start_acc,
85 | | );
| |_________^ expected struct `UTerm`, found struct `UInt`
| |_________^ expected `UTerm`, found `UInt<UTerm, B1>`
|
= note: expected struct `ExtraSponge<BasicSponge, Cons<Absorb<UInt<UInt<UTerm, B1>, B0>>, Cons<Absorb<UInt<..., ...>>, ...>>>`
found struct `ExtraSponge<_, Cons<extra_safe::traits::Absorb<UInt<UInt<UInt<UTerm, B1>, B0>, B1>>, Cons<extra_safe::traits::Squeeze<UInt<UInt<UTerm, B1>, B1>>, Nil>>>`
= note: consider using `--verbose` to print the full type name to the console

0 comments on commit 927e395

Please sign in to comment.