diff options
Diffstat (limited to 'library/std/src')
72 files changed, 285 insertions, 293 deletions
| diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 8ee55234cea..a8804396246 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -83,7 +83,7 @@ pub use alloc_crate::alloc::*; /// /// fn main() { /// let a = Box::new(4); // Allocates from the system allocator. -/// println!("{}", a); +/// println!("{a}"); /// } /// ``` /// diff --git a/library/std/src/backtrace/tests.rs b/library/std/src/backtrace/tests.rs index f5da93f93fd..4dfbf88e83e 100644 --- a/library/std/src/backtrace/tests.rs +++ b/library/std/src/backtrace/tests.rs @@ -57,10 +57,10 @@ fn test_debug() { \n { fn: \"std::rt::lang_start\", file: \"rust/rt.rs\", line: 400 },\ \n]"; - assert_eq!(format!("{:#?}", backtrace), expected); + assert_eq!(format!("{backtrace:#?}"), expected); // Format the backtrace a second time, just to make sure lazily resolved state is stable - assert_eq!(format!("{:#?}", backtrace), expected); + assert_eq!(format!("{backtrace:#?}"), expected); } #[test] @@ -91,5 +91,5 @@ fn test_frames() { let mut iter = frames.iter().zip(expected.iter()); - assert!(iter.all(|(f, e)| format!("{:#?}", f) == *e)); + assert!(iter.all(|(f, e)| format!("{f:#?}") == *e)); } diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index c0524352193..b5dd17d9929 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -109,8 +109,8 @@ use crate::sys; /// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"]; /// for &book in &to_find { /// match book_reviews.get(book) { -/// Some(review) => println!("{}: {}", book, review), -/// None => println!("{} is unreviewed.", book) +/// Some(review) => println!("{book}: {review}"), +/// None => println!("{book} is unreviewed.") /// } /// } /// @@ -119,7 +119,7 @@ use crate::sys; /// /// // Iterate over everything. /// for (book, review) in &book_reviews { -/// println!("{}: \"{}\"", book, review); +/// println!("{book}: \"{review}\""); /// } /// ``` /// @@ -199,7 +199,7 @@ use crate::sys; /// /// // Use derived implementation to print the status of the vikings. /// for (viking, health) in &vikings { -/// println!("{:?} has {} hp", viking, health); +/// println!("{viking:?} has {health} hp"); /// } /// ``` @@ -341,7 +341,7 @@ impl<K, V, S> HashMap<K, V, S> { /// ]); /// /// for key in map.keys() { - /// println!("{}", key); + /// println!("{key}"); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -392,7 +392,7 @@ impl<K, V, S> HashMap<K, V, S> { /// ]); /// /// for val in map.values() { - /// println!("{}", val); + /// println!("{val}"); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -419,7 +419,7 @@ impl<K, V, S> HashMap<K, V, S> { /// } /// /// for val in map.values() { - /// println!("{}", val); + /// println!("{val}"); /// } /// ``` #[stable(feature = "map_values_mut", since = "1.10.0")] @@ -470,7 +470,7 @@ impl<K, V, S> HashMap<K, V, S> { /// ]); /// /// for (key, val) in map.iter() { - /// println!("key: {} val: {}", key, val); + /// println!("key: {key} val: {val}"); /// } /// ``` #[rustc_lint_query_instability] @@ -500,7 +500,7 @@ impl<K, V, S> HashMap<K, V, S> { /// } /// /// for (key, val) in &map { - /// println!("key: {} val: {}", key, val); + /// println!("key: {key} val: {val}"); /// } /// ``` #[rustc_lint_query_instability] diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs index 30da22b8084..7ebc41588b3 100644 --- a/library/std/src/collections/hash/map/tests.rs +++ b/library/std/src/collections/hash/map/tests.rs @@ -515,10 +515,10 @@ fn test_show() { map.insert(1, 2); map.insert(3, 4); - let map_str = format!("{:?}", map); + let map_str = format!("{map:?}"); assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}"); - assert_eq!(format!("{:?}", empty), "{}"); + assert_eq!(format!("{empty:?}"), "{}"); } #[test] @@ -702,7 +702,7 @@ fn test_entry_take_doesnt_corrupt() { // Test for #19292 fn check(m: &HashMap<i32, ()>) { for k in m.keys() { - assert!(m.contains_key(k), "{} is in keys() but not in the map?", k); + assert!(m.contains_key(k), "{k} is in keys() but not in the map?"); } } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 2eb4cacabb8..876d05b50fb 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -66,7 +66,7 @@ use super::map::{map_try_reserve_error, RandomState}; /// /// // Iterate over everything. /// for book in &books { -/// println!("{}", book); +/// println!("{book}"); /// } /// ``` /// @@ -91,7 +91,7 @@ use super::map::{map_try_reserve_error, RandomState}; /// /// // Use derived implementation to print the vikings. /// for x in &vikings { -/// println!("{:?}", x); +/// println!("{x:?}"); /// } /// ``` /// @@ -181,7 +181,7 @@ impl<T, S> HashSet<T, S> { /// /// // Will print in an arbitrary order. /// for x in set.iter() { - /// println!("{}", x); + /// println!("{x}"); /// } /// ``` #[inline] @@ -244,7 +244,7 @@ impl<T, S> HashSet<T, S> { /// /// // print 1, 2, 3 in an arbitrary order /// for i in set.drain() { - /// println!("{}", i); + /// println!("{i}"); /// } /// /// assert!(set.is_empty()); @@ -525,7 +525,7 @@ where /// /// // Can be seen as `a - b`. /// for x in a.difference(&b) { - /// println!("{}", x); // Print 1 + /// println!("{x}"); // Print 1 /// } /// /// let diff: HashSet<_> = a.difference(&b).collect(); @@ -555,7 +555,7 @@ where /// /// // Print 1, 4 in arbitrary order. /// for x in a.symmetric_difference(&b) { - /// println!("{}", x); + /// println!("{x}"); /// } /// /// let diff1: HashSet<_> = a.symmetric_difference(&b).collect(); @@ -586,7 +586,7 @@ where /// /// // Print 2, 3 in arbitrary order. /// for x in a.intersection(&b) { - /// println!("{}", x); + /// println!("{x}"); /// } /// /// let intersection: HashSet<_> = a.intersection(&b).collect(); @@ -615,7 +615,7 @@ where /// /// // Print 1, 2, 3, 4 in arbitrary order. /// for x in a.union(&b) { - /// println!("{}", x); + /// println!("{x}"); /// } /// /// let union: HashSet<_> = a.union(&b).collect(); @@ -1451,7 +1451,7 @@ impl<T, S> IntoIterator for HashSet<T, S> { /// /// // Will print in an arbitrary order. /// for x in &v { - /// println!("{}", x); + /// println!("{x}"); /// } /// ``` #[inline] diff --git a/library/std/src/collections/hash/set/tests.rs b/library/std/src/collections/hash/set/tests.rs index 6a625e6243c..233db276b9e 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -301,10 +301,10 @@ fn test_show() { set.insert(1); set.insert(2); - let set_str = format!("{:?}", set); + let set_str = format!("{set:?}"); assert!(set_str == "{1, 2}" || set_str == "{2, 1}"); - assert_eq!(format!("{:?}", empty), "{}"); + assert_eq!(format!("{empty:?}"), "{}"); } #[test] diff --git a/library/std/src/collections/mod.rs b/library/std/src/collections/mod.rs index b5e81deb480..0caec8fe05a 100644 --- a/library/std/src/collections/mod.rs +++ b/library/std/src/collections/mod.rs @@ -199,7 +199,7 @@ //! ``` //! let vec = vec![1, 2, 3, 4]; //! for x in vec.iter() { -//! println!("vec contained {}", x); +//! println!("vec contained {x:?}"); //! } //! ``` //! @@ -246,7 +246,7 @@ //! ``` //! let vec = vec![1, 2, 3, 4]; //! for x in vec.iter().rev() { -//! println!("vec contained {}", x); +//! println!("vec contained {x:?}"); //! } //! ``` //! @@ -306,7 +306,7 @@ //! //! println!("Number of occurrences of each character"); //! for (char, count) in &count { -//! println!("{}: {}", char, count); +//! println!("{char}: {count}"); //! } //! ``` //! @@ -339,7 +339,7 @@ //! // Check if they're sober enough to have another beer. //! if person.blood_alcohol > 0.3 { //! // Too drunk... for now. -//! println!("Sorry {}, I have to cut you off", id); +//! println!("Sorry {id}, I have to cut you off"); //! } else { //! // Have another! //! person.blood_alcohol += 0.1; diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 5ed9fa9d6f0..05f08c498e6 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -118,7 +118,7 @@ pub struct VarsOs { /// // We will iterate through the references to the element returned by /// // env::vars(); /// for (key, value) in env::vars() { -/// println!("{}: {}", key, value); +/// println!("{key}: {value}"); /// } /// ``` /// @@ -148,7 +148,7 @@ pub fn vars() -> Vars { /// // We will iterate through the references to the element returned by /// // env::vars_os(); /// for (key, value) in env::vars_os() { -/// println!("{:?}: {:?}", key, value); +/// println!("{key:?}: {value:?}"); /// } /// ``` #[must_use] @@ -212,8 +212,8 @@ impl fmt::Debug for VarsOs { /// /// let key = "HOME"; /// match env::var(key) { -/// Ok(val) => println!("{}: {:?}", key, val), -/// Err(e) => println!("couldn't interpret {}: {}", key, e), +/// Ok(val) => println!("{key}: {val:?}"), +/// Err(e) => println!("couldn't interpret {key}: {e}"), /// } /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -252,8 +252,8 @@ fn _var(key: &OsStr) -> Result<String, VarError> { /// /// let key = "HOME"; /// match env::var_os(key) { -/// Some(val) => println!("{}: {:?}", key, val), -/// None => println!("{} is not defined in the environment.", key) +/// Some(val) => println!("{key}: {val:?}"), +/// None => println!("{key} is not defined in the environment.") /// } /// ``` #[must_use] @@ -343,7 +343,7 @@ pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) { fn _set_var(key: &OsStr, value: &OsStr) { os_imp::setenv(key, value).unwrap_or_else(|e| { - panic!("failed to set environment variable `{:?}` to `{:?}`: {}", key, value, e) + panic!("failed to set environment variable `{key:?}` to `{value:?}`: {e}") }) } @@ -385,7 +385,7 @@ pub fn remove_var<K: AsRef<OsStr>>(key: K) { fn _remove_var(key: &OsStr) { os_imp::unsetenv(key) - .unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", key, e)) + .unwrap_or_else(|e| panic!("failed to remove environment variable `{key:?}`: {e}")) } /// An iterator that splits an environment variable into paths according to @@ -421,7 +421,7 @@ pub struct SplitPaths<'a> { /// println!("'{}'", path.display()); /// } /// } -/// None => println!("{} is not defined in the environment.", key) +/// None => println!("{key} is not defined in the environment.") /// } /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -684,7 +684,7 @@ pub fn temp_dir() -> PathBuf { /// match env::current_exe() { /// Ok(exe_path) => println!("Path of this executable is: {}", /// exe_path.display()), -/// Err(e) => println!("failed to get current exe path: {}", e), +/// Err(e) => println!("failed to get current exe path: {e}"), /// }; /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -755,7 +755,7 @@ pub struct ArgsOs { /// /// // Prints each argument on a separate line /// for argument in env::args() { -/// println!("{}", argument); +/// println!("{argument}"); /// } /// ``` #[stable(feature = "env", since = "1.0.0")] @@ -790,7 +790,7 @@ pub fn args() -> Args { /// /// // Prints each argument on a separate line /// for argument in env::args_os() { -/// println!("{:?}", argument); +/// println!("{argument:?}"); /// } /// ``` #[stable(feature = "env", since = "1.0.0")] diff --git a/library/std/src/error.rs b/library/std/src/error.rs index 1a96b9c9282..c3cb71a5dee 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -96,7 +96,7 @@ pub trait Error: Debug + Display { /// fn main() { /// match get_super_error() { /// Err(e) => { - /// println!("Error: {}", e); + /// println!("Error: {e}"); /// println!("Caused by: {}", e.source().unwrap()); /// } /// _ => println!("No error"), @@ -139,7 +139,7 @@ pub trait Error: Debug + Display { /// ``` /// if let Err(e) = "xc".parse::<u32>() { /// // Print `e` itself, no need for description(). - /// eprintln!("Error: {}", e); + /// eprintln!("Error: {e}"); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -1074,7 +1074,7 @@ impl<E> Report<E> { /// /// let error = SuperError { source: SuperErrorSideKick }; /// let report = Report::new(error).pretty(true); - /// eprintln!("Error: {:?}", report); + /// eprintln!("Error: {report:?}"); /// ``` /// /// This example produces the following output: @@ -1135,7 +1135,7 @@ impl<E> Report<E> { /// let source = SuperErrorSideKick { source }; /// let error = SuperError { source }; /// let report = Report::new(error).pretty(true); - /// eprintln!("Error: {:?}", report); + /// eprintln!("Error: {report:?}"); /// ``` /// /// This example produces the following output: @@ -1210,7 +1210,7 @@ impl<E> Report<E> { /// let source = SuperErrorSideKick::new(); /// let error = SuperError { source }; /// let report = Report::new(error).pretty(true).show_backtrace(true); - /// eprintln!("Error: {:?}", report); + /// eprintln!("Error: {report:?}"); /// ``` /// /// This example produces something similar to the following output: @@ -1267,7 +1267,7 @@ where let sources = self.error.source().into_iter().flat_map(<dyn Error>::chain); for cause in sources { - write!(f, ": {}", cause)?; + write!(f, ": {cause}")?; } Ok(()) @@ -1278,7 +1278,7 @@ where fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let error = &self.error; - write!(f, "{}", error)?; + write!(f, "{error}")?; if let Some(cause) = error.source() { write!(f, "\n\nCaused by:")?; @@ -1289,9 +1289,9 @@ where writeln!(f)?; let mut indented = Indented { inner: f }; if multiple { - write!(indented, "{: >4}: {}", ind, error)?; + write!(indented, "{ind: >4}: {error}")?; } else { - write!(indented, " {}", error)?; + write!(indented, " {error}")?; } } } @@ -1333,7 +1333,7 @@ impl Report<Box<dyn Error>> { let sources = self.error.source().into_iter().flat_map(<dyn Error>::chain); for cause in sources { - write!(f, ": {}", cause)?; + write!(f, ": {cause}")?; } Ok(()) @@ -1344,7 +1344,7 @@ impl Report<Box<dyn Error>> { fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let error = &self.error; - write!(f, "{}", error)?; + write!(f, "{error}")?; if let Some(cause) = error.source() { write!(f, "\n\nCaused by:")?; @@ -1355,9 +1355,9 @@ impl Report<Box<dyn Error>> { writeln!(f)?; let mut indented = Indented { inner: f }; if multiple { - write!(indented, "{: >4}: {}", ind, error)?; + write!(indented, "{ind: >4}: {error}")?; } else { - write!(indented, " {}", error)?; + write!(indented, " {error}")?; } } } diff --git a/library/std/src/error/tests.rs b/library/std/src/error/tests.rs index eae5f43ff3c..a2a35d96ec9 100644 --- a/library/std/src/error/tests.rs +++ b/library/std/src/error/tests.rs @@ -130,7 +130,7 @@ Stack backtrace: error.backtrace = Some(trace); let report = Report::new(error).pretty(true).show_backtrace(true); - println!("Error: {}", report); + println!("Error: {report}"); assert_eq!(expected.trim_end(), report.to_string()); } @@ -155,7 +155,7 @@ Stack backtrace: let error = GenericError::new_with_source("Error with two sources", error); let report = Report::new(error).pretty(true).show_backtrace(true); - println!("Error: {}", report); + println!("Error: {report}"); assert_eq!(expected.trim_end(), report.to_string()); } @@ -355,7 +355,7 @@ Caused by: 1: The message goes on and on."; let actual = report.to_string(); - println!("{}", actual); + println!("{actual}"); assert_eq!(expected, actual); } diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index 1678367290e..b833d0e2ca5 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -1120,7 +1120,7 @@ impl fmt::Display for FromBytesWithNulError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.description())?; if let FromBytesWithNulErrorKind::InteriorNul(pos) = self.kind { - write!(f, " at byte pos {}", pos)?; + write!(f, " at byte pos {pos}")?; } Ok(()) } @@ -1134,7 +1134,7 @@ impl fmt::Display for FromVecWithNulError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.error_kind { FromBytesWithNulErrorKind::InteriorNul(pos) => { - write!(f, "data provided contains an interior nul byte at pos {}", pos) + write!(f, "data provided contains an interior nul byte at pos {pos}") } FromBytesWithNulErrorKind::NotNulTerminated => { write!(f, "data provided is not nul terminated") diff --git a/library/std/src/ffi/c_str/tests.rs b/library/std/src/ffi/c_str/tests.rs index 00ba5460821..8d603229315 100644 --- a/library/std/src/ffi/c_str/tests.rs +++ b/library/std/src/ffi/c_str/tests.rs @@ -35,7 +35,7 @@ fn build_with_zero2() { #[test] fn formatted() { let s = CString::new(&b"abc\x01\x02\n\xE2\x80\xA6\xFF"[..]).unwrap(); - assert_eq!(format!("{:?}", s), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#); + assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#); } #[test] diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0b65336a5a7..c99d9b279a9 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1123,7 +1123,7 @@ impl Metadata { /// let metadata = fs::metadata("foo.txt")?; /// /// if let Ok(time) = metadata.modified() { - /// println!("{:?}", time); + /// println!("{time:?}"); /// } else { /// println!("Not supported on this platform"); /// } @@ -1158,7 +1158,7 @@ impl Metadata { /// let metadata = fs::metadata("foo.txt")?; /// /// if let Ok(time) = metadata.accessed() { - /// println!("{:?}", time); + /// println!("{time:?}"); /// } else { /// println!("Not supported on this platform"); /// } @@ -1190,7 +1190,7 @@ impl Metadata { /// let metadata = fs::metadata("foo.txt")?; /// /// if let Ok(time) = metadata.created() { - /// println!("{:?}", time); + /// println!("{time:?}"); /// } else { /// println!("Not supported on this platform or filesystem"); /// } diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 16b8bf68242..88d87fc532e 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -30,7 +30,7 @@ macro_rules! check { ($e:expr) => { match $e { Ok(t) => t, - Err(e) => panic!("{} failed with: {}", stringify!($e), e), + Err(e) => panic!("{} failed with: {e}", stringify!($e)), } }; } @@ -470,7 +470,7 @@ fn file_test_directoryinfo_readdir() { check!(fs::create_dir(dir)); let prefix = "foo"; for n in 0..3 { - let f = dir.join(&format!("{}.txt", n)); + let f = dir.join(&format!("{n}.txt")); let mut w = check!(File::create(&f)); let msg_str = format!("{}{}", prefix, n.to_string()); let msg = msg_str.as_bytes(); @@ -1329,7 +1329,7 @@ fn dir_entry_methods() { assert!(file.file_type().unwrap().is_file()); assert!(file.metadata().unwrap().is_file()); } - f => panic!("unknown file name: {:?}", f), + f => panic!("unknown file name: {f:?}"), } } } @@ -1340,7 +1340,7 @@ fn dir_entry_debug() { File::create(&tmpdir.join("b")).unwrap(); let mut read_dir = tmpdir.path().read_dir().unwrap(); let dir_entry = read_dir.next().unwrap().unwrap(); - let actual = format!("{:?}", dir_entry); + let actual = format!("{dir_entry:?}"); let expected = format!("DirEntry({:?})", dir_entry.0.path()); assert_eq!(actual, expected); } @@ -1409,7 +1409,7 @@ fn metadata_access_times() { || e1.kind() == ErrorKind::Unsupported && e2.kind() == ErrorKind::Unsupported => {} (a, b) => { - panic!("creation time must be always supported or not supported: {:?} {:?}", a, b,) + panic!("creation time must be always supported or not supported: {a:?} {b:?}") } } } diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index e7eee443624..989cec976b7 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -41,7 +41,7 @@ use crate::mem::MaybeUninit; /// /// let mut line = String::new(); /// let len = reader.read_line(&mut line)?; -/// println!("First line is {} bytes long", len); +/// println!("First line is {len} bytes long"); /// Ok(()) /// } /// ``` diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 17e2b97545a..4a50e647c64 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -457,7 +457,7 @@ impl From<ErrorKind> for Error { /// /// let not_found = ErrorKind::NotFound; /// let error = Error::from(not_found); - /// assert_eq!("entity not found", format!("{}", error)); + /// assert_eq!("entity not found", format!("{error}")); /// ``` #[inline] fn from(kind: ErrorKind) -> Error { @@ -561,7 +561,7 @@ impl Error { /// use std::io::Error; /// /// let os_error = Error::last_os_error(); - /// println!("last OS error: {:?}", os_error); + /// println!("last OS error: {os_error:?}"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[must_use] @@ -618,7 +618,7 @@ impl Error { /// /// fn print_os_error(err: &Error) { /// if let Some(raw_os_err) = err.raw_os_error() { - /// println!("raw OS error: {:?}", raw_os_err); + /// println!("raw OS error: {raw_os_err:?}"); /// } else { /// println!("Not an OS error"); /// } @@ -657,7 +657,7 @@ impl Error { /// /// fn print_error(err: &Error) { /// if let Some(inner_err) = err.get_ref() { - /// println!("Inner error: {:?}", inner_err); + /// println!("Inner error: {inner_err:?}"); /// } else { /// println!("No inner error"); /// } @@ -731,7 +731,7 @@ impl Error { /// /// fn print_error(err: &Error) { /// if let Some(inner_err) = err.get_ref() { - /// println!("Inner error: {}", inner_err); + /// println!("Inner error: {inner_err}"); /// } else { /// println!("No inner error"); /// } @@ -770,7 +770,7 @@ impl Error { /// /// fn print_error(err: Error) { /// if let Some(inner_err) = err.into_inner() { - /// println!("Inner error: {}", inner_err); + /// println!("Inner error: {inner_err}"); /// } else { /// println!("No inner error"); /// } @@ -852,7 +852,7 @@ impl fmt::Display for Error { match self.repr.data() { ErrorData::Os(code) => { let detail = sys::os::error_string(code); - write!(fmt, "{} (os error {})", detail, code) + write!(fmt, "{detail} (os error {code})") } ErrorData::Custom(ref c) => c.error.fmt(fmt), ErrorData::Simple(kind) => write!(fmt, "{}", kind.as_str()), diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index 4301e941b3d..1a0538f861a 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -161,8 +161,7 @@ impl Repr { // only run in libstd's tests, unless the user uses -Zbuild-std) debug_assert!( matches!(res.data(), ErrorData::Os(c) if c == code), - "repr(os) encoding failed for {}", - code, + "repr(os) encoding failed for {code}" ); res } diff --git a/library/std/src/io/error/tests.rs b/library/std/src/io/error/tests.rs index c2c51553b20..6fd15fa8048 100644 --- a/library/std/src/io/error/tests.rs +++ b/library/std/src/io/error/tests.rs @@ -33,7 +33,7 @@ fn test_debug_error() { }}", code, kind, msg ); - assert_eq!(format!("{:?}", err), expected); + assert_eq!(format!("{err:?}"), expected); } #[test] @@ -65,8 +65,8 @@ fn test_const() { assert_eq!(E.kind(), ErrorKind::NotFound); assert_eq!(E.to_string(), "hello"); - assert!(format!("{:?}", E).contains("\"hello\"")); - assert!(format!("{:?}", E).contains("NotFound")); + assert!(format!("{E:?}").contains("\"hello\"")); + assert!(format!("{E:?}").contains("NotFound")); } #[test] @@ -101,7 +101,7 @@ fn test_simple_message_packing() { let e = &$err; // Check that the public api is right. assert_eq!(e.kind(), $kind); - assert!(format!("{:?}", e).contains($msg)); + assert!(format!("{e:?}").contains($msg)); // and we got what we expected assert_matches!( e.repr.data(), diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 3fa965d08e6..6005270a75f 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -91,7 +91,7 @@ //! // read a line into buffer //! reader.read_line(&mut buffer)?; //! -//! println!("{}", buffer); +//! println!("{buffer}"); //! Ok(()) //! } //! ``` @@ -1035,7 +1035,7 @@ pub trait Read { /// fn main() -> io::Result<()> { /// let stdin = io::read_to_string(io::stdin())?; /// println!("Stdin was:"); -/// println!("{}", stdin); +/// println!("{stdin}"); /// Ok(()) /// } /// ``` @@ -1761,7 +1761,7 @@ pub trait Seek { /// .open("foo.txt").unwrap(); /// /// let hello = "Hello!\n"; - /// write!(f, "{}", hello).unwrap(); + /// write!(f, "{hello}").unwrap(); /// f.rewind().unwrap(); /// /// let mut buf = String::new(); @@ -1804,7 +1804,7 @@ pub trait Seek { /// let mut f = File::open("foo.txt")?; /// /// let len = f.stream_len()?; - /// println!("The file is currently {} bytes long", len); + /// println!("The file is currently {len} bytes long"); /// Ok(()) /// } /// ``` @@ -1988,7 +1988,7 @@ pub trait BufRead: Read { /// let buffer = stdin.fill_buf().unwrap(); /// /// // work with buffer - /// println!("{:?}", buffer); + /// println!("{buffer:?}"); /// /// // ensure the bytes we worked with aren't returned again later /// let length = buffer.len(); @@ -2042,7 +2042,7 @@ pub trait BufRead: Read { /// let mut line = String::new(); /// stdin.read_line(&mut line).unwrap(); /// // work with line - /// println!("{:?}", line); + /// println!("{line:?}"); /// } /// ``` #[unstable(feature = "buf_read_has_data_left", reason = "recently added", issue = "86423")] diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 5414ff648d4..50344e602a9 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -349,10 +349,10 @@ impl Stdin { /// let mut input = String::new(); /// match io::stdin().read_line(&mut input) { /// Ok(n) => { - /// println!("{} bytes read", n); - /// println!("{}", input); + /// println!("{n} bytes read"); + /// println!("{input}"); /// } - /// Err(error) => println!("error: {}", error), + /// Err(error) => println!("error: {error}"), /// } /// ``` /// @@ -953,7 +953,7 @@ where } if let Err(e) = global_s().write_fmt(args) { - panic!("failed printing to {}: {}", label, e); + panic!("failed printing to {label}: {e}"); } } diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 5b76259afc1..542b793f6da 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -64,7 +64,7 @@ mod as_keyword {} /// } /// /// assert_eq!(last, 12); -/// println!("{}", last); +/// println!("{last}"); /// ``` /// /// A break expression is normally associated with the innermost loop enclosing the @@ -72,10 +72,10 @@ mod as_keyword {} /// ///```rust /// 'outer: for i in 1..=5 { -/// println!("outer iteration (i): {}", i); +/// println!("outer iteration (i): {i}"); /// /// '_inner: for j in 1..=200 { -/// println!(" inner iteration (j): {}", j); +/// println!(" inner iteration (j): {j}"); /// if j >= 3 { /// // breaks from inner loop, lets outer loop continue. /// break; @@ -106,7 +106,7 @@ mod as_keyword {} /// }; /// // first number in Fibonacci sequence over 10: /// assert_eq!(result, 13); -/// println!("{}", result); +/// println!("{result}"); /// ``` /// /// For more details consult the [Reference on "break expression"] and the [Reference on "break and @@ -200,7 +200,7 @@ mod const_keyword {} /// if number % 2 == 0 { /// continue; /// } -/// println!("{}", number); +/// println!("{number}"); /// } ///``` /// @@ -515,7 +515,7 @@ mod fn_keyword {} /// } /// /// for i in std::iter::repeat(5) { -/// println!("turns out {} never stops being 5", i); +/// println!("turns out {i} never stops being 5"); /// break; // would loop forever otherwise /// } /// @@ -776,7 +776,7 @@ mod in_keyword {} /// let shadowing_example = true; /// let shadowing_example = 123.4; /// let shadowing_example = shadowing_example as u32; -/// let mut shadowing_example = format!("cool! {}", shadowing_example); +/// let mut shadowing_example = format!("cool! {shadowing_example}"); /// shadowing_example += " something else!"; // not shadowing /// ``` /// @@ -805,7 +805,7 @@ mod let_keyword {} /// let mut counter = 0; /// /// while counter < 10 { -/// println!("{}", counter); +/// println!("{counter}"); /// counter += 1; /// } /// ``` @@ -836,7 +836,7 @@ mod let_keyword {} /// if i == 10 { /// counter = None; /// } else { -/// println!("{}", i); +/// println!("{i}"); /// counter = Some (i + 1); /// } /// } @@ -866,7 +866,7 @@ mod while_keyword {} /// /// let mut i = 1; /// loop { -/// println!("i is {}", i); +/// println!("i is {i}"); /// if i > 100 { /// break; /// } @@ -920,8 +920,8 @@ mod loop_keyword {} /// /// let a_number = Option::Some(10); /// match a_number { -/// Some(x) if x <= 5 => println!("0 to 5 num = {}", x), -/// Some(x @ 6..=10) => println!("6 to 10 num = {}", x), +/// Some(x) if x <= 5 => println!("0 to 5 num = {x}"), +/// Some(x @ 6..=10) => println!("6 to 10 num = {x}"), /// None => panic!(), /// // all other numbers /// _ => panic!(), @@ -940,8 +940,8 @@ mod loop_keyword {} /// /// let get_inner = Outer::Double(None, Some(String::new())); /// match get_inner { -/// Outer::Double(None, Some(st)) => println!("{}", st), -/// Outer::Single(opt) => println!("{:?}", opt), +/// Outer::Double(None, Some(st)) => println!("{st}"), +/// Outer::Single(opt) => println!("{opt:?}"), /// _ => panic!(), /// } /// ``` @@ -988,7 +988,7 @@ mod mod_keyword {} /// /// ```rust /// let data = vec![1, 2, 3]; -/// let closure = move || println!("captured {:?} by value", data); +/// let closure = move || println!("captured {data:?} by value"); /// /// // data is no longer available, it is owned by the closure /// ``` @@ -1001,7 +1001,7 @@ mod mod_keyword {} /// ```rust /// fn create_fn() -> impl Fn() { /// let text = "Fn".to_owned(); -/// move || println!("This is a: {}", text) +/// move || println!("This is a: {text}") /// } /// /// let fn_plain = create_fn(); @@ -1014,7 +1014,7 @@ mod mod_keyword {} /// let data = vec![1, 2, 3]; /// /// std::thread::spawn(move || { -/// println!("captured {:?} by value", data) +/// println!("captured {data:?} by value") /// }).join().unwrap(); /// /// // data was moved to the spawned thread, so we cannot use it here @@ -1025,7 +1025,7 @@ mod mod_keyword {} /// ```rust /// let capture = "hello".to_owned(); /// let block = async move { -/// println!("rust says {} from async block", capture); +/// println!("rust says {capture} from async block"); /// }; /// ``` /// @@ -1124,7 +1124,7 @@ mod pub_keyword {} /// let maybe_name = Some(String::from("Alice")); /// // The variable 'maybe_name' is consumed here ... /// match maybe_name { -/// Some(n) => println!("Hello, {}", n), +/// Some(n) => println!("Hello, {n}"), /// _ => println!("Hello, world"), /// } /// // ... and is now unavailable. @@ -1138,7 +1138,7 @@ mod pub_keyword {} /// let maybe_name = Some(String::from("Alice")); /// // Using `ref`, the value is borrowed, not moved ... /// match maybe_name { -/// Some(ref n) => println!("Hello, {}", n), +/// Some(ref n) => println!("Hello, {n}"), /// _ => println!("Hello, world"), /// } /// // ... so it's available here! @@ -1423,7 +1423,7 @@ mod self_upper_keyword {} /// // With a strictly read-only static, references will have the same address /// assert_eq!(r1, r2); /// // A static item can be used just like a variable in many cases -/// println!("{:?}", FOO); +/// println!("{FOO:?}"); /// ``` /// /// # Mutable `static`s @@ -1675,7 +1675,7 @@ mod super_keyword {} /// # #![allow(dead_code)] /// fn debug_iter<I: Iterator>(it: I) where I::Item: std::fmt::Debug { /// for elem in it { -/// println!("{:#?}", elem); +/// println!("{elem:#?}"); /// } /// } /// @@ -2313,7 +2313,7 @@ mod dyn_keyword {} /// match u { /// IntOrFloat { i: 10 } => println!("Found exactly ten!"), /// // Matching the field `f` provides an `f32`. -/// IntOrFloat { f } => println!("Found f = {} !", f), +/// IntOrFloat { f } => println!("Found f = {f} !"), /// } /// } /// ``` @@ -2337,7 +2337,7 @@ mod dyn_keyword {} /// let i = unsafe { &mut u.i }; /// /// *i = 10; -/// println!("f = {} and i = {}", f, i); +/// println!("f = {f} and i = {i}"); /// ``` /// /// See the [Reference][union] for more informations on `union`s. diff --git a/library/std/src/net/addr/tests.rs b/library/std/src/net/addr/tests.rs index 40f5a84bcd5..585a17451a0 100644 --- a/library/std/src/net/addr/tests.rs +++ b/library/std/src/net/addr/tests.rs @@ -169,30 +169,30 @@ fn is_v6() { fn socket_v4_to_str() { let socket = SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 8080); - assert_eq!(format!("{}", socket), "192.168.0.1:8080"); - assert_eq!(format!("{:<20}", socket), "192.168.0.1:8080 "); - assert_eq!(format!("{:>20}", socket), " 192.168.0.1:8080"); - assert_eq!(format!("{:^20}", socket), " 192.168.0.1:8080 "); - assert_eq!(format!("{:.10}", socket), "192.168.0."); + assert_eq!(format!("{socket}"), "192.168.0.1:8080"); + assert_eq!(format!("{socket:<20}"), "192.168.0.1:8080 "); + assert_eq!(format!("{socket:>20}"), " 192.168.0.1:8080"); + assert_eq!(format!("{socket:^20}"), " 192.168.0.1:8080 "); + assert_eq!(format!("{socket:.10}"), "192.168.0."); } #[test] fn socket_v6_to_str() { let mut socket = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53, 0, 0); - assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1]:53"); - assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1]:53 "); - assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1]:53"); - assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1]:53 "); - assert_eq!(format!("{:.15}", socket), "[2a02:6b8:0:1::"); + assert_eq!(format!("{socket}"), "[2a02:6b8:0:1::1]:53"); + assert_eq!(format!("{socket:<24}"), "[2a02:6b8:0:1::1]:53 "); + assert_eq!(format!("{socket:>24}"), " [2a02:6b8:0:1::1]:53"); + assert_eq!(format!("{socket:^24}"), " [2a02:6b8:0:1::1]:53 "); + assert_eq!(format!("{socket:.15}"), "[2a02:6b8:0:1::"); socket.set_scope_id(5); - assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1%5]:53"); - assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1%5]:53 "); - assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1%5]:53"); - assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1%5]:53 "); - assert_eq!(format!("{:.18}", socket), "[2a02:6b8:0:1::1%5"); + assert_eq!(format!("{socket}"), "[2a02:6b8:0:1::1%5]:53"); + assert_eq!(format!("{socket:<24}"), "[2a02:6b8:0:1::1%5]:53 "); + assert_eq!(format!("{socket:>24}"), " [2a02:6b8:0:1::1%5]:53"); + assert_eq!(format!("{socket:^24}"), " [2a02:6b8:0:1::1%5]:53 "); + assert_eq!(format!("{socket:.18}"), "[2a02:6b8:0:1::1%5"); } #[test] diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index cc4e4fd4fdc..f5d3c4905e0 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -595,10 +595,10 @@ impl TcpStream { /// // via platform-specific APIs such as epoll or IOCP /// wait_for_fd(); /// } - /// Err(e) => panic!("encountered IO error: {}", e), + /// Err(e) => panic!("encountered IO error: {e}"), /// }; /// }; - /// println!("bytes: {:?}", buf); + /// println!("bytes: {buf:?}"); /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { @@ -799,8 +799,8 @@ impl TcpListener { /// /// let listener = TcpListener::bind("127.0.0.1:8080").unwrap(); /// match listener.accept() { - /// Ok((_socket, addr)) => println!("new client: {:?}", addr), - /// Err(e) => println!("couldn't get client: {:?}", e), + /// Ok((_socket, addr)) => println!("new client: {addr:?}"), + /// Err(e) => println!("couldn't get client: {e:?}"), /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -991,7 +991,7 @@ impl TcpListener { /// wait_for_fd(); /// continue; /// } - /// Err(e) => panic!("encountered IO error: {}", e), + /// Err(e) => panic!("encountered IO error: {e}"), /// } /// } /// ``` diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index 4d5cf658def..8c0adcfb0eb 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -142,8 +142,7 @@ fn write_close() { e.kind() == ErrorKind::ConnectionReset || e.kind() == ErrorKind::BrokenPipe || e.kind() == ErrorKind::ConnectionAborted, - "unknown error: {}", - e + "unknown error: {e}" ); } } @@ -655,7 +654,7 @@ fn debug() { inner_name, render_inner(&listener) ); - assert_eq!(format!("{:?}", listener), compare); + assert_eq!(format!("{listener:?}"), compare); let stream = t!(TcpStream::connect(&("localhost", socket_addr.port()))); let compare = format!( @@ -665,7 +664,7 @@ fn debug() { inner_name, render_inner(&stream) ); - assert_eq!(format!("{:?}", stream), compare); + assert_eq!(format!("{stream:?}"), compare); } // FIXME: re-enabled openbsd tests once their socket timeout code @@ -832,7 +831,7 @@ fn set_nonblocking() { match stream.read(&mut buf) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), } } @@ -862,7 +861,7 @@ fn peek() { match c.peek(&mut b) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), } t!(txdone.send(())); }) diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 11a696e92c8..864e1b0f345 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -605,9 +605,9 @@ impl UdpSocket { /// /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); /// match socket.take_error() { - /// Ok(Some(error)) => println!("UdpSocket error: {:?}", error), + /// Ok(Some(error)) => println!("UdpSocket error: {error:?}"), /// Ok(None) => println!("No error"), - /// Err(error) => println!("UdpSocket.take_error failed: {:?}", error), + /// Err(error) => println!("UdpSocket.take_error failed: {error:?}"), /// } /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] @@ -686,8 +686,8 @@ impl UdpSocket { /// socket.connect("127.0.0.1:8080").expect("connect function failed"); /// let mut buf = [0; 10]; /// match socket.recv(&mut buf) { - /// Ok(received) => println!("received {} bytes {:?}", received, &buf[..received]), - /// Err(e) => println!("recv function failed: {:?}", e), + /// Ok(received) => println!("received {received} bytes {:?}", &buf[..received]), + /// Err(e) => println!("recv function failed: {e:?}"), /// } /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] @@ -726,8 +726,8 @@ impl UdpSocket { /// socket.connect("127.0.0.1:8080").expect("connect function failed"); /// let mut buf = [0; 10]; /// match socket.peek(&mut buf) { - /// Ok(received) => println!("received {} bytes", received), - /// Err(e) => println!("peek function failed: {:?}", e), + /// Ok(received) => println!("received {received} bytes"), + /// Err(e) => println!("peek function failed: {e:?}"), /// } /// ``` #[stable(feature = "peek", since = "1.18.0")] @@ -770,7 +770,7 @@ impl UdpSocket { /// // via platform-specific APIs such as epoll or IOCP /// wait_for_fd(); /// } - /// Err(e) => panic!("encountered IO error: {}", e), + /// Err(e) => panic!("encountered IO error: {e}"), /// } /// }; /// println!("bytes: {:?}", &buf[..num_bytes_read]); diff --git a/library/std/src/net/udp/tests.rs b/library/std/src/net/udp/tests.rs index a51113dd9e7..f82904ffbbf 100644 --- a/library/std/src/net/udp/tests.rs +++ b/library/std/src/net/udp/tests.rs @@ -173,8 +173,8 @@ fn debug() { let udpsock = t!(UdpSocket::bind(&socket_addr)); let udpsock_inner = udpsock.0.socket().as_raw(); - let compare = format!("UdpSocket {{ addr: {:?}, {}: {:?} }}", socket_addr, name, udpsock_inner); - assert_eq!(format!("{:?}", udpsock), compare); + let compare = format!("UdpSocket {{ addr: {socket_addr:?}, {name}: {udpsock_inner:?} }}"); + assert_eq!(format!("{udpsock:?}"), compare); } // FIXME: re-enabled openbsd/netbsd tests once their socket timeout code @@ -359,7 +359,7 @@ fn set_nonblocking() { match socket.recv(&mut buf) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), } }) } diff --git a/library/std/src/os/unix/fs.rs b/library/std/src/os/unix/fs.rs index 75d65e6d5fc..3fc6cc44ce4 100644 --- a/library/std/src/os/unix/fs.rs +++ b/library/std/src/os/unix/fs.rs @@ -47,7 +47,7 @@ pub trait FileExt { /// /// // We now read 8 bytes from the offset 10. /// let num_bytes_read = file.read_at(&mut buf, 10)?; - /// println!("read {} bytes: {:?}", num_bytes_read, buf); + /// println!("read {num_bytes_read} bytes: {buf:?}"); /// Ok(()) /// } /// ``` @@ -861,7 +861,7 @@ pub trait DirEntryExt2: Sealed { /// entries.sort_unstable_by(|a, b| a.file_name_ref().cmp(b.file_name_ref())); /// /// for p in entries { - /// println!("{:?}", p); + /// println!("{p:?}"); /// } /// /// Ok(()) diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index 034fa301ba1..ba65d8f285e 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -86,7 +86,7 @@ impl<'a> fmt::Display for AsciiEscaped<'a> { /// let socket = match UnixListener::bind("/tmp/sock") { /// Ok(sock) => sock, /// Err(e) => { -/// println!("Couldn't bind: {:?}", e); +/// println!("Couldn't bind: {e:?}"); /// return /// } /// }; @@ -307,7 +307,7 @@ impl SocketAddr { /// let listener = match UnixListener::bind_addr(&addr) { /// Ok(sock) => sock, /// Err(err) => { - /// println!("Couldn't bind: {:?}", err); + /// println!("Couldn't bind: {err:?}"); /// return Err(err); /// } /// }; @@ -346,7 +346,7 @@ impl fmt::Debug for SocketAddr { match self.address() { AddressKind::Unnamed => write!(fmt, "(unnamed)"), AddressKind::Abstract(name) => write!(fmt, "{} (abstract)", AsciiEscaped(name)), - AddressKind::Pathname(path) => write!(fmt, "{:?} (pathname)", path), + AddressKind::Pathname(path) => write!(fmt, "{path:?} (pathname)"), } } } diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index 6e6f5212b46..fb1ff4b725c 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -396,7 +396,7 @@ impl<'a> Iterator for Messages<'a> { /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { -/// println!("receive file descriptor: {}", fd); +/// println!("receive file descriptor: {fd}"); /// } /// } /// } @@ -568,7 +568,7 @@ impl<'a> SocketAncillary<'a> { /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {}", fd); + /// println!("receive file descriptor: {fd}"); /// } /// } /// } @@ -579,7 +579,7 @@ impl<'a> SocketAncillary<'a> { /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {}", fd); + /// println!("receive file descriptor: {fd}"); /// } /// } /// } diff --git a/library/std/src/os/unix/net/datagram.rs b/library/std/src/os/unix/net/datagram.rs index a2caccc7849..59c91e9a82e 100644 --- a/library/std/src/os/unix/net/datagram.rs +++ b/library/std/src/os/unix/net/datagram.rs @@ -95,7 +95,7 @@ impl UnixDatagram { /// let sock = match UnixDatagram::bind("/path/to/the/socket") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't bind: {:?}", e); + /// println!("Couldn't bind: {e:?}"); /// return /// } /// }; @@ -127,7 +127,7 @@ impl UnixDatagram { /// let sock2 = match UnixDatagram::bind_addr(&addr) { /// Ok(sock) => sock, /// Err(err) => { - /// println!("Couldn't bind: {:?}", err); + /// println!("Couldn't bind: {err:?}"); /// return Err(err); /// } /// }; @@ -157,7 +157,7 @@ impl UnixDatagram { /// let sock = match UnixDatagram::unbound() { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't unbound: {:?}", e); + /// println!("Couldn't unbound: {e:?}"); /// return /// } /// }; @@ -180,7 +180,7 @@ impl UnixDatagram { /// let (sock1, sock2) = match UnixDatagram::pair() { /// Ok((sock1, sock2)) => (sock1, sock2), /// Err(e) => { - /// println!("Couldn't unbound: {:?}", e); + /// println!("Couldn't unbound: {e:?}"); /// return /// } /// }; @@ -210,7 +210,7 @@ impl UnixDatagram { /// match sock.connect("/path/to/the/socket") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {:?}", e); + /// println!("Couldn't connect: {e:?}"); /// return Err(e) /// } /// }; @@ -243,7 +243,7 @@ impl UnixDatagram { /// match sock.connect_addr(&addr) { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {:?}", e); + /// println!("Couldn't connect: {e:?}"); /// return Err(e) /// } /// }; @@ -367,7 +367,7 @@ impl UnixDatagram { /// let sock = UnixDatagram::unbound()?; /// let mut buf = vec![0; 10]; /// let (size, sender) = sock.recv_from(buf.as_mut_slice())?; - /// println!("received {} bytes from {:?}", size, sender); + /// println!("received {size} bytes from {sender:?}"); /// Ok(()) /// } /// ``` @@ -422,11 +422,11 @@ impl UnixDatagram { /// let mut ancillary_buffer = [0; 128]; /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// let (size, _truncated, sender) = sock.recv_vectored_with_ancillary_from(bufs, &mut ancillary)?; - /// println!("received {}", size); + /// println!("received {size}"); /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {}", fd); + /// println!("receive file descriptor: {fd}"); /// } /// } /// } @@ -479,11 +479,11 @@ impl UnixDatagram { /// let mut ancillary_buffer = [0; 128]; /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// let (size, _truncated) = sock.recv_vectored_with_ancillary(bufs, &mut ancillary)?; - /// println!("received {}", size); + /// println!("received {size}"); /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {}", fd); + /// println!("receive file descriptor: {fd}"); /// } /// } /// } @@ -893,7 +893,7 @@ impl UnixDatagram { /// fn main() -> std::io::Result<()> { /// let sock = UnixDatagram::unbound()?; /// if let Ok(Some(err)) = sock.take_error() { - /// println!("Got error: {:?}", err); + /// println!("Got error: {err:?}"); /// } /// Ok(()) /// } diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs index b23dd6062f6..8e11d32f130 100644 --- a/library/std/src/os/unix/net/listener.rs +++ b/library/std/src/os/unix/net/listener.rs @@ -63,7 +63,7 @@ impl UnixListener { /// let listener = match UnixListener::bind("/path/to/the/socket") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {:?}", e); + /// println!("Couldn't connect: {e:?}"); /// return /// } /// }; @@ -98,7 +98,7 @@ impl UnixListener { /// let listener2 = match UnixListener::bind_addr(&addr) { /// Ok(sock) => sock, /// Err(err) => { - /// println!("Couldn't bind: {:?}", err); + /// println!("Couldn't bind: {err:?}"); /// return Err(err); /// } /// }; @@ -136,8 +136,8 @@ impl UnixListener { /// let listener = UnixListener::bind("/path/to/the/socket")?; /// /// match listener.accept() { - /// Ok((socket, addr)) => println!("Got a client: {:?}", addr), - /// Err(e) => println!("accept function failed: {:?}", e), + /// Ok((socket, addr)) => println!("Got a client: {addr:?}"), + /// Err(e) => println!("accept function failed: {e:?}"), /// } /// Ok(()) /// } @@ -226,7 +226,7 @@ impl UnixListener { /// let listener = UnixListener::bind("/tmp/sock")?; /// /// if let Ok(Some(err)) = listener.take_error() { - /// println!("Got error: {:?}", err); + /// println!("Got error: {err:?}"); /// } /// Ok(()) /// } diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index 583f861a925..3943b4fed09 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -57,7 +57,7 @@ pub use ucred::UCred; /// stream.write_all(b"hello world")?; /// let mut response = String::new(); /// stream.read_to_string(&mut response)?; -/// println!("{}", response); +/// println!("{response}"); /// Ok(()) /// } /// ``` @@ -90,7 +90,7 @@ impl UnixStream { /// let socket = match UnixStream::connect("/tmp/sock") { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {:?}", e); + /// println!("Couldn't connect: {e:?}"); /// return /// } /// }; @@ -123,7 +123,7 @@ impl UnixStream { /// let sock = match UnixStream::connect_addr(&addr) { /// Ok(sock) => sock, /// Err(e) => { - /// println!("Couldn't connect: {:?}", e); + /// println!("Couldn't connect: {e:?}"); /// return Err(e) /// } /// }; @@ -155,7 +155,7 @@ impl UnixStream { /// let (sock1, sock2) = match UnixStream::pair() { /// Ok((sock1, sock2)) => (sock1, sock2), /// Err(e) => { - /// println!("Couldn't create a pair of sockets: {:?}", e); + /// println!("Couldn't create a pair of sockets: {e:?}"); /// return /// } /// }; @@ -443,7 +443,7 @@ impl UnixStream { /// fn main() -> std::io::Result<()> { /// let socket = UnixStream::connect("/tmp/sock")?; /// if let Ok(Some(err)) = socket.take_error() { - /// println!("Got error: {:?}", err); + /// println!("Got error: {err:?}"); /// } /// Ok(()) /// } @@ -530,11 +530,11 @@ impl UnixStream { /// let mut ancillary_buffer = [0; 128]; /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// let size = socket.recv_vectored_with_ancillary(bufs, &mut ancillary)?; - /// println!("received {}", size); + /// println!("received {size}"); /// for ancillary_result in ancillary.messages() { /// if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { /// for fd in scm_rights { - /// println!("receive file descriptor: {}", fd); + /// println!("receive file descriptor: {fd}"); /// } /// } /// } diff --git a/library/std/src/os/unix/net/tests.rs b/library/std/src/os/unix/net/tests.rs index 7ad4a02611e..aa0df61c192 100644 --- a/library/std/src/os/unix/net/tests.rs +++ b/library/std/src/os/unix/net/tests.rs @@ -29,7 +29,7 @@ macro_rules! or_panic { ($e:expr) => { match $e { Ok(e) => e, - Err(e) => panic!("{}", e), + Err(e) => panic!("{e}"), } }; } @@ -161,19 +161,19 @@ fn long_path() { ); match UnixStream::connect(&socket_path) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), Ok(_) => panic!("unexpected success"), } match UnixListener::bind(&socket_path) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), Ok(_) => panic!("unexpected success"), } match UnixDatagram::bind(&socket_path) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), Ok(_) => panic!("unexpected success"), } } @@ -524,7 +524,7 @@ fn test_abstract_namespace_too_long() { jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", ) { Err(ref e) if e.kind() == io::ErrorKind::InvalidInput => {} - Err(e) => panic!("unexpected error {}", e), + Err(e) => panic!("unexpected error {e}"), Ok(_) => panic!("unexpected success"), } } @@ -564,7 +564,7 @@ fn test_unix_stream_peek() { match stream.peek(&mut buf) { Ok(_) => panic!("expected error"), Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} - Err(e) => panic!("unexpected error: {}", e), + Err(e) => panic!("unexpected error: {e}"), } or_panic!(txdone.send(())); diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 2b9ae3210de..03de7eed6d4 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -283,7 +283,7 @@ fn default_hook(info: &PanicInfo<'_>) { let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>"); let write = |err: &mut dyn crate::io::Write| { - let _ = writeln!(err, "thread '{}' panicked at '{}', {}", name, msg, location); + let _ = writeln!(err, "thread '{name}' panicked at '{msg}', {location}"); static FIRST_PANIC: AtomicBool = AtomicBool::new(true); @@ -677,7 +677,7 @@ fn rust_panic_with_hook( // Unfortunately, this does not print a backtrace, because creating // a `Backtrace` will allocate, which we must to avoid here. let panicinfo = PanicInfo::internal_constructor(message, location, can_unwind); - rtprintpanic!("{}\npanicked after panic::always_abort(), aborting.\n", panicinfo); + rtprintpanic!("{panicinfo}\npanicked after panic::always_abort(), aborting.\n"); } crate::sys::abort_internal(); } @@ -745,5 +745,5 @@ fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! { let obj = &mut msg as *mut &mut dyn BoxMeUp; __rust_start_panic(obj) }; - rtabort!("failed to initiate panic, error {}", code) + rtabort!("failed to initiate panic, error {code}") } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index e544608f83c..bcf5c9328b7 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -592,7 +592,7 @@ impl AsRef<Path> for Component<'_> { /// let path = Path::new("/tmp/foo/bar.txt"); /// /// for component in path.components() { -/// println!("{:?}", component); +/// println!("{component:?}"); /// } /// ``` /// diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs index 6e863787b7f..c8dc768d3fc 100644 --- a/library/std/src/path/tests.rs +++ b/library/std/src/path/tests.rs @@ -1586,17 +1586,17 @@ fn test_components_debug() { let mut components = path.components(); let expected = "Components([RootDir, Normal(\"tmp\")])"; - let actual = format!("{:?}", components); + let actual = format!("{components:?}"); assert_eq!(expected, actual); let _ = components.next().unwrap(); let expected = "Components([Normal(\"tmp\")])"; - let actual = format!("{:?}", components); + let actual = format!("{components:?}"); assert_eq!(expected, actual); let _ = components.next().unwrap(); let expected = "Components([])"; - let actual = format!("{:?}", components); + let actual = format!("{components:?}"); assert_eq!(expected, actual); } @@ -1608,17 +1608,17 @@ fn test_iter_debug() { let mut iter = path.iter(); let expected = "Iter([\"/\", \"tmp\"])"; - let actual = format!("{:?}", iter); + let actual = format!("{iter:?}"); assert_eq!(expected, actual); let _ = iter.next().unwrap(); let expected = "Iter([\"tmp\"])"; - let actual = format!("{:?}", iter); + let actual = format!("{iter:?}"); assert_eq!(expected, actual); let _ = iter.next().unwrap(); let expected = "Iter([])"; - let actual = format!("{:?}", iter); + let actual = format!("{iter:?}"); assert_eq!(expected, actual); } @@ -1770,7 +1770,7 @@ fn test_windows_absolute() { fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { let prefix = "my/home"; let mut paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); paths.sort(); @@ -1783,7 +1783,7 @@ fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); let mut set = BTreeSet::new(); @@ -1801,7 +1801,7 @@ fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { let prefix = "my/home"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); let mut set = BTreeSet::new(); @@ -1819,7 +1819,7 @@ fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { fn bench_path_hashset(b: &mut test::Bencher) { let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); let mut set = HashSet::new(); @@ -1837,7 +1837,7 @@ fn bench_path_hashset(b: &mut test::Bencher) { fn bench_path_hashset_miss(b: &mut test::Bencher) { let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {}.rs", num))).collect(); + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); let mut set = HashSet::new(); diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index ebb1d8971b9..225a679efd2 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -607,7 +607,7 @@ mod prim_pointer {} /// /// // This loop prints: 0 1 2 /// for x in array { -/// print!("{} ", x); +/// print!("{x} "); /// } /// ``` /// @@ -646,19 +646,19 @@ mod prim_pointer {} /// // This creates a slice iterator, producing references to each value. /// for item in array.into_iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{}] = {}", i, x); +/// println!("array[{i}] = {x}"); /// } /// /// // The `array_into_iter` lint suggests this change for future compatibility: /// for item in array.iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{}] = {}", i, x); +/// println!("array[{i}] = {x}"); /// } /// /// // You can explicitly iterate an array by value using `IntoIterator::into_iter` /// for item in IntoIterator::into_iter(array).enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{}] = {}", i, x); +/// println!("array[{i}] = {x}"); /// } /// ``` /// @@ -673,13 +673,13 @@ mod prim_pointer {} /// // This iterates by reference: /// for item in array.iter().enumerate() { /// let (i, x): (usize, &i32) = item; -/// println!("array[{}] = {}", i, x); +/// println!("array[{i}] = {x}"); /// } /// /// // This iterates by value: /// for item in array.into_iter().enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{}] = {}", i, x); +/// println!("array[{i}] = {x}"); /// } /// ``` /// @@ -702,26 +702,26 @@ mod prim_pointer {} /// // This iterates by reference: /// for item in array.iter() { /// let x: &i32 = item; -/// println!("{}", x); +/// println!("{x}"); /// } /// /// // This iterates by value: /// for item in IntoIterator::into_iter(array) { /// let x: i32 = item; -/// println!("{}", x); +/// println!("{x}"); /// } /// /// // This iterates by value: /// for item in array { /// let x: i32 = item; -/// println!("{}", x); +/// println!("{x}"); /// } /// /// // IntoIter can also start a chain. /// // This iterates by value: /// for item in IntoIterator::into_iter(array).enumerate() { /// let (i, x): (usize, i32) = item; -/// println!("array[{}] = {}", i, x); +/// println!("array[{i}] = {x}"); /// } /// ``` /// diff --git a/library/std/src/process.rs b/library/std/src/process.rs index e3fff155e47..d88ab625371 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -915,7 +915,7 @@ impl Command { /// .status() /// .expect("failed to execute process"); /// - /// println!("process finished with: {}", status); + /// println!("process finished with: {status}"); /// /// assert!(status.success()); /// ``` @@ -1434,7 +1434,7 @@ impl ExitStatus { /// .status() /// .expect("ls could not be executed"); /// - /// println!("ls: {}", status); + /// println!("ls: {status}"); /// status.exit_ok().expect_err("/dev/nonexistent could be listed!"); /// # } // cfg!(unix) /// ``` @@ -1459,7 +1459,7 @@ impl ExitStatus { /// if status.success() { /// println!("'projects/' directory created"); /// } else { - /// println!("failed to create 'projects/' directory: {}", status); + /// println!("failed to create 'projects/' directory: {status}"); /// } /// ``` #[must_use] @@ -1490,7 +1490,7 @@ impl ExitStatus { /// .expect("failed to execute mkdir"); /// /// match status.code() { - /// Some(code) => println!("Exited with status code: {}", code), + /// Some(code) => println!("Exited with status code: {code}"), /// None => println!("Process terminated by signal") /// } /// ``` @@ -1806,13 +1806,13 @@ impl Child { /// let mut child = Command::new("ls").spawn().unwrap(); /// /// match child.try_wait() { - /// Ok(Some(status)) => println!("exited with: {}", status), + /// Ok(Some(status)) => println!("exited with: {status}"), /// Ok(None) => { /// println!("status not ready yet, let's really wait"); /// let res = child.wait(); - /// println!("result: {:?}", res); + /// println!("result: {res:?}"); /// } - /// Err(e) => println!("error attempting to wait: {}", e), + /// Err(e) => println!("error attempting to wait: {e}"), /// } /// ``` #[stable(feature = "process_try_wait", since = "1.18.0")] @@ -1912,7 +1912,7 @@ impl Child { /// std::process::exit(match run_app() { /// Ok(_) => 0, /// Err(err) => { -/// eprintln!("error: {:?}", err); +/// eprintln!("error: {err:?}"); /// 1 /// } /// }); @@ -2071,7 +2071,7 @@ impl Termination for ! { impl<E: fmt::Debug> Termination for Result<!, E> { fn report(self) -> ExitCode { let Err(err) = self; - eprintln!("Error: {:?}", err); + eprintln!("Error: {err:?}"); ExitCode::FAILURE.report() } } diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index e5cdc473706..4f779ab4e78 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -64,7 +64,7 @@ fn signal_reported_right() { p.kill().unwrap(); match p.wait().unwrap().signal() { Some(9) => {} - result => panic!("not terminated by signal 9 (instead, {:?})", result), + result => panic!("not terminated by signal 9 (instead, {result:?})"), } } @@ -252,8 +252,7 @@ fn test_override_env() { assert!( output.contains("RUN_TEST_NEW_ENV=123"), - "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", - output + "didn't find RUN_TEST_NEW_ENV inside of:\n\n{output}", ); } @@ -265,8 +264,7 @@ fn test_add_to_env() { assert!( output.contains("RUN_TEST_NEW_ENV=123"), - "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", - output + "didn't find RUN_TEST_NEW_ENV inside of:\n\n{output}" ); } @@ -288,13 +286,11 @@ fn test_capture_env_at_spawn() { assert!( output.contains("RUN_TEST_NEW_ENV1=123"), - "didn't find RUN_TEST_NEW_ENV1 inside of:\n\n{}", - output + "didn't find RUN_TEST_NEW_ENV1 inside of:\n\n{output}" ); assert!( output.contains("RUN_TEST_NEW_ENV2=456"), - "didn't find RUN_TEST_NEW_ENV2 inside of:\n\n{}", - output + "didn't find RUN_TEST_NEW_ENV2 inside of:\n\n{output}" ); } diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index ee35598bab5..87d01daeafc 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -19,7 +19,7 @@ //! B = 4; //! A = A + B; //! C = B; -//! println!("{} {} {}", A, B, C); +//! println!("{A} {B} {C}"); //! C = A; //! } //! } diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index 2e54321e127..e85a8723965 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -129,7 +129,7 @@ //! //! // Unbounded receiver waiting for all senders to complete. //! while let Ok(msg) = rx.recv() { -//! println!("{}", msg); +//! println!("{msg}"); //! } //! //! println!("completed"); @@ -376,7 +376,7 @@ impl<T> !Sync for Receiver<T> {} /// }); /// /// for x in recv.iter() { -/// println!("Got: {}", x); +/// println!("Got: {x}"); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -419,7 +419,7 @@ pub struct Iter<'a, T: 'a> { /// thread::sleep(Duration::from_secs(2)); // block for two seconds /// /// for x in receiver.try_iter() { -/// println!("Got: {}", x); +/// println!("Got: {x}"); /// } /// ``` #[stable(feature = "receiver_try_iter", since = "1.15.0")] @@ -453,7 +453,7 @@ pub struct TryIter<'a, T: 'a> { /// }); /// /// for x in recv.into_iter() { -/// println!("Got: {}", x); +/// println!("Got: {x}"); /// } /// ``` #[stable(feature = "receiver_into_iter", since = "1.1.0")] @@ -544,16 +544,16 @@ impl<T> !Sync for Sender<T> {} /// let mut msg; /// /// msg = receiver.recv().unwrap(); -/// println!("message {} received", msg); +/// println!("message {msg} received"); /// /// // "Thread unblocked!" will be printed now /// /// msg = receiver.recv().unwrap(); -/// println!("message {} received", msg); +/// println!("message {msg} received"); /// /// msg = receiver.recv().unwrap(); /// -/// println!("message {} received", msg); +/// println!("message {msg} received"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct SyncSender<T> { @@ -996,14 +996,14 @@ impl<T> SyncSender<T> { /// /// let mut msg; /// msg = receiver.recv().unwrap(); - /// println!("message {} received", msg); + /// println!("message {msg} received"); /// /// msg = receiver.recv().unwrap(); - /// println!("message {} received", msg); + /// println!("message {msg} received"); /// /// // Third message may have never been sent /// match receiver.try_recv() { - /// Ok(msg) => println!("message {} received", msg), + /// Ok(msg) => println!("message {msg} received"), /// Err(_) => println!("the third message was never sent"), /// } /// ``` diff --git a/library/std/src/sync/mpsc/shared.rs b/library/std/src/sync/mpsc/shared.rs index 8487a5f8b50..56162655544 100644 --- a/library/std/src/sync/mpsc/shared.rs +++ b/library/std/src/sync/mpsc/shared.rs @@ -369,7 +369,7 @@ impl<T> Packet<T> { match self.channels.fetch_sub(1, Ordering::SeqCst) { 1 => {} n if n > 1 => return, - n => panic!("bad number of channels left {}", n), + n => panic!("bad number of channels left {n}"), } match self.cnt.swap(DISCONNECTED, Ordering::SeqCst) { diff --git a/library/std/src/sync/mutex/tests.rs b/library/std/src/sync/mutex/tests.rs index a1b5aeddcb6..93900566f11 100644 --- a/library/std/src/sync/mutex/tests.rs +++ b/library/std/src/sync/mutex/tests.rs @@ -94,7 +94,7 @@ fn test_into_inner_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().into_inner() { Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), - Ok(x) => panic!("into_inner of poisoned Mutex is Ok: {:?}", x), + Ok(x) => panic!("into_inner of poisoned Mutex is Ok: {x:?}"), } } @@ -118,7 +118,7 @@ fn test_get_mut_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().get_mut() { Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), - Ok(x) => panic!("get_mut of poisoned Mutex is Ok: {:?}", x), + Ok(x) => panic!("get_mut of poisoned Mutex is Ok: {x:?}"), } } diff --git a/library/std/src/sync/poison.rs b/library/std/src/sync/poison.rs index fa950331e64..07a90da449c 100644 --- a/library/std/src/sync/poison.rs +++ b/library/std/src/sync/poison.rs @@ -73,7 +73,7 @@ pub struct Guard { /// Ok(_) => unreachable!(), /// Err(p_err) => { /// let data = p_err.get_ref(); -/// println!("recovered: {}", data); +/// println!("recovered: {data}"); /// } /// }; /// ``` diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs index e9b74fb3ecc..53aa2b1e38a 100644 --- a/library/std/src/sync/rwlock/tests.rs +++ b/library/std/src/sync/rwlock/tests.rs @@ -218,7 +218,7 @@ fn test_into_inner_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().into_inner() { Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), - Ok(x) => panic!("into_inner of poisoned RwLock is Ok: {:?}", x), + Ok(x) => panic!("into_inner of poisoned RwLock is Ok: {x:?}"), } } @@ -242,6 +242,6 @@ fn test_get_mut_poison() { assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().get_mut() { Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), - Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {:?}", x), + Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {x:?}"), } } diff --git a/library/std/src/sys/sgx/abi/mod.rs b/library/std/src/sys/sgx/abi/mod.rs index 5df08a4ff59..9508c387415 100644 --- a/library/std/src/sys/sgx/abi/mod.rs +++ b/library/std/src/sys/sgx/abi/mod.rs @@ -95,7 +95,7 @@ extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64 pub(super) fn exit_with_code(code: isize) -> ! { if code != 0 { if let Some(mut out) = panic::SgxPanicOutput::new() { - let _ = write!(out, "Exited with status code {}", code); + let _ = write!(out, "Exited with status code {code}"); } } usercalls::exit(code != 0); diff --git a/library/std/src/sys/sgx/abi/usercalls/mod.rs b/library/std/src/sys/sgx/abi/usercalls/mod.rs index a6a659df291..4030355f135 100644 --- a/library/std/src/sys/sgx/abi/usercalls/mod.rs +++ b/library/std/src/sys/sgx/abi/usercalls/mod.rs @@ -83,7 +83,7 @@ pub fn close(fd: Fd) { fn string_from_bytebuffer(buf: &alloc::UserRef<ByteBuffer>, usercall: &str, arg: &str) -> String { String::from_utf8(buf.copy_user_buffer()) - .unwrap_or_else(|_| rtabort!("Usercall {}: expected {} to be valid UTF-8", usercall, arg)) + .unwrap_or_else(|_| rtabort!("Usercall {usercall}: expected {arg} to be valid UTF-8")) } /// Usercall `bind_stream`. See the ABI documentation for more information. @@ -287,7 +287,7 @@ fn check_os_error(err: Result) -> i32 { { err } else { - rtabort!("Usercall: returned invalid error value {}", err) + rtabort!("Usercall: returned invalid error value {err}") } } diff --git a/library/std/src/sys/sgx/abi/usercalls/raw.rs b/library/std/src/sys/sgx/abi/usercalls/raw.rs index b0e6a6aaed7..4267b96ccd5 100644 --- a/library/std/src/sys/sgx/abi/usercalls/raw.rs +++ b/library/std/src/sys/sgx/abi/usercalls/raw.rs @@ -132,7 +132,7 @@ impl<T: RegisterArgument> RegisterArgument for Option<NonNull<T>> { impl ReturnValue for ! { fn from_registers(call: &'static str, _regs: (Register, Register)) -> Self { - rtabort!("Usercall {}: did not expect to be re-entered", call); + rtabort!("Usercall {call}: did not expect to be re-entered"); } } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index d14990c6877..feb0b62dcd1 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -501,7 +501,7 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { type Error = io::Error; fn try_from((host, port): (&'a str, u16)) -> io::Result<LookupHost> { - LookupHost::new(format!("{}:{}", host, port)) + LookupHost::new(format!("{host}:{port}")) } } diff --git a/library/std/src/sys/sgx/os.rs b/library/std/src/sys/sgx/os.rs index 5f8b8def7c6..5da0257f35d 100644 --- a/library/std/src/sys/sgx/os.rs +++ b/library/std/src/sys/sgx/os.rs @@ -22,7 +22,7 @@ pub fn error_string(errno: i32) -> String { if errno == RESULT_SUCCESS { "operation successful".into() } else if ((Error::UserRangeStart as _)..=(Error::UserRangeEnd as _)).contains(&errno) { - format!("user-specified error {:08x}", errno) + format!("user-specified error {errno:08x}") } else { decode_error_kind(errno).as_str().into() } diff --git a/library/std/src/sys/sgx/stdio.rs b/library/std/src/sys/sgx/stdio.rs index 8ccf043b5b5..2e680e740fd 100644 --- a/library/std/src/sys/sgx/stdio.rs +++ b/library/std/src/sys/sgx/stdio.rs @@ -83,6 +83,6 @@ pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) { } let buf = unsafe { slice::from_raw_parts(m as *const u8, s as _) }; if let Ok(s) = str::from_utf8(&buf[..buf.iter().position(|&b| b == 0).unwrap_or(buf.len())]) { - eprint!("{}", s); + eprint!("{s}"); } } diff --git a/library/std/src/sys/solid/mod.rs b/library/std/src/sys/solid/mod.rs index 2082c940153..049460755d6 100644 --- a/library/std/src/sys/solid/mod.rs +++ b/library/std/src/sys/solid/mod.rs @@ -87,7 +87,7 @@ pub fn hashmap_random_keys() -> (u64, u64) { unsafe { let mut out = crate::mem::MaybeUninit::<[u64; 2]>::uninit(); let result = abi::SOLID_RNG_SampleRandomBytes(out.as_mut_ptr() as *mut u8, 16); - assert_eq!(result, 0, "SOLID_RNG_SampleRandomBytes failed: {}", result); + assert_eq!(result, 0, "SOLID_RNG_SampleRandomBytes failed: {result}"); let [x1, x2] = out.assume_init(); (x1, x2) } diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index a43407bd0f8..faeda5a854d 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -157,7 +157,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { }; Err(io::Error::new( io::ErrorKind::Uncategorized, - &format!("failed to lookup address information: {}", msg)[..], + &format!("failed to lookup address information: {msg}")[..], )) } } diff --git a/library/std/src/sys/solid/os.rs b/library/std/src/sys/solid/os.rs index 22239e1fa8e..127cca3acca 100644 --- a/library/std/src/sys/solid/os.rs +++ b/library/std/src/sys/solid/os.rs @@ -26,7 +26,7 @@ pub fn errno() -> i32 { } pub fn error_string(errno: i32) -> String { - if let Some(name) = error::error_name(errno) { name.to_owned() } else { format!("{}", errno) } + if let Some(name) = error::error_name(errno) { name.to_owned() } else { format!("{errno}") } } pub fn getcwd() -> io::Result<PathBuf> { diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 61c15ecd85d..e6fd9a0c827 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -54,7 +54,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { Err(io::Error::new( io::ErrorKind::Uncategorized, - &format!("failed to lookup address information: {}", detail)[..], + &format!("failed to lookup address information: {detail}")[..], )) } diff --git a/library/std/src/sys/unix/os_str/tests.rs b/library/std/src/sys/unix/os_str/tests.rs index 37967378155..213277f01f2 100644 --- a/library/std/src/sys/unix/os_str/tests.rs +++ b/library/std/src/sys/unix/os_str/tests.rs @@ -4,7 +4,7 @@ use super::*; fn slice_debug_output() { let input = Slice::from_u8_slice(b"\xF0hello,\tworld"); let expected = r#""\xF0hello,\tworld""#; - let output = format!("{:?}", input); + let output = format!("{input:?}"); assert_eq!(output, expected); } diff --git a/library/std/src/sys/unix/process/process_fuchsia.rs b/library/std/src/sys/unix/process/process_fuchsia.rs index 09bfd9680f5..e3347ab12a7 100644 --- a/library/std/src/sys/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/unix/process/process_fuchsia.rs @@ -211,7 +211,7 @@ impl Process { return Ok(None); } _ => { - panic!("Failed to wait on process handle: {}", status); + panic!("Failed to wait on process handle: {status}"); } } zx_cvt(zx_object_get_info( diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 07a0339c066..9c477e5addc 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -120,7 +120,7 @@ impl Command { Err(ref e) if e.kind() == ErrorKind::Interrupted => {} Err(e) => { assert!(p.wait().is_ok(), "wait() should either return Ok or panic"); - panic!("the CLOEXEC pipe failed: {:?}", e) + panic!("the CLOEXEC pipe failed: {e:?}") } Ok(..) => { // pipe I/O up to PIPE_BUF bytes should be atomic @@ -682,15 +682,15 @@ impl From<c_int> for ExitStatus { impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { - write!(f, "exit status: {}", code) + write!(f, "exit status: {code}") } else if let Some(signal) = self.signal() { if self.core_dumped() { - write!(f, "signal: {} (core dumped)", signal) + write!(f, "signal: {signal} (core dumped)") } else { - write!(f, "signal: {}", signal) + write!(f, "signal: {signal}") } } else if let Some(signal) = self.stopped_signal() { - write!(f, "stopped (not terminated) by signal: {}", signal) + write!(f, "stopped (not terminated) by signal: {signal}") } else if self.continued() { write!(f, "continued (WIFCONTINUED)") } else { diff --git a/library/std/src/sys/unix/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs index 56ed6cfeb6a..016bc20ec0a 100644 --- a/library/std/src/sys/unix/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -239,10 +239,10 @@ impl From<c_int> for ExitStatus { impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { - write!(f, "exit code: {}", code) + write!(f, "exit code: {code}") } else { let signal = self.signal().unwrap(); - write!(f, "signal: {}", signal) + write!(f, "signal: {signal}") } } } diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs index 7a3f6b0d95a..17e8efbe097 100644 --- a/library/std/src/sys/unix/rand.rs +++ b/library/std/src/sys/unix/rand.rs @@ -82,7 +82,7 @@ mod imp { } else if err == libc::EAGAIN { return false; } else { - panic!("unexpected getrandom error: {}", err); + panic!("unexpected getrandom error: {err}"); } } else { read += result as usize; diff --git a/library/std/src/sys/windows/os.rs b/library/std/src/sys/windows/os.rs index 5f8556c3bc3..450bceae000 100644 --- a/library/std/src/sys/windows/os.rs +++ b/library/std/src/sys/windows/os.rs @@ -64,7 +64,7 @@ pub fn error_string(mut errnum: i32) -> String { if res == 0 { // Sometimes FormatMessageW can fail e.g., system doesn't like langId, let fm_err = errno(); - return format!("OS Error {} (FormatMessageW() returned error {})", errnum, fm_err); + return format!("OS Error {errnum} (FormatMessageW() returned error {fm_err})"); } match String::from_utf16(&buf[..res]) { diff --git a/library/std/src/sys/windows/process/tests.rs b/library/std/src/sys/windows/process/tests.rs index d18c3d855bc..d8c9beb0c19 100644 --- a/library/std/src/sys/windows/process/tests.rs +++ b/library/std/src/sys/windows/process/tests.rs @@ -121,9 +121,7 @@ fn windows_env_unicode_case() { assert_eq!( env::var(key).ok(), value.map(|s| s.to_string_lossy().into_owned()), - "command environment mismatch: {} {}", - a, - b + "command environment mismatch: {a} {b}", ); } } diff --git a/library/std/src/sys/windows/thread_parker.rs b/library/std/src/sys/windows/thread_parker.rs index 5a8011a9588..5888ee8e34b 100644 --- a/library/std/src/sys/windows/thread_parker.rs +++ b/library/std/src/sys/windows/thread_parker.rs @@ -230,7 +230,7 @@ fn keyed_event_handle() -> c::HANDLE { 0, ) { c::STATUS_SUCCESS => {} - r => panic!("Unable to create keyed event handle: error {}", r), + r => panic!("Unable to create keyed event handle: error {r}"), } } match HANDLE.compare_exchange(INVALID, handle as usize, Relaxed, Relaxed) { diff --git a/library/std/src/sys_common/backtrace.rs b/library/std/src/sys_common/backtrace.rs index b0b55592f6f..31164afdc7b 100644 --- a/library/std/src/sys_common/backtrace.rs +++ b/library/std/src/sys_common/backtrace.rs @@ -174,7 +174,7 @@ pub fn output_filename( if let Some(cwd) = cwd { if let Ok(stripped) = file.strip_prefix(&cwd) { if let Some(s) = stripped.to_str() { - return write!(fmt, ".{}{}", path::MAIN_SEPARATOR, s); + return write!(fmt, ".{}{s}", path::MAIN_SEPARATOR); } } } diff --git a/library/std/src/sys_common/net/tests.rs b/library/std/src/sys_common/net/tests.rs index 7d45621e09a..ac75d9ebfc8 100644 --- a/library/std/src/sys_common/net/tests.rs +++ b/library/std/src/sys_common/net/tests.rs @@ -6,7 +6,7 @@ fn no_lookup_host_duplicates() { let mut addrs = HashMap::new(); let lh = match LookupHost::try_from(("localhost", 0)) { Ok(lh) => lh, - Err(e) => panic!("couldn't resolve `localhost': {}", e), + Err(e) => panic!("couldn't resolve `localhost': {e}"), }; for sa in lh { *addrs.entry(sa).or_insert(0) += 1; diff --git a/library/std/src/sys_common/thread_parker/generic.rs b/library/std/src/sys_common/thread_parker/generic.rs index d99e901bb5f..ffb61200e15 100644 --- a/library/std/src/sys_common/thread_parker/generic.rs +++ b/library/std/src/sys_common/thread_parker/generic.rs @@ -84,7 +84,7 @@ impl Parker { match self.state.swap(EMPTY, SeqCst) { NOTIFIED => {} // got a notification, hurray! PARKED => {} // no notification, alas - n => panic!("inconsistent park_timeout state: {}", n), + n => panic!("inconsistent park_timeout state: {n}"), } } diff --git a/library/std/src/sys_common/wtf8.rs b/library/std/src/sys_common/wtf8.rs index 7a6e6246357..10ef6662115 100644 --- a/library/std/src/sys_common/wtf8.rs +++ b/library/std/src/sys_common/wtf8.rs @@ -830,7 +830,7 @@ pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { #[inline(never)] pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! { assert!(begin <= end); - panic!("index {} and/or {} in `{:?}` do not lie on character boundary", begin, end, s); + panic!("index {begin} and/or {end} in `{s:?}` do not lie on character boundary"); } /// Iterator for the code points of a WTF-8 string. diff --git a/library/std/src/sys_common/wtf8/tests.rs b/library/std/src/sys_common/wtf8/tests.rs index 1bafbaa6939..931996791fb 100644 --- a/library/std/src/sys_common/wtf8/tests.rs +++ b/library/std/src/sys_common/wtf8/tests.rs @@ -266,7 +266,7 @@ fn wtf8buf_extend() { fn wtf8buf_show() { let mut string = Wtf8Buf::from_str("a\té \u{7f}💩\r"); string.push(CodePoint::from_u32(0xD800).unwrap()); - assert_eq!(format!("{:?}", string), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{d800}\""); + assert_eq!(format!("{string:?}"), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{d800}\""); } #[test] @@ -278,7 +278,7 @@ fn wtf8buf_as_slice() { fn wtf8buf_show_str() { let text = "a\té 💩\r"; let string = Wtf8Buf::from_str(text); - assert_eq!(format!("{:?}", text), format!("{:?}", string)); + assert_eq!(format!("{text:?}"), format!("{string:?}")); } #[test] diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 5ffc86b4560..8f38271eb5d 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -613,7 +613,7 @@ impl Builder { /// /// let receiver = thread::spawn(move || { /// let value = rx.recv().expect("Unable to receive from channel"); -/// println!("{}", value); +/// println!("{value}"); /// }); /// /// sender.join().expect("The sender thread has panicked"); @@ -633,7 +633,7 @@ impl Builder { /// }); /// /// let result = computation.join().unwrap(); -/// println!("{}", result); +/// println!("{result}"); /// ``` /// /// [`channels`]: crate::sync::mpsc @@ -979,7 +979,7 @@ pub fn park_timeout_ms(ms: u32) { /// if elapsed >= timeout { /// break; /// } -/// println!("restarting park_timeout after {:?}", elapsed); +/// println!("restarting park_timeout after {elapsed:?}"); /// timeout_remaining = timeout - elapsed; /// } /// ``` diff --git a/library/std/src/thread/scoped.rs b/library/std/src/thread/scoped.rs index c4847b529a3..07e113f3b62 100644 --- a/library/std/src/thread/scoped.rs +++ b/library/std/src/thread/scoped.rs @@ -22,7 +22,7 @@ pub struct Scope<'scope, 'env: 'scope> { /// std::thread::scope(|s| { /// s.spawn(|| { /// let a = String::from("abcd"); - /// s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped + /// s.spawn(|| println!("{a:?}")); // might run after `a` is dropped /// }); /// }); /// ``` diff --git a/library/std/src/time.rs b/library/std/src/time.rs index df8a726e64e..2f8eb557b4f 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -191,7 +191,7 @@ pub struct Instant(time::Instant); /// } /// Err(e) => { /// // an error occurred! -/// println!("Error: {:?}", e); +/// println!("Error: {e:?}"); /// } /// } /// } @@ -513,7 +513,7 @@ impl SystemTime { /// let new_sys_time = SystemTime::now(); /// let difference = new_sys_time.duration_since(sys_time) /// .expect("Clock may have gone backwards"); - /// println!("{:?}", difference); + /// println!("{difference:?}"); /// ``` #[stable(feature = "time2", since = "1.8.0")] pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, SystemTimeError> { diff --git a/library/std/src/time/tests.rs b/library/std/src/time/tests.rs index d1a69ff8697..d710a574465 100644 --- a/library/std/src/time/tests.rs +++ b/library/std/src/time/tests.rs @@ -55,10 +55,10 @@ fn instant_elapsed() { fn instant_math() { let a = Instant::now(); let b = Instant::now(); - println!("a: {:?}", a); - println!("b: {:?}", b); + println!("a: {a:?}"); + println!("b: {b:?}"); let dur = b.duration_since(a); - println!("dur: {:?}", dur); + println!("dur: {dur:?}"); assert_almost_eq!(b - dur, a); assert_almost_eq!(a + dur, b); | 
