Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ fn get_key(data: &Element) -> usize {
fn binary_search_slice_test() {
let map = test_map();
assert_eq!(binary_search_slice(&map, get_key, &0), &[(0, "zero")]);
assert_eq!(binary_search_slice(&map, get_key, &1), &[]);
assert_eq!(binary_search_slice(&map, get_key, &1), &map[..0]);
assert_eq!(binary_search_slice(&map, get_key, &3), &[(3, "three-a"), (3, "three-b")]);
assert_eq!(binary_search_slice(&map, get_key, &22), &[(22, "twenty-two")]);
assert_eq!(binary_search_slice(&map, get_key, &23), &[]);
assert_eq!(binary_search_slice(&map, get_key, &23), &map[..0]);
}
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ fn test_top_level_options_tracked_no_crate() {
real_rust_source_base_dir,
Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
);
tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
tracked!(remap_path_prefix, vec![(PathBuf::from("/home/bors/rust"), PathBuf::from("src"))]);
// tidy-alphabetical-end
}

Expand Down
30 changes: 11 additions & 19 deletions library/alloc/src/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,12 @@ fn make_contiguous_big_head() {

// 012......9876543
assert_eq!(tester.capacity(), 15);
assert_eq!((&[9, 8, 7, 6, 5, 4, 3] as &[_], &[0, 1, 2] as &[_]), tester.as_slices());
assert_eq!(tester.as_slices(), ([9, 8, 7, 6, 5, 4, 3], [0, 1, 2]));

let expected_start = tester.as_slices().1.len();
tester.make_contiguous();
assert_eq!(tester.head, expected_start);
assert_eq!((&[9, 8, 7, 6, 5, 4, 3, 0, 1, 2] as &[_], &[] as &[_]), tester.as_slices());
assert_eq!(tester.as_slices(), ([9, 8, 7, 6, 5, 4, 3, 0, 1, 2], []));
}

#[test]
Expand All @@ -503,7 +503,7 @@ fn make_contiguous_big_tail() {
let expected_start = 0;
tester.make_contiguous();
assert_eq!(tester.head, expected_start);
assert_eq!((&[9, 8, 0, 1, 2, 3, 4, 5, 6, 7] as &[_], &[] as &[_]), tester.as_slices());
assert_eq!(tester.as_slices(), ([9, 8, 0, 1, 2, 3, 4, 5, 6, 7], []));
}

#[test]
Expand All @@ -525,8 +525,8 @@ fn make_contiguous_small_free() {
tester.make_contiguous();
assert_eq!(tester.head, expected_start);
assert_eq!(
(&['M', 'L', 'K', 'J', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as &[_], &[] as &[_]),
tester.as_slices()
tester.as_slices(),
(['M', 'L', 'K', 'J', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'], [])
);

tester.clear();
Expand All @@ -543,8 +543,8 @@ fn make_contiguous_small_free() {
tester.make_contiguous();
assert_eq!(tester.head, expected_start);
assert_eq!(
(&['H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'I', 'J', 'K', 'L', 'M'] as &[_], &[] as &[_]),
tester.as_slices()
tester.as_slices(),
(['H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'I', 'J', 'K', 'L', 'M'], [])
);
}

Expand All @@ -570,12 +570,8 @@ fn make_contiguous_head_to_end() {
tester.make_contiguous();
assert_eq!(tester.head, expected_start);
assert_eq!(
(
&['P', 'O', 'N', 'M', 'L', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']
as &[_],
&[] as &[_]
),
tester.as_slices()
tester.as_slices(),
(['P', 'O', 'N', 'M', 'L', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'], [])
);

tester.clear();
Expand All @@ -592,12 +588,8 @@ fn make_contiguous_head_to_end() {
tester.make_contiguous();
assert_eq!(tester.head, expected_start);
assert_eq!(
(
&['K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'L', 'M', 'N', 'O', 'P']
as &[_],
&[] as &[_]
),
tester.as_slices()
tester.as_slices(),
(['K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'L', 'M', 'N', 'O', 'P'], [])
);
}

Expand Down
8 changes: 4 additions & 4 deletions library/alloctests/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ fn zero_sized_values() {

#[test]
fn test_partition() {
assert_eq!([].into_iter().partition(|x: &i32| *x < 3), (vec![], vec![]));
assert_eq!([1, 2, 3].into_iter().partition(|x| *x < 4), (vec![1, 2, 3], vec![]));
assert_eq!([1, 2, 3].into_iter().partition(|x| *x < 2), (vec![1], vec![2, 3]));
assert_eq!([1, 2, 3].into_iter().partition(|x| *x < 0), (vec![], vec![1, 2, 3]));
assert_eq!([].into_iter().partition::<Vec<_>, _>(|x: &i32| *x < 3), ([], []));
assert_eq!([1, 2, 3].into_iter().partition::<Vec<_>, _>(|x| *x < 4), ([1, 2, 3], []));
assert_eq!([1, 2, 3].into_iter().partition::<Vec<_>, _>(|x| *x < 2), ([1], [2, 3]));
assert_eq!([1, 2, 3].into_iter().partition::<Vec<_>, _>(|x| *x < 0), ([], [1, 2, 3]));
}

#[test]
Expand Down
26 changes: 13 additions & 13 deletions library/core/src/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ macro_rules! tuple_impls {
maybe_tuple_doc! {
$($T)+ @
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T: PartialEq),+> PartialEq for ($($T,)+) {
impl<$(${concat($T, _)}, $T: PartialEq<${concat($T, _)}>),+> PartialEq<($(${concat($T, _)},)+)> for ($($T,)+) {
#[inline]
fn eq(&self, other: &($($T,)+)) -> bool {
fn eq(&self, other: &($(${concat($T, _)},)+)) -> bool {
$( ${ignore($T)} self.${index()} == other.${index()} )&&+
}
#[inline]
fn ne(&self, other: &($($T,)+)) -> bool {
fn ne(&self, other: &($(${concat($T, _)},)+)) -> bool {
$( ${ignore($T)} self.${index()} != other.${index()} )||+
}
}
Expand Down Expand Up @@ -66,42 +66,42 @@ macro_rules! tuple_impls {
maybe_tuple_doc! {
$($T)+ @
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T: PartialOrd),+> PartialOrd for ($($T,)+)
impl<$(${concat($T, _)}, $T: PartialOrd<${concat($T, _)}>),+> PartialOrd<($(${concat($T, _)},)+)> for ($($T,)+)
{
#[inline]
fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
fn partial_cmp(&self, other: &($(${concat($T, _)},)+)) -> Option<Ordering> {
lexical_partial_cmp!($( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn lt(&self, other: &($($T,)+)) -> bool {
fn lt(&self, other: &($(${concat($T, _)},)+)) -> bool {
lexical_ord!(lt, __chaining_lt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn le(&self, other: &($($T,)+)) -> bool {
fn le(&self, other: &($(${concat($T, _)},)+)) -> bool {
lexical_ord!(le, __chaining_le, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn ge(&self, other: &($($T,)+)) -> bool {
fn ge(&self, other: &($(${concat($T, _)},)+)) -> bool {
lexical_ord!(ge, __chaining_ge, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn gt(&self, other: &($($T,)+)) -> bool {
fn gt(&self, other: &($(${concat($T, _)},)+)) -> bool {
lexical_ord!(gt, __chaining_gt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn __chaining_lt(&self, other: &($($T,)+)) -> ControlFlow<bool> {
fn __chaining_lt(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
lexical_chain!(__chaining_lt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn __chaining_le(&self, other: &($($T,)+)) -> ControlFlow<bool> {
fn __chaining_le(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
lexical_chain!(__chaining_le, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn __chaining_gt(&self, other: &($($T,)+)) -> ControlFlow<bool> {
fn __chaining_gt(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
lexical_chain!(__chaining_gt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
#[inline]
fn __chaining_ge(&self, other: &($($T,)+)) -> ControlFlow<bool> {
fn __chaining_ge(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
lexical_chain!(__chaining_ge, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/coretests/tests/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ where
let v: T = TestableFloat::ldexpi(x, e);
let decoded = decode_finite(v);

try_exact!(f(&decoded) => &mut buf, &expected, expectedk;
try_exact!(f(&decoded) => &mut buf, expected, expectedk;
"exact mismatch for v={x}p{e}{t}: actual {actual:?}, expected {expected:?}",
x = x, e = e, t = tstr);
try_fixed!(f(&decoded) => &mut buf, expectedk - expected.len() as i16, &expected, expectedk;
try_fixed!(f(&decoded) => &mut buf, expectedk - expected.len() as i16, expected, expectedk;
"fixed mismatch for v={x}p{e}{t}: actual {actual:?}, expected {expected:?}",
x = x, e = e, t = tstr);
}
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/net/connection/socket/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn no_lookup_host_duplicates() {
*addrs.entry(sa).or_insert(0) += 1;
}
assert_eq!(
addrs.iter().filter(|&(_, &v)| v > 1).collect::<Vec<_>>(),
vec![],
addrs.into_iter().filter(|&(_, v)| v > 1).collect::<Vec<_>>(),
[],
"There should be no duplicate localhost entries"
);
}
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fn main() {

assert_eq!(
res[..3],
[("x", "def".into()), ("y", "def".into()), ("zoo", "type:\ni32\n".into())]
[("x", "def".to_owned()), ("y", "def".to_owned()), ("zoo", "type:\ni32\n".to_owned())]
);
assert_eq!(res[3].0.len(), 115);
}
Expand All @@ -384,7 +384,7 @@ fn main() {
.map(|(range, ann)| (&text[range], ann))
.collect::<Vec<_>>();

assert_eq!(res, [("x", "a".into()), ("y", "b".into()), ("(x, y)", "c".into())]);
assert_eq!(res, [("x", "a".to_owned()), ("y", "b".to_owned()), ("(x, y)", "c".to_owned())]);
}

/// Returns `false` if slow tests should not run, otherwise returns `true` and
Expand Down
Loading