diff options
Diffstat (limited to 'library/alloc/tests')
| -rw-r--r-- | library/alloc/tests/fmt.rs | 24 | ||||
| -rw-r--r-- | library/alloc/tests/linked_list.rs | 4 | ||||
| -rw-r--r-- | library/alloc/tests/slice.rs | 12 | ||||
| -rw-r--r-- | library/alloc/tests/str.rs | 10 | ||||
| -rw-r--r-- | library/alloc/tests/string.rs | 4 | ||||
| -rw-r--r-- | library/alloc/tests/vec.rs | 6 | ||||
| -rw-r--r-- | library/alloc/tests/vec_deque.rs | 4 |
7 files changed, 32 insertions, 32 deletions
diff --git a/library/alloc/tests/fmt.rs b/library/alloc/tests/fmt.rs index 27ab6c07e43..1575a5999f9 100644 --- a/library/alloc/tests/fmt.rs +++ b/library/alloc/tests/fmt.rs @@ -84,8 +84,8 @@ fn test_format_macro_interface() { } t!(format!("{:p}", 0x1234 as *const isize), "0x1234"); t!(format!("{:p}", 0x1234 as *mut isize), "0x1234"); - t!(format!("{:x}", A), "aloha"); - t!(format!("{:X}", B), "adios"); + t!(format!("{A:x}"), "aloha"); + t!(format!("{B:X}"), "adios"); t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃"); t!(format!("{1} {0}", 0, 1), "1 0"); t!(format!("{foo} {bar}", foo = 0, bar = 1), "0 1"); @@ -94,11 +94,11 @@ fn test_format_macro_interface() { t!(format!("{_foo}", _foo = 6usize), "6"); t!(format!("{foo_bar}", foo_bar = 1), "1"); t!(format!("{}", 5 + 5), "10"); - t!(format!("{:#4}", C), "☃123"); - t!(format!("{:b}", D), "aa☃bb"); + t!(format!("{C:#4}"), "☃123"); + t!(format!("{D:b}"), "aa☃bb"); let a: &dyn fmt::Debug = &1; - t!(format!("{:?}", a), "1"); + t!(format!("{a:?}"), "1"); // Formatting strings and their arguments t!(format!("{}", "a"), "a"); @@ -206,7 +206,7 @@ fn test_format_macro_interface() { // Test that pointers don't get truncated. { let val = usize::MAX; - let exp = format!("{:#x}", val); + let exp = format!("{val:#x}"); t!(format!("{:p}", val as *const isize), exp); } @@ -216,14 +216,14 @@ fn test_format_macro_interface() { // make sure that format! doesn't move out of local variables let a = Box::new(3); - format!("{}", a); - format!("{}", a); + format!("{a}"); + format!("{a}"); // make sure that format! doesn't cause spurious unused-unsafe warnings when // it's inside of an outer unsafe block unsafe { let a: isize = ::std::mem::transmute(3_usize); - format!("{}", a); + format!("{a}"); } // test that trailing commas are acceptable @@ -315,9 +315,9 @@ fn test_once() { #[test] fn test_refcell() { let refcell = RefCell::new(5); - assert_eq!(format!("{:?}", refcell), "RefCell { value: 5 }"); + assert_eq!(format!("{refcell:?}"), "RefCell { value: 5 }"); let borrow = refcell.borrow_mut(); - assert_eq!(format!("{:?}", refcell), "RefCell { value: <borrowed> }"); + assert_eq!(format!("{refcell:?}"), "RefCell { value: <borrowed> }"); drop(borrow); - assert_eq!(format!("{:?}", refcell), "RefCell { value: 5 }"); + assert_eq!(format!("{refcell:?}"), "RefCell { value: 5 }"); } diff --git a/library/alloc/tests/linked_list.rs b/library/alloc/tests/linked_list.rs index 5f5bd9af2fe..66a9cca6644 100644 --- a/library/alloc/tests/linked_list.rs +++ b/library/alloc/tests/linked_list.rs @@ -302,10 +302,10 @@ fn test_ord_nan() { #[test] fn test_show() { let list: LinkedList<_> = (0..10).collect(); - assert_eq!(format!("{:?}", list), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + assert_eq!(format!("{list:?}"), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let list: LinkedList<_> = ["just", "one", "test", "more"].into_iter().collect(); - assert_eq!(format!("{:?}", list), "[\"just\", \"one\", \"test\", \"more\"]"); + assert_eq!(format!("{list:?}"), "[\"just\", \"one\", \"test\", \"more\"]"); } #[test] diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index b93d7938bc9..b027a25a146 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1045,10 +1045,10 @@ fn test_split_iterators_size_hint() { a(v.rsplit_mut(p), b, "rsplit_mut"); for n in 0..=3 { - a(v.splitn(n, p), b, f!("splitn, n = {}", n)); - a(v.splitn_mut(n, p), b, f!("splitn_mut, n = {}", n)); - a(v.rsplitn(n, p), b, f!("rsplitn, n = {}", n)); - a(v.rsplitn_mut(n, p), b, f!("rsplitn_mut, n = {}", n)); + a(v.splitn(n, p), b, f!("splitn, n = {n}")); + a(v.splitn_mut(n, p), b, f!("splitn_mut, n = {n}")); + a(v.rsplitn(n, p), b, f!("rsplitn, n = {n}")); + a(v.rsplitn_mut(n, p), b, f!("rsplitn_mut, n = {n}")); } } } @@ -1184,8 +1184,8 @@ fn test_show() { macro_rules! test_show_vec { ($x:expr, $x_str:expr) => {{ let (x, x_str) = ($x, $x_str); - assert_eq!(format!("{:?}", x), x_str); - assert_eq!(format!("{:?}", x), x_str); + assert_eq!(format!("{x:?}"), x_str); + assert_eq!(format!("{x:?}"), x_str); }}; } let empty = Vec::<i32>::new(); diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index 6b8be2506b6..f3ed611acda 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -1259,7 +1259,7 @@ fn test_chars_debug() { let s = "ศไทย中华Việt Nam"; let c = s.chars(); assert_eq!( - format!("{:?}", c), + format!("{c:?}"), r#"Chars(['ศ', 'ไ', 'ท', 'ย', '中', '华', 'V', 'i', 'ệ', 't', ' ', 'N', 'a', 'm'])"# ); } @@ -1870,7 +1870,7 @@ mod pattern { } if let Some(err) = err { - panic!("Input skipped range at {}", err); + panic!("Input skipped range at {err}"); } if first_index != haystack.len() { @@ -2187,10 +2187,10 @@ fn utf8() { fn check_str_eq(a: String, b: String) { let mut i: isize = 0; for ab in a.bytes() { - println!("{}", i); - println!("{}", ab); + println!("{i}"); + println!("{ab}"); let bb: u8 = b.as_bytes()[i as usize]; - println!("{}", bb); + println!("{bb}"); assert_eq!(ab, bb); i += 1; } diff --git a/library/alloc/tests/string.rs b/library/alloc/tests/string.rs index 893283e5a24..b6836fdc88e 100644 --- a/library/alloc/tests/string.rs +++ b/library/alloc/tests/string.rs @@ -470,7 +470,7 @@ fn test_simple_types() { #[test] fn test_vectors() { let x: Vec<i32> = vec![]; - assert_eq!(format!("{:?}", x), "[]"); + assert_eq!(format!("{x:?}"), "[]"); assert_eq!(format!("{:?}", vec![1]), "[1]"); assert_eq!(format!("{:?}", vec![1, 2, 3]), "[1, 2, 3]"); assert!(format!("{:?}", vec![vec![], vec![1], vec![1, 1]]) == "[[], [1], [1, 1]]"); @@ -871,6 +871,6 @@ fn test_from_char() { fn test_str_concat() { let a: String = "hello".to_string(); let b: String = "world".to_string(); - let s: String = format!("{}{}", a, b); + let s: String = format!("{a}{b}"); assert_eq!(s.as_bytes()[9], 'd' as u8); } diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 705914b4497..ca0fcc855c7 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -100,7 +100,7 @@ fn test_debug_fmt() { assert_eq!("[0, 1]", format!("{:?}", vec2)); let slice: &[isize] = &[4, 5]; - assert_eq!("[4, 5]", format!("{:?}", slice)); + assert_eq!("[4, 5]", format!("{slice:?}")); } #[test] @@ -918,7 +918,7 @@ fn test_into_iter_as_mut_slice() { fn test_into_iter_debug() { let vec = vec!['a', 'b', 'c']; let into_iter = vec.into_iter(); - let debug = format!("{:?}", into_iter); + let debug = format!("{into_iter:?}"); assert_eq!(debug, "IntoIter(['a', 'b', 'c'])"); } @@ -2336,7 +2336,7 @@ fn test_vec_dedup_panicking() { let ok = vec.iter().zip(expected.iter()).all(|(x, y)| x.index == y.index); if !ok { - panic!("expected: {:?}\ngot: {:?}\n", expected, vec); + panic!("expected: {expected:?}\ngot: {vec:?}\n"); } } diff --git a/library/alloc/tests/vec_deque.rs b/library/alloc/tests/vec_deque.rs index 18954f094c6..89cc7f905be 100644 --- a/library/alloc/tests/vec_deque.rs +++ b/library/alloc/tests/vec_deque.rs @@ -647,10 +647,10 @@ fn test_ord() { #[test] fn test_show() { let ringbuf: VecDeque<_> = (0..10).collect(); - assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + assert_eq!(format!("{ringbuf:?}"), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"].iter().cloned().collect(); - assert_eq!(format!("{:?}", ringbuf), "[\"just\", \"one\", \"test\", \"more\"]"); + assert_eq!(format!("{ringbuf:?}"), "[\"just\", \"one\", \"test\", \"more\"]"); } #[test] |
