Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include a Debug rendering of lhs and rhs in ensure! messages #193

Merged
merged 5 commits into from Nov 22, 2021
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Nov 22, 2021

For invocations of ensure! where the argument is one of the comparison operators == <= < != >= > and the lhs and rhs of the operator both have a Debug impl, we render both sides as part of the error message.

Example:

ensure!(flags.len() <= 40);
ensure!(kind == Kind::File);

Before:

Condition failed: `flags.len() <= 40`
Condition failed: `kind == Kind::File`

After:

Condition failed: `flags.len() <= 40` (99 vs 40)
Condition failed: `kind == Kind::File` (Symlink vs File)

On 1.52:

    error[E0658]: or-patterns syntax is experimental
       --> tests/test_ensure.rs:187:22
        |
    187 |     let test = || Ok(ensure!(for true | false in iter::empty() {}.t(1) == 2));
        |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@dtolnay dtolnay merged commit e05df5f into master Nov 22, 2021
@dtolnay dtolnay deleted the ensure branch November 22, 2021 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant