Skip to content

Commit 0bd7084

Browse files
committed
Auto merge of #29770 - ollie27:assert_eq_unsized, r=alexcrichton
`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.
2 parents afd4a54 + 780581e commit 0bd7084

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/libcore/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ macro_rules! assert_eq {
8989
(left_val, right_val) => {
9090
if !(*left_val == *right_val) {
9191
panic!("assertion failed: `(left == right)` \
92-
(left: `{:?}`, right: `{:?}`)", *left_val, *right_val)
92+
(left: `{:?}`, right: `{:?}`)", left_val, right_val)
9393
}
9494
}
9595
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
assert_eq!([1, 2, 3][..], vec![1, 2, 3][..]);
13+
}

0 commit comments

Comments
 (0)