-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Allow none Sized types in assert_eq! #29770
Conversation
format_args! doesn't support none Sized types so we should just pass it the references to left_val and right_val. This fixes `assert_eq!([1, 2, 3][..], vec![1, 2, 3][..])` for example.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Does this change which type needs to impl Debug? Imagine left_val and right_val are
Previous code would have it compare as New code compares The potential breaking change comes when Workaround would be to use |
Can match (&($left), &($right)) {
(left_val, right_val) => { |
Oh that's a good point 😄. |
Thanks! Could you also add a test for this? |
I've added a test, I hope it's in the right place. |
`format_args!` doesn't support none Sized types so we should just pass it the references to `left_val` and `right_val`. The following works: ```rust assert!([1, 2, 3][..] == vec![1, 2, 3][..]) ``` So I would expect this to as well: ```rust assert_eq!([1, 2, 3][..], vec![1, 2, 3][..]) ``` But it fails with "error: the trait `core::marker::Sized` is not implemented for the type `[_]` [E0277]" I don't know if this change will have any nasty side effects I don't understand.
format_args!
doesn't support none Sized types so we should just pass it the references toleft_val
andright_val
.The following works:
So I would expect this to as well:
But it fails with "error: the trait
core::marker::Sized
is not implemented for the type[_]
[E0277]"I don't know if this change will have any nasty side effects I don't understand.