Skip to content

Mismatch between documentation and implementation of debug_assert_eq macro #30600

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

Closed
est31 opened this issue Dec 29, 2015 · 5 comments
Closed

Comments

@est31
Copy link
Member

est31 commented Dec 29, 2015

The documentation for the debug_assert_eq macro claims:

Asserts that two expressions are equal to each other, testing equality in both directions.

But if you read the implementation of debug_assert_eq, you see that it tests equality in one direction only. Also see the example: http://is.gd/YGKAOj

@durka
Copy link
Contributor

durka commented Dec 29, 2015

What does "equality in both directions" even mean?

@sfackler
Copy link
Member

It used to check if left == right && right == left.

@est31
Copy link
Member Author

est31 commented Dec 29, 2015

The commit that introduced this mismatch was
5cf126a

debug_assert_eq internally uses assert_eq, and when assert_eq was changed to check equality in one direction only (in above commit), the documentation for debug_assert_eq wasn't adjusted.

@est31
Copy link
Member Author

est31 commented Dec 29, 2015

As the macro was stabilized when it checked equality in one direction only. I guess it makes most sense to adjust the documentation, and not the code?

@sfackler
Copy link
Member

Yep, this is a docs issue.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Dec 29, 2015
Also, make its panic description identical in wording to assert_eq.

Fixes rust-lang#30600
steveklabnik added a commit to steveklabnik/rust that referenced this issue Dec 29, 2015
Also, make its panic description identical in wording to assert_eq.

Fixes rust-lang#30600
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

No branches or pull requests

4 participants