about summary refs log tree commit diff
path: root/library/core/tests
diff options
context:
space:
mode:
authorT-O-R-U-S <bageliq@protonmail.com>2022-02-12 23:16:17 +0400
committerMark Rousskov <mark.simulacrum@gmail.com>2022-03-10 10:23:40 -0500
commit72a25d05bf1a4b155d74139ef700ff93af6d8e22 (patch)
tree3f143b29a3a51b68e9b29d93e47fb0b0968ad3df /library/core/tests
parentba14a836c7038da21f5e102aacc7e6d5964f79a6 (diff)
downloadrust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.tar.gz
rust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.zip
Use implicit capture syntax in format_args
This updates the standard library's documentation to use the new syntax. The
documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.

A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).
Diffstat (limited to 'library/core/tests')
-rw-r--r--library/core/tests/any.rs16
-rw-r--r--library/core/tests/cell.rs8
-rw-r--r--library/core/tests/fmt/builders.rs126
-rw-r--r--library/core/tests/fmt/mod.rs8
-rw-r--r--library/core/tests/fmt/num.rs2
-rw-r--r--library/core/tests/lazy.rs2
-rw-r--r--library/core/tests/num/dec2flt/mod.rs8
-rw-r--r--library/core/tests/num/dec2flt/parse.rs2
-rw-r--r--library/core/tests/num/flt2dec/mod.rs2
-rw-r--r--library/core/tests/num/flt2dec/random.rs2
-rw-r--r--library/core/tests/ptr.rs2
-rw-r--r--library/core/tests/result.rs4
12 files changed, 91 insertions, 91 deletions
diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs
index b36d6f0d404..eccddcbbf59 100644
--- a/library/core/tests/any.rs
+++ b/library/core/tests/any.rs
@@ -46,12 +46,12 @@ fn any_downcast_ref() {
 
     match a.downcast_ref::<usize>() {
         Some(&5) => {}
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 
     match a.downcast_ref::<Test>() {
         None => {}
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 }
 
@@ -69,7 +69,7 @@ fn any_downcast_mut() {
             assert_eq!(*x, 5);
             *x = 612;
         }
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 
     match b_r.downcast_mut::<usize>() {
@@ -77,27 +77,27 @@ fn any_downcast_mut() {
             assert_eq!(*x, 7);
             *x = 413;
         }
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 
     match a_r.downcast_mut::<Test>() {
         None => (),
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 
     match b_r.downcast_mut::<Test>() {
         None => (),
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 
     match a_r.downcast_mut::<usize>() {
         Some(&mut 612) => {}
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 
     match b_r.downcast_mut::<usize>() {
         Some(&mut 413) => {}
-        x => panic!("Unexpected value {:?}", x),
+        x => panic!("Unexpected value {x:?}"),
     }
 }
 
diff --git a/library/core/tests/cell.rs b/library/core/tests/cell.rs
index 4707cc7076e..f15e03076ca 100644
--- a/library/core/tests/cell.rs
+++ b/library/core/tests/cell.rs
@@ -62,10 +62,10 @@ fn cell_update() {
 #[test]
 fn cell_has_sensible_show() {
     let x = Cell::new("foo bar");
-    assert!(format!("{:?}", x).contains(x.get()));
+    assert!(format!("{x:?}").contains(x.get()));
 
     x.set("baz qux");
-    assert!(format!("{:?}", x).contains(x.get()));
+    assert!(format!("{x:?}").contains(x.get()));
 }
 
 #[test]
@@ -73,11 +73,11 @@ fn ref_and_refmut_have_sensible_show() {
     let refcell = RefCell::new("foo");
 
     let refcell_refmut = refcell.borrow_mut();
-    assert!(format!("{:?}", refcell_refmut).contains("foo"));
+    assert!(format!("{refcell_refmut:?}").contains("foo"));
     drop(refcell_refmut);
 
     let refcell_ref = refcell.borrow();
-    assert!(format!("{:?}", refcell_ref).contains("foo"));
+    assert!(format!("{refcell_ref:?}").contains("foo"));
     drop(refcell_ref);
 }
 
diff --git a/library/core/tests/fmt/builders.rs b/library/core/tests/fmt/builders.rs
index 9567479c813..487ce46be28 100644
--- a/library/core/tests/fmt/builders.rs
+++ b/library/core/tests/fmt/builders.rs
@@ -11,8 +11,8 @@ mod debug_struct {
             }
         }
 
-        assert_eq!("Foo", format!("{:?}", Foo));
-        assert_eq!("Foo", format!("{:#?}", Foo));
+        assert_eq!("Foo", format!("{Foo:?}"));
+        assert_eq!("Foo", format!("{Foo:#?}"));
     }
 
     #[test]
@@ -25,12 +25,12 @@ mod debug_struct {
             }
         }
 
-        assert_eq!("Foo { bar: true }", format!("{:?}", Foo));
+        assert_eq!("Foo { bar: true }", format!("{Foo:?}"));
         assert_eq!(
             "Foo {
     bar: true,
 }",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -47,13 +47,13 @@ mod debug_struct {
             }
         }
 
-        assert_eq!("Foo { bar: true, baz: 10/20 }", format!("{:?}", Foo));
+        assert_eq!("Foo { bar: true, baz: 10/20 }", format!("{Foo:?}"));
         assert_eq!(
             "Foo {
     bar: true,
     baz: 10/20,
 }",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -80,7 +80,7 @@ mod debug_struct {
 
         assert_eq!(
             "Bar { foo: Foo { bar: true, baz: 10/20 }, hello: \"world\" }",
-            format!("{:?}", Bar)
+            format!("{Bar:?}")
         );
         assert_eq!(
             "Bar {
@@ -90,7 +90,7 @@ mod debug_struct {
     },
     hello: \"world\",
 }",
-            format!("{:#?}", Bar)
+            format!("{Bar:#?}")
         );
     }
 
@@ -104,8 +104,8 @@ mod debug_struct {
             }
         }
 
-        assert_eq!("Foo { .. }", format!("{:?}", Foo));
-        assert_eq!("Foo { .. }", format!("{:#?}", Foo));
+        assert_eq!("Foo { .. }", format!("{Foo:?}"));
+        assert_eq!("Foo { .. }", format!("{Foo:#?}"));
     }
 
     #[test]
@@ -121,14 +121,14 @@ mod debug_struct {
             }
         }
 
-        assert_eq!("Foo { bar: true, baz: 10/20, .. }", format!("{:?}", Foo));
+        assert_eq!("Foo { bar: true, baz: 10/20, .. }", format!("{Foo:?}"));
         assert_eq!(
             "Foo {
     bar: true,
     baz: 10/20,
     ..
 }",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -158,7 +158,7 @@ mod debug_struct {
 
         assert_eq!(
             "Bar { foo: Foo { bar: true, baz: 10/20, .. }, hello: \"world\", .. }",
-            format!("{:?}", Bar)
+            format!("{Bar:?}")
         );
         assert_eq!(
             "Bar {
@@ -170,7 +170,7 @@ mod debug_struct {
     hello: \"world\",
     ..
 }",
-            format!("{:#?}", Bar)
+            format!("{Bar:#?}")
         );
     }
 }
@@ -188,8 +188,8 @@ mod debug_tuple {
             }
         }
 
-        assert_eq!("Foo", format!("{:?}", Foo));
-        assert_eq!("Foo", format!("{:#?}", Foo));
+        assert_eq!("Foo", format!("{Foo:?}"));
+        assert_eq!("Foo", format!("{Foo:#?}"));
     }
 
     #[test]
@@ -202,12 +202,12 @@ mod debug_tuple {
             }
         }
 
-        assert_eq!("Foo(true)", format!("{:?}", Foo));
+        assert_eq!("Foo(true)", format!("{Foo:?}"));
         assert_eq!(
             "Foo(
     true,
 )",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -221,13 +221,13 @@ mod debug_tuple {
             }
         }
 
-        assert_eq!("Foo(true, 10/20)", format!("{:?}", Foo));
+        assert_eq!("Foo(true, 10/20)", format!("{Foo:?}"));
         assert_eq!(
             "Foo(
     true,
     10/20,
 )",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -249,7 +249,7 @@ mod debug_tuple {
             }
         }
 
-        assert_eq!("Bar(Foo(true, 10/20), \"world\")", format!("{:?}", Bar));
+        assert_eq!("Bar(Foo(true, 10/20), \"world\")", format!("{Bar:?}"));
         assert_eq!(
             "Bar(
     Foo(
@@ -258,7 +258,7 @@ mod debug_tuple {
     ),
     \"world\",
 )",
-            format!("{:#?}", Bar)
+            format!("{Bar:#?}")
         );
     }
 }
@@ -276,8 +276,8 @@ mod debug_map {
             }
         }
 
-        assert_eq!("{}", format!("{:?}", Foo));
-        assert_eq!("{}", format!("{:#?}", Foo));
+        assert_eq!("{}", format!("{Foo:?}"));
+        assert_eq!("{}", format!("{Foo:#?}"));
     }
 
     #[test]
@@ -298,15 +298,15 @@ mod debug_map {
             }
         }
 
-        assert_eq!(format!("{:?}", Entry), format!("{:?}", KeyValue));
-        assert_eq!(format!("{:#?}", Entry), format!("{:#?}", KeyValue));
+        assert_eq!(format!("{Entry:?}"), format!("{KeyValue:?}"));
+        assert_eq!(format!("{Entry:#?}"), format!("{KeyValue:#?}"));
 
-        assert_eq!("{\"bar\": true}", format!("{:?}", Entry));
+        assert_eq!("{\"bar\": true}", format!("{Entry:?}"));
         assert_eq!(
             "{
     \"bar\": true,
 }",
-            format!("{:#?}", Entry)
+            format!("{Entry:#?}")
         );
     }
 
@@ -336,16 +336,16 @@ mod debug_map {
             }
         }
 
-        assert_eq!(format!("{:?}", Entry), format!("{:?}", KeyValue));
-        assert_eq!(format!("{:#?}", Entry), format!("{:#?}", KeyValue));
+        assert_eq!(format!("{Entry:?}"), format!("{KeyValue:?}"));
+        assert_eq!(format!("{Entry:#?}"), format!("{KeyValue:#?}"));
 
-        assert_eq!("{\"bar\": true, 10: 10/20}", format!("{:?}", Entry));
+        assert_eq!("{\"bar\": true, 10: 10/20}", format!("{Entry:?}"));
         assert_eq!(
             "{
     \"bar\": true,
     10: 10/20,
 }",
-            format!("{:#?}", Entry)
+            format!("{Entry:#?}")
         );
     }
 
@@ -373,7 +373,7 @@ mod debug_map {
         assert_eq!(
             "{\"foo\": {\"bar\": true, 10: 10/20}, \
                     {\"bar\": true, 10: 10/20}: \"world\"}",
-            format!("{:?}", Bar)
+            format!("{Bar:?}")
         );
         assert_eq!(
             "{
@@ -386,7 +386,7 @@ mod debug_map {
         10: 10/20,
     }: \"world\",
 }",
-            format!("{:#?}", Bar)
+            format!("{Bar:#?}")
         );
     }
 
@@ -441,7 +441,7 @@ mod debug_map {
             }
         }
 
-        format!("{:?}", Foo);
+        format!("{Foo:?}");
     }
 
     #[test]
@@ -455,7 +455,7 @@ mod debug_map {
             }
         }
 
-        format!("{:?}", Foo);
+        format!("{Foo:?}");
     }
 
     #[test]
@@ -469,7 +469,7 @@ mod debug_map {
             }
         }
 
-        format!("{:?}", Foo);
+        format!("{Foo:?}");
     }
 }
 
@@ -486,8 +486,8 @@ mod debug_set {
             }
         }
 
-        assert_eq!("{}", format!("{:?}", Foo));
-        assert_eq!("{}", format!("{:#?}", Foo));
+        assert_eq!("{}", format!("{Foo:?}"));
+        assert_eq!("{}", format!("{Foo:#?}"));
     }
 
     #[test]
@@ -500,12 +500,12 @@ mod debug_set {
             }
         }
 
-        assert_eq!("{true}", format!("{:?}", Foo));
+        assert_eq!("{true}", format!("{Foo:?}"));
         assert_eq!(
             "{
     true,
 }",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -519,13 +519,13 @@ mod debug_set {
             }
         }
 
-        assert_eq!("{true, 10/20}", format!("{:?}", Foo));
+        assert_eq!("{true, 10/20}", format!("{Foo:?}"));
         assert_eq!(
             "{
     true,
     10/20,
 }",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -547,7 +547,7 @@ mod debug_set {
             }
         }
 
-        assert_eq!("{{true, 10/20}, \"world\"}", format!("{:?}", Bar));
+        assert_eq!("{{true, 10/20}, \"world\"}", format!("{Bar:?}"));
         assert_eq!(
             "{
     {
@@ -556,7 +556,7 @@ mod debug_set {
     },
     \"world\",
 }",
-            format!("{:#?}", Bar)
+            format!("{Bar:#?}")
         );
     }
 }
@@ -574,8 +574,8 @@ mod debug_list {
             }
         }
 
-        assert_eq!("[]", format!("{:?}", Foo));
-        assert_eq!("[]", format!("{:#?}", Foo));
+        assert_eq!("[]", format!("{Foo:?}"));
+        assert_eq!("[]", format!("{Foo:#?}"));
     }
 
     #[test]
@@ -588,12 +588,12 @@ mod debug_list {
             }
         }
 
-        assert_eq!("[true]", format!("{:?}", Foo));
+        assert_eq!("[true]", format!("{Foo:?}"));
         assert_eq!(
             "[
     true,
 ]",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -607,13 +607,13 @@ mod debug_list {
             }
         }
 
-        assert_eq!("[true, 10/20]", format!("{:?}", Foo));
+        assert_eq!("[true, 10/20]", format!("{Foo:?}"));
         assert_eq!(
             "[
     true,
     10/20,
 ]",
-            format!("{:#?}", Foo)
+            format!("{Foo:#?}")
         );
     }
 
@@ -635,7 +635,7 @@ mod debug_list {
             }
         }
 
-        assert_eq!("[[true, 10/20], \"world\"]", format!("{:?}", Bar));
+        assert_eq!("[[true, 10/20], \"world\"]", format!("{Bar:?}"));
         assert_eq!(
             "[
     [
@@ -644,7 +644,7 @@ mod debug_list {
     ],
     \"world\",
 ]",
-            format!("{:#?}", Bar)
+            format!("{Bar:#?}")
         );
     }
 }
@@ -668,13 +668,13 @@ fn test_formatting_parameters_are_forwarded() {
     set.insert(1024);
     set.insert(7);
 
-    assert_eq!(format!("{:03?}", struct_), "Foo { bar: 1024, baz: 007 }");
-    assert_eq!(format!("{:03?}", tuple), "(1024, 007)");
-    assert_eq!(format!("{:03?}", list), "[1024, 007]");
-    assert_eq!(format!("{:03?}", map), r#"{"bar": 1024, "baz": 007}"#);
-    assert_eq!(format!("{:03?}", set), "{007, 1024}");
+    assert_eq!(format!("{struct_:03?}"), "Foo { bar: 1024, baz: 007 }");
+    assert_eq!(format!("{tuple:03?}"), "(1024, 007)");
+    assert_eq!(format!("{list:03?}"), "[1024, 007]");
+    assert_eq!(format!("{map:03?}"), r#"{"bar": 1024, "baz": 007}"#);
+    assert_eq!(format!("{set:03?}"), "{007, 1024}");
     assert_eq!(
-        format!("{:#03?}", struct_),
+        format!("{struct_:#03?}"),
         "
 Foo {
     bar: 1024,
@@ -684,7 +684,7 @@ Foo {
         .trim()
     );
     assert_eq!(
-        format!("{:#03?}", tuple),
+        format!("{tuple:#03?}"),
         "
 (
     1024,
@@ -694,7 +694,7 @@ Foo {
         .trim()
     );
     assert_eq!(
-        format!("{:#03?}", list),
+        format!("{list:#03?}"),
         "
 [
     1024,
@@ -704,7 +704,7 @@ Foo {
         .trim()
     );
     assert_eq!(
-        format!("{:#03?}", map),
+        format!("{map:#03?}"),
         r#"
 {
     "bar": 1024,
@@ -714,7 +714,7 @@ Foo {
         .trim()
     );
     assert_eq!(
-        format!("{:#03?}", set),
+        format!("{set:#03?}"),
         "
 {
     007,
diff --git a/library/core/tests/fmt/mod.rs b/library/core/tests/fmt/mod.rs
index 7b281ce48e6..61807635813 100644
--- a/library/core/tests/fmt/mod.rs
+++ b/library/core/tests/fmt/mod.rs
@@ -6,7 +6,7 @@ mod num;
 fn test_format_flags() {
     // No residual flags left by pointer formatting
     let p = "".as_ptr();
-    assert_eq!(format!("{:p} {:x}", p, 16), format!("{:p} 10", p));
+    assert_eq!(format!("{:p} {:x}", p, 16), format!("{p:p} 10"));
 
     assert_eq!(format!("{: >3}", 'a'), "  a");
 }
@@ -15,8 +15,8 @@ fn test_format_flags() {
 fn test_pointer_formats_data_pointer() {
     let b: &[u8] = b"";
     let s: &str = "";
-    assert_eq!(format!("{:p}", s), format!("{:p}", s.as_ptr()));
-    assert_eq!(format!("{:p}", b), format!("{:p}", b.as_ptr()));
+    assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr()));
+    assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr()));
 }
 
 #[test]
@@ -41,5 +41,5 @@ fn pad_integral_resets() {
         }
     }
 
-    assert_eq!(format!("{:<03}", Bar), "1  0051  ");
+    assert_eq!(format!("{Bar:<03}"), "1  0051  ");
 }
diff --git a/library/core/tests/fmt/num.rs b/library/core/tests/fmt/num.rs
index b958422d14f..b9ede65c9ff 100644
--- a/library/core/tests/fmt/num.rs
+++ b/library/core/tests/fmt/num.rs
@@ -126,7 +126,7 @@ fn test_format_int_exp_limits() {
 fn test_format_int_exp_precision() {
     //test that float and integer match
     let big_int: u32 = 314_159_265;
-    assert_eq!(format!("{:.1e}", big_int), format!("{:.1e}", f64::from(big_int)));
+    assert_eq!(format!("{big_int:.1e}"), format!("{:.1e}", f64::from(big_int)));
 
     //test adding precision
     assert_eq!(format!("{:.10e}", i8::MIN), "-1.2800000000e2");
diff --git a/library/core/tests/lazy.rs b/library/core/tests/lazy.rs
index 064024ab87b..416d2b2dae4 100644
--- a/library/core/tests/lazy.rs
+++ b/library/core/tests/lazy.rs
@@ -113,7 +113,7 @@ fn aliasing_in_get() {
     x.set(42).unwrap();
     let at_x = x.get().unwrap(); // --- (shared) borrow of inner `Option<T>` --+
     let _ = x.set(27); // <-- temporary (unique) borrow of inner `Option<T>`   |
-    println!("{}", at_x); // <------- up until here ---------------------------+
+    println!("{at_x}"); // <------- up until here ---------------------------+
 }
 
 #[test]
diff --git a/library/core/tests/num/dec2flt/mod.rs b/library/core/tests/num/dec2flt/mod.rs
index 4990d4a083d..c4e105cba60 100644
--- a/library/core/tests/num/dec2flt/mod.rs
+++ b/library/core/tests/num/dec2flt/mod.rs
@@ -15,7 +15,7 @@ macro_rules! test_literal {
         for input in inputs {
             assert_eq!(input.parse(), Ok(x64));
             assert_eq!(input.parse(), Ok(x32));
-            let neg_input = &format!("-{}", input);
+            let neg_input = &format!("-{input}");
             assert_eq!(neg_input.parse(), Ok(-x64));
             assert_eq!(neg_input.parse(), Ok(-x32));
         }
@@ -123,9 +123,9 @@ fn inf() {
 #[test]
 fn massive_exponent() {
     let max = i64::MAX;
-    assert_eq!(format!("1e{}000", max).parse(), Ok(f64::INFINITY));
-    assert_eq!(format!("1e-{}000", max).parse(), Ok(0.0));
-    assert_eq!(format!("1e{}000", max).parse(), Ok(f64::INFINITY));
+    assert_eq!(format!("1e{max}000").parse(), Ok(f64::INFINITY));
+    assert_eq!(format!("1e-{max}000").parse(), Ok(0.0));
+    assert_eq!(format!("1e{max}000").parse(), Ok(f64::INFINITY));
 }
 
 #[test]
diff --git a/library/core/tests/num/dec2flt/parse.rs b/library/core/tests/num/dec2flt/parse.rs
index 473feacc91f..edc77377d58 100644
--- a/library/core/tests/num/dec2flt/parse.rs
+++ b/library/core/tests/num/dec2flt/parse.rs
@@ -46,7 +46,7 @@ fn valid() {
     assert_eq!(parse_positive(b".1e300"), Some(new_number(299, 1)));
     assert_eq!(parse_positive(b"101e-33"), Some(new_number(-33, 101)));
     let zeros = "0".repeat(25);
-    let s = format!("1.5e{}", zeros);
+    let s = format!("1.5e{zeros}");
     assert_eq!(parse_positive(s.as_bytes()), Some(new_number(-1, 15)));
 }
 
diff --git a/library/core/tests/num/flt2dec/mod.rs b/library/core/tests/num/flt2dec/mod.rs
index 4874e8ec09f..798473bbde3 100644
--- a/library/core/tests/num/flt2dec/mod.rs
+++ b/library/core/tests/num/flt2dec/mod.rs
@@ -20,7 +20,7 @@ mod random;
 pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
     match decode(v).1 {
         FullDecoded::Finite(decoded) => decoded,
-        full_decoded => panic!("expected finite, got {:?} instead", full_decoded),
+        full_decoded => panic!("expected finite, got {full_decoded:?} instead"),
     }
 }
 
diff --git a/library/core/tests/num/flt2dec/random.rs b/library/core/tests/num/flt2dec/random.rs
index 57b3dcf8e1e..d0950039314 100644
--- a/library/core/tests/num/flt2dec/random.rs
+++ b/library/core/tests/num/flt2dec/random.rs
@@ -15,7 +15,7 @@ use rand::SeedableRng;
 pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
     match decode(v).1 {
         FullDecoded::Finite(decoded) => decoded,
-        full_decoded => panic!("expected finite, got {:?} instead", full_decoded),
+        full_decoded => panic!("expected finite, got {full_decoded:?} instead"),
     }
 }
 
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
index 9c65871ac4b..af8e78f1f4e 100644
--- a/library/core/tests/ptr.rs
+++ b/library/core/tests/ptr.rs
@@ -550,7 +550,7 @@ fn dyn_metadata() {
     assert_eq!(meta.align_of(), std::mem::align_of::<Something>());
     assert_eq!(meta.layout(), std::alloc::Layout::new::<Something>());
 
-    assert!(format!("{:?}", meta).starts_with("DynMetadata(0x"));
+    assert!(format!("{meta:?}").starts_with("DynMetadata(0x"));
 }
 
 #[test]
diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs
index 1652c1b83de..98b870512b0 100644
--- a/library/core/tests/result.rs
+++ b/library/core/tests/result.rs
@@ -80,9 +80,9 @@ fn test_fmt_default() {
     let ok: Result<isize, &'static str> = Ok(100);
     let err: Result<isize, &'static str> = Err("Err");
 
-    let s = format!("{:?}", ok);
+    let s = format!("{ok:?}");
     assert_eq!(s, "Ok(100)");
-    let s = format!("{:?}", err);
+    let s = format!("{err:?}");
     assert_eq!(s, "Err(\"Err\")");
 }