diff --git a/examples/examples/custom-error.rs b/examples/examples/custom-error.rs index 9cc4d939fe..2f93c7a63c 100644 --- a/examples/examples/custom-error.rs +++ b/examples/examples/custom-error.rs @@ -59,7 +59,7 @@ fn main() { .with(ErrorSubscriber::default()) .init(); match do_something("hello world") { - Ok(result) => println!("did something successfully: {}", result), - Err(e) => eprintln!("error: {}", e), + Ok(result) => println!("did something successfully: {result}"), + Err(e) => eprintln!("error: {e}"), }; } diff --git a/examples/examples/fmt-custom-field.rs b/examples/examples/fmt-custom-field.rs index 044055383e..22fe3e0bb7 100644 --- a/examples/examples/fmt-custom-field.rs +++ b/examples/examples/fmt-custom-field.rs @@ -31,7 +31,7 @@ fn main() { // Format fields using the provided closure. let format = format::debug_fn(|writer, field, value| { // We'll format the field name and value separated with a colon. - write!(writer, "{}: {:?}", field, value) + write!(writer, "{field}: {value:?}") }) // Separate each field with a comma. // This method is provided by an extension trait in the diff --git a/examples/examples/instrumented-error.rs b/examples/examples/instrumented-error.rs index 3a78b824c5..bec6b42c8d 100644 --- a/examples/examples/instrumented-error.rs +++ b/examples/examples/instrumented-error.rs @@ -53,7 +53,7 @@ fn main() { .init(); match do_something("hello world") { - Ok(result) => println!("did something successfully: {}", result), + Ok(result) => println!("did something successfully: {result}"), Err(e) => { eprintln!("printing error chain naively"); print_naive_spantraces(&e); @@ -72,9 +72,9 @@ fn print_extracted_spantraces(error: &(dyn Error + 'static)) { while let Some(err) = error { if let Some(spantrace) = err.span_trace() { - eprintln!("Span Backtrace:\n{}", spantrace); + eprintln!("Span Backtrace:\n{spantrace}"); } else { - eprintln!("Error {}: {}", ind, err); + eprintln!("Error {ind}: {err}"); } error = err.source(); @@ -88,7 +88,7 @@ fn print_naive_spantraces(error: &(dyn Error + 'static)) { let mut error = Some(error); let mut ind = 0; while let Some(err) = error { - eprintln!("Error {}: {}", ind, err); + eprintln!("Error {ind}: {err}"); error = err.source(); ind += 1; } diff --git a/examples/examples/map-traced-error.rs b/examples/examples/map-traced-error.rs index fb4d382690..05710e863f 100644 --- a/examples/examples/map-traced-error.rs +++ b/examples/examples/map-traced-error.rs @@ -30,9 +30,9 @@ fn print_extracted_spantraces(error: &(dyn Error + 'static)) { while let Some(err) = error { if let Some(spantrace) = err.span_trace() { - eprintln!("Span Backtrace:\n{}", spantrace); + eprintln!("Span Backtrace:\n{spantrace}"); } else { - eprintln!("Error {}: {}", ind, err); + eprintln!("Error {ind}: {err}"); } error = err.source(); diff --git a/examples/examples/serde-yak-shave.rs b/examples/examples/serde-yak-shave.rs index a718543dfd..9a6afb3d64 100644 --- a/examples/examples/serde-yak-shave.rs +++ b/examples/examples/serde-yak-shave.rs @@ -26,7 +26,7 @@ impl Collect for JsonCollector { "enabled": { "metadata": metadata.as_serde(), }}); - println!("{}", json); + println!("{json}"); true } @@ -38,7 +38,7 @@ impl Collect for JsonCollector { "attributes": attrs.as_serde(), "id": id.as_serde(), }}); - println!("{}", json); + println!("{json}"); id } @@ -48,7 +48,7 @@ impl Collect for JsonCollector { "span": span.as_serde(), "values": values.as_serde(), }}); - println!("{}", json); + println!("{json}"); } fn record_follows_from(&self, span: &Id, follows: &Id) { @@ -57,28 +57,28 @@ impl Collect for JsonCollector { "span": span.as_serde(), "follows": follows.as_serde(), }}); - println!("{}", json); + println!("{json}"); } fn event(&self, event: &Event<'_>) { let json = json!({ "event": event.as_serde(), }); - println!("{}", json); + println!("{json}"); } fn enter(&self, span: &Id) { let json = json!({ "enter": span.as_serde(), }); - println!("{}", json); + println!("{json}"); } fn exit(&self, span: &Id) { let json = json!({ "exit": span.as_serde(), }); - println!("{}", json); + println!("{json}"); } fn current_span(&self) -> Current { diff --git a/examples/examples/sloggish/sloggish_collector.rs b/examples/examples/sloggish/sloggish_collector.rs index 68a236a653..810f8134df 100644 --- a/examples/examples/sloggish/sloggish_collector.rs +++ b/examples/examples/sloggish/sloggish_collector.rs @@ -105,7 +105,7 @@ impl Span { impl Visit for Span { fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { - self.kvs.push((field.name(), format!("{:?}", value))) + self.kvs.push((field.name(), format!("{value:?}"))) } } @@ -123,7 +123,7 @@ impl<'a> Visit for Event<'a> { &mut self.stderr, "{}", // Have to alloc here due to `nu_ansi_term`'s API... - Style::new().bold().paint(format!("{:?}", value)) + Style::new().bold().paint(format!("{value:?}")) ) .unwrap(); } else { diff --git a/examples/examples/tower-load.rs b/examples/examples/tower-load.rs index 808a9a31c7..192569df96 100644 --- a/examples/examples/tower-load.rs +++ b/examples/examples/tower-load.rs @@ -253,12 +253,12 @@ impl Service> for AdminSvc { impl AdminSvc { fn set_from(&self, bytes: Bytes) -> Result<(), String> { use std::str; - let body = str::from_utf8(bytes.as_ref()).map_err(|e| format!("{}", e))?; + let body = str::from_utf8(bytes.as_ref()).map_err(|e| format!("{e}"))?; trace!(request.body = ?body); let new_filter = body .parse::() - .map_err(|e| format!("{}", e))?; - self.handle.reload(new_filter).map_err(|e| format!("{}", e)) + .map_err(|e| format!("{e}"))?; + self.handle.reload(new_filter).map_err(|e| format!("{e}")) } } @@ -280,7 +280,7 @@ impl fmt::Display for HandleError { match self { HandleError::BadPath => f.pad("path must be a single ASCII character"), HandleError::NoContentLength => f.pad("request must have Content-Length header"), - HandleError::BadRequest(ref e) => write!(f, "bad request: {}", e), + HandleError::BadRequest(ref e) => write!(f, "bad request: {e}"), HandleError::Unknown => f.pad("unknown internal error"), } } @@ -302,7 +302,7 @@ fn gen_uri(authority: &str) -> (usize, String) { let idx = rng.gen_range(0, ALPHABET.len() + 1); let len = rng.gen_range(0, 26); let letter = ALPHABET.get(idx..=idx).unwrap_or(""); - (len, format!("http://{}/{}", authority, letter)) + (len, format!("http://{authority}/{letter}")) } #[tracing::instrument(target = "gen", "load_gen")] @@ -316,7 +316,7 @@ async fn load_gen(addr: SocketAddr) -> Result<(), Err> { loop { interval.tick().await; - let authority = format!("{}", addr); + let authority = format!("{addr}"); let mut svc = svc.clone().ready_oneshot().await?; let f = async move { diff --git a/tracing-attributes/src/attr.rs b/tracing-attributes/src/attr.rs index 4684326d62..82e290d014 100644 --- a/tracing-attributes/src/attr.rs +++ b/tracing-attributes/src/attr.rs @@ -50,7 +50,7 @@ impl InstrumentArgs { /// the only way to do this on stable Rust right now. pub(crate) fn warnings(&self) -> impl ToTokens { let warnings = self.parse_warnings.iter().map(|err| { - let msg = format!("found unrecognized input, {}", err); + let msg = format!("found unrecognized input, {err}"); let msg = LitStr::new(&msg, err.span()); // TODO(eliza): This is a bit of a hack, but it's just about the // only way to emit warnings from a proc macro on stable Rust. diff --git a/tracing-core/src/dispatch.rs b/tracing-core/src/dispatch.rs index 53263b494d..3a9dc50fde 100644 --- a/tracing-core/src/dispatch.rs +++ b/tracing-core/src/dispatch.rs @@ -887,13 +887,13 @@ impl fmt::Debug for Dispatch { #[cfg(feature = "alloc")] Kind::Global(collector) => f .debug_tuple("Dispatch::Global") - .field(&format_args!("{:p}", collector)) + .field(&format_args!("{collector:p}")) .finish(), #[cfg(feature = "alloc")] Kind::Scoped(collector) => f .debug_tuple("Dispatch::Scoped") - .field(&format_args!("{:p}", collector)) + .field(&format_args!("{collector:p}")) .finish(), #[cfg(not(feature = "alloc"))] @@ -955,13 +955,13 @@ impl fmt::Debug for WeakDispatch { #[cfg(feature = "alloc")] Kind::Global(collector) => f .debug_tuple("WeakDispatch::Global") - .field(&format_args!("{:p}", collector)) + .field(&format_args!("{collector:p}")) .finish(), #[cfg(feature = "alloc")] Kind::Scoped(collector) => f .debug_tuple("WeakDispatch::Scoped") - .field(&format_args!("{:p}", collector)) + .field(&format_args!("{collector:p}")) .finish(), #[cfg(not(feature = "alloc"))] diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index 6b4c950909..0bdd70da5a 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -318,7 +318,7 @@ impl<'a, 'b> Visit for fmt::DebugStruct<'a, 'b> { impl<'a, 'b> Visit for fmt::DebugMap<'a, 'b> { fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { - self.entry(&format_args!("{}", field), value); + self.entry(&format_args!("{field}"), value); } } @@ -602,7 +602,7 @@ impl fmt::Debug for dyn Value { let mut res = Ok(()); self.record(&FIELD, &mut |_: &Field, val: &dyn fmt::Debug| { - res = write!(f, "{:?}", val); + res = write!(f, "{val:?}"); }); res } @@ -1154,7 +1154,7 @@ mod test { let mut result = String::new(); valueset.record(&mut |_: &Field, value: &dyn fmt::Debug| { use core::fmt::Write; - write!(&mut result, "{:?}", value).unwrap(); + write!(&mut result, "{value:?}").unwrap(); }); assert_eq!(result, String::from("123")); } @@ -1174,9 +1174,9 @@ mod test { let mut result = String::new(); valueset.record(&mut |_: &Field, value: &dyn fmt::Debug| { use core::fmt::Write; - write!(&mut result, "{:?}", value).unwrap(); + write!(&mut result, "{value:?}").unwrap(); }); - assert_eq!(result, format!("{}", err)); + assert_eq!(result, format!("{err}")); } #[test] @@ -1193,7 +1193,7 @@ mod test { let mut result = String::new(); valueset.record(&mut |_: &Field, value: &dyn fmt::Debug| { use core::fmt::Write; - write!(&mut result, "{:?}", value).unwrap(); + write!(&mut result, "{value:?}").unwrap(); }); assert_eq!(result, format!("{}", r#"[61 62 63]" "[c0 ff ee]"#)); } diff --git a/tracing-core/src/metadata.rs b/tracing-core/src/metadata.rs index 3e8cb9761a..4e68fad3a5 100644 --- a/tracing-core/src/metadata.rs +++ b/tracing-core/src/metadata.rs @@ -346,10 +346,10 @@ impl<'a> fmt::Debug for Metadata<'a> { match (self.file(), self.line()) { (Some(file), Some(line)) => { - meta.field("location", &format_args!("{}:{}", file, line)); + meta.field("location", &format_args!("{file}:{line}")); } (Some(file), None) => { - meta.field("file", &format_args!("{}", file)); + meta.field("file", &format_args!("{file}")); } // Note: a line num with no file is a kind of weird case that _probably_ never occurs... @@ -1110,7 +1110,7 @@ mod tests { // We're not going to do anything with it that might be unsound. mem::transmute::(filter) }; - assert_eq!(expected, repr, "repr changed for {:?}", filter) + assert_eq!(expected, repr, "repr changed for {filter:?}") } } } diff --git a/tracing-error/src/backtrace.rs b/tracing-error/src/backtrace.rs index 16335d17b4..af960a687d 100644 --- a/tracing-error/src/backtrace.rs +++ b/tracing-error/src/backtrace.rs @@ -245,7 +245,7 @@ impl fmt::Debug for SpanTrace { .file() .and_then(|file| self.metadata.line().map(|line| (file, line))) { - write!(f, ", file: {:?}, line: {:?}", file, line)?; + write!(f, ", file: {file:?}, line: {line:?}")?; } write!(f, " }}")?; diff --git a/tracing-flame/src/error.rs b/tracing-flame/src/error.rs index b20b438731..2bad91950e 100644 --- a/tracing-flame/src/error.rs +++ b/tracing-flame/src/error.rs @@ -14,7 +14,7 @@ impl Error { eprintln!("Error:"); while let Some(error) = current_error { - eprintln!(" {}: {}", ind, error); + eprintln!(" {ind}: {error}"); ind += 1; current_error = error.source(); } diff --git a/tracing-flame/src/lib.rs b/tracing-flame/src/lib.rs index 5ad84b582c..f0ed3edb29 100644 --- a/tracing-flame/src/lib.rs +++ b/tracing-flame/src/lib.rs @@ -414,7 +414,7 @@ where write!(&mut stack, " {}", samples.as_nanos()) .expect("expected: write to String never fails"); - let _ = writeln!(*self.out.lock().unwrap(), "{}", stack); + let _ = writeln!(*self.out.lock().unwrap(), "{stack}"); } fn on_exit(&self, id: &span::Id, ctx: Context<'_, C>) { @@ -459,7 +459,7 @@ where "expected: write to String never fails" ); - let _ = writeln!(*expect!(self.out.lock()), "{}", stack); + let _ = writeln!(*expect!(self.out.lock()), "{stack}"); } } @@ -487,7 +487,7 @@ where { if config.module_path { if let Some(module_path) = span.metadata().module_path() { - write!(dest, "{}::", module_path)?; + write!(dest, "{module_path}::")?; } } @@ -495,11 +495,11 @@ where if config.file_and_line { if let Some(file) = span.metadata().file() { - write!(dest, ":{}", file)?; + write!(dest, ":{file}")?; } if let Some(line) = span.metadata().line() { - write!(dest, ":{}", line)?; + write!(dest, ":{line}")?; } } diff --git a/tracing-flame/tests/concurrent.rs b/tracing-flame/tests/concurrent.rs index a121176942..92aed29b8a 100644 --- a/tracing-flame/tests/concurrent.rs +++ b/tracing-flame/tests/concurrent.rs @@ -37,7 +37,7 @@ fn capture_supported() { flame_guard.flush().unwrap(); let traces = std::fs::read_to_string(&path).unwrap(); - println!("{}", traces); + println!("{traces}"); assert_eq!(5, traces.lines().count()); tmp_dir.close().expect("failed to delete tempdir"); diff --git a/tracing-journald/src/lib.rs b/tracing-journald/src/lib.rs index 112ee7c2d0..1b0d423ea2 100644 --- a/tracing-journald/src/lib.rs +++ b/tracing-journald/src/lib.rs @@ -385,7 +385,7 @@ impl Visit for SpanVisitor<'_> { fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { self.put_span_prefix(); put_field_length_encoded(self.buf, field.name(), |buf| { - write!(buf, "{:?}", value).unwrap() + write!(buf, "{value:?}").unwrap() }); } } @@ -424,7 +424,7 @@ impl Visit for EventVisitor<'_> { fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { self.put_prefix(field); put_field_length_encoded(self.buf, field.name(), |buf| { - write!(buf, "{:?}", value).unwrap() + write!(buf, "{value:?}").unwrap() }); } } @@ -541,21 +541,21 @@ impl Default for PriorityMappings { fn put_metadata(buf: &mut Vec, meta: &Metadata, prefix: Option<&str>) { if let Some(prefix) = prefix { - write!(buf, "{}", prefix).unwrap(); + write!(buf, "{prefix}").unwrap(); } put_field_wellformed(buf, "TARGET", meta.target().as_bytes()); if let Some(file) = meta.file() { if let Some(prefix) = prefix { - write!(buf, "{}", prefix).unwrap(); + write!(buf, "{prefix}").unwrap(); } put_field_wellformed(buf, "CODE_FILE", file.as_bytes()); } if let Some(line) = meta.line() { if let Some(prefix) = prefix { - write!(buf, "{}", prefix).unwrap(); + write!(buf, "{prefix}").unwrap(); } // Text format is safe as a line number can't possibly contain anything funny - writeln!(buf, "CODE_LINE={}", line).unwrap(); + writeln!(buf, "CODE_LINE={line}").unwrap(); } } diff --git a/tracing-journald/tests/journal.rs b/tracing-journald/tests/journal.rs index df86475fe3..9154a991ef 100644 --- a/tracing-journald/tests/journal.rs +++ b/tracing-journald/tests/journal.rs @@ -34,10 +34,7 @@ fn with_journald_subscriber(subscriber: Subscriber, f: impl FnOnce()) { let sub = Registry::default().with(subscriber); tracing::collect::with_default(sub, f); } - Err(error) => eprintln!( - "SKIPPING TEST: journalctl --version failed with error: {}", - error - ), + Err(error) => eprintln!("SKIPPING TEST: journalctl --version failed with error: {error}"), } } @@ -133,7 +130,7 @@ fn read_from_journal(test_name: &str) -> Vec> { .args(["--user", "--output=json", "--all"]) // Filter by the PID of the current test process .arg(format!("_PID={}", std::process::id())) - .arg(format!("TEST_NAME={}", test_name)) + .arg(format!("TEST_NAME={test_name}")) .output() .unwrap() .stdout, @@ -179,8 +176,8 @@ fn simple_message() { #[test] fn custom_priorities() { fn check_message(level: &str, priority: &str) { - let entry = retry_read_one_line_from_journal(&format!("custom_priority.{}", level)); - assert_eq!(entry["MESSAGE"], format!("hello {}", level).as_str()); + let entry = retry_read_one_line_from_journal(&format!("custom_priority.{level}")); + assert_eq!(entry["MESSAGE"], format!("hello {level}").as_str()); assert_eq!(entry["PRIORITY"], priority); } @@ -256,7 +253,7 @@ fn large_message() { let message = retry_read_one_line_from_journal("large_message"); assert_eq!( message["MESSAGE"], - format!("Message: {}", large_string).as_str() + format!("Message: {large_string}").as_str() ); assert_eq!(message["PRIORITY"], "6"); }); diff --git a/tracing-log/src/lib.rs b/tracing-log/src/lib.rs index dbdf8e9549..74f1ed2ec9 100644 --- a/tracing-log/src/lib.rs +++ b/tracing-log/src/lib.rs @@ -564,9 +564,7 @@ mod test { assert_eq!( meta.callsite(), cs_meta.callsite(), - "actual: {:#?}\nexpected: {:#?}", - meta, - cs_meta + "actual: {meta:#?}\nexpected: {cs_meta:#?}" ); assert_eq!(meta.level(), &level.as_trace()); } diff --git a/tracing-mock/src/collector.rs b/tracing-mock/src/collector.rs index fcf5f0ede3..2982b8e2c5 100644 --- a/tracing-mock/src/collector.rs +++ b/tracing-mock/src/collector.rs @@ -1075,7 +1075,7 @@ where }; expected.check(event, event_get_ancestry, &self.name); } - Some(ex) => ex.bad(&self.name, format_args!("observed event {:#?}", event)), + Some(ex) => ex.bad(&self.name, format_args!("observed event {event:#?}")), } } diff --git a/tracing-mock/src/event.rs b/tracing-mock/src/event.rs index 5978cbf95b..bfff895d25 100644 --- a/tracing-mock/src/event.rs +++ b/tracing-mock/src/event.rs @@ -540,7 +540,7 @@ impl ExpectedEvent { let meta = event.metadata(); let name = meta.name(); self.metadata - .check(meta, format_args!("event \"{}\"", name), collector_name); + .check(meta, format_args!("event \"{name}\""), collector_name); assert!( meta.is_event(), "[{}] expected {}, but got {:?}", @@ -580,7 +580,7 @@ impl fmt::Debug for ExpectedEvent { } if let Some(ref level) = self.metadata.level { - s.field("level", &format_args!("{:?}", level)); + s.field("level", &format_args!("{level:?}")); } if let Some(ref fields) = self.fields { @@ -588,7 +588,7 @@ impl fmt::Debug for ExpectedEvent { } if let Some(ref parent) = self.ancestry { - s.field("parent", &format_args!("{:?}", parent)); + s.field("parent", &format_args!("{parent:?}")); } if let Some(in_spans) = &self.in_spans { diff --git a/tracing-mock/src/field.rs b/tracing-mock/src/field.rs index c4b07b818e..4348ae42c8 100644 --- a/tracing-mock/src/field.rs +++ b/tracing-mock/src/field.rs @@ -504,12 +504,12 @@ impl ExpectedFields { impl fmt::Display for ExpectedValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ExpectedValue::F64(v) => write!(f, "f64 = {:?}", v), - ExpectedValue::I64(v) => write!(f, "i64 = {:?}", v), - ExpectedValue::U64(v) => write!(f, "u64 = {:?}", v), - ExpectedValue::Bool(v) => write!(f, "bool = {:?}", v), - ExpectedValue::Str(v) => write!(f, "&str = {:?}", v), - ExpectedValue::Debug(v) => write!(f, "&fmt::Debug = {:?}", v), + ExpectedValue::F64(v) => write!(f, "f64 = {v:?}"), + ExpectedValue::I64(v) => write!(f, "i64 = {v:?}"), + ExpectedValue::U64(v) => write!(f, "u64 = {v:?}"), + ExpectedValue::Bool(v) => write!(f, "bool = {v:?}"), + ExpectedValue::Str(v) => write!(f, "&str = {v:?}"), + ExpectedValue::Debug(v) => write!(f, "&fmt::Debug = {v:?}"), ExpectedValue::Any => write!(f, "_ = _"), } } @@ -597,7 +597,7 @@ impl<'a> From<&'a dyn Value> for ExpectedValue { } fn record_debug(&mut self, _: &Field, value: &dyn fmt::Debug) { - self.value = Some(ExpectedValue::Debug(format!("{:?}", value))); + self.value = Some(ExpectedValue::Debug(format!("{value:?}"))); } } diff --git a/tracing-mock/src/metadata.rs b/tracing-mock/src/metadata.rs index 7c083a5842..947233824f 100644 --- a/tracing-mock/src/metadata.rs +++ b/tracing-mock/src/metadata.rs @@ -78,15 +78,15 @@ impl ExpectedMetadata { impl fmt::Display for ExpectedMetadata { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(ref name) = self.name { - write!(f, " named `{}`", name)?; + write!(f, " named `{name}`")?; } if let Some(ref level) = self.level { - write!(f, " at the `{:?}` level", level)?; + write!(f, " at the `{level:?}` level")?; } if let Some(ref target) = self.target { - write!(f, " with target `{}`", target)?; + write!(f, " with target `{target}`")?; } Ok(()) diff --git a/tracing-mock/src/span.rs b/tracing-mock/src/span.rs index 62737d32fa..0056ee7dfe 100644 --- a/tracing-mock/src/span.rs +++ b/tracing-mock/src/span.rs @@ -836,7 +836,7 @@ impl fmt::Debug for ExpectedSpan { } if let Some(level) = self.level() { - s.field("level", &format_args!("{:?}", level)); + s.field("level", &format_args!("{level:?}")); } if let Some(target) = self.target() { @@ -916,7 +916,7 @@ impl NewSpan { let actual_ancestry = get_ancestry(); expected_ancestry.check( &actual_ancestry, - format_args!("span `{}`", name), + format_args!("span `{name}`"), collector_name, ); } @@ -942,7 +942,7 @@ impl fmt::Debug for NewSpan { } if let Some(level) = self.span.level() { - s.field("level", &format_args!("{:?}", level)); + s.field("level", &format_args!("{level:?}")); } if let Some(target) = self.span.target() { @@ -950,7 +950,7 @@ impl fmt::Debug for NewSpan { } if let Some(ref parent) = self.ancestry { - s.field("parent", &format_args!("{:?}", parent)); + s.field("parent", &format_args!("{parent:?}")); } if !self.fields.is_empty() { diff --git a/tracing-mock/src/subscriber.rs b/tracing-mock/src/subscriber.rs index a9bfabff10..8c66d41b19 100644 --- a/tracing-mock/src/subscriber.rs +++ b/tracing-mock/src/subscriber.rs @@ -350,7 +350,7 @@ impl MockSubscriberBuilder { pub fn named(mut self, name: impl fmt::Display) -> Self { use std::fmt::Write; if !self.name.is_empty() { - write!(&mut self.name, "::{}", name).unwrap(); + write!(&mut self.name, "::{name}").unwrap(); } else { self.name = name.to_string(); } @@ -811,7 +811,7 @@ impl MockSubscriber { ); expected.check( &(&actual).into(), - format_args!("the {}th span in the event's scope to be", i), + format_args!("the {i}th span in the event's scope to be"), &self.name, ); i += 1; @@ -870,7 +870,7 @@ where self.check_event_scope(cx.event_scope(event), expected_scope); } } - Some(ex) => ex.bad(&self.name, format_args!("observed event {:#?}", event)), + Some(ex) => ex.bad(&self.name, format_args!("observed event {event:#?}")), } } diff --git a/tracing-serde/src/lib.rs b/tracing-serde/src/lib.rs index 0692f7d645..592b10d5a8 100644 --- a/tracing-serde/src/lib.rs +++ b/tracing-serde/src/lib.rs @@ -392,7 +392,7 @@ where if self.state.is_ok() { self.state = self .serializer - .serialize_entry(field.name(), &format_args!("{:?}", value)) + .serialize_entry(field.name(), &format_args!("{value:?}")) } } @@ -444,7 +444,7 @@ where if self.state.is_ok() { self.state = self .serializer - .serialize_field(field.name(), &format_args!("{:?}", value)) + .serialize_field(field.name(), &format_args!("{value:?}")) } } diff --git a/tracing-subscriber/src/field/debug.rs b/tracing-subscriber/src/field/debug.rs index cc67d29fe7..5c89530799 100644 --- a/tracing-subscriber/src/field/debug.rs +++ b/tracing-subscriber/src/field/debug.rs @@ -70,7 +70,7 @@ where #[inline] fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { - self.0.record_debug(field, &format_args!("{:#?}", value)) + self.0.record_debug(field, &format_args!("{value:#?}")) } } diff --git a/tracing-subscriber/src/field/display.rs b/tracing-subscriber/src/field/display.rs index 78a039ce17..234dbc8fd5 100644 --- a/tracing-subscriber/src/field/display.rs +++ b/tracing-subscriber/src/field/display.rs @@ -63,7 +63,7 @@ where /// Visit a string value. fn record_str(&mut self, field: &Field, value: &str) { if field.name() == "message" { - self.0.record_debug(field, &format_args!("{}", value)) + self.0.record_debug(field, &format_args!("{value}")) } else { self.0.record_str(field, value) } diff --git a/tracing-subscriber/src/field/mod.rs b/tracing-subscriber/src/field/mod.rs index e55ec82d6e..672de7c52b 100644 --- a/tracing-subscriber/src/field/mod.rs +++ b/tracing-subscriber/src/field/mod.rs @@ -340,7 +340,7 @@ pub(in crate::field) mod test_util { impl<'a> Visit for DebugVisitor<'a> { fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { - write!(self.writer, "{}={:?}", field, value).unwrap(); + write!(self.writer, "{field}={value:?}").unwrap(); } } diff --git a/tracing-subscriber/src/filter/directive.rs b/tracing-subscriber/src/filter/directive.rs index 8e00a57a43..8a1b7822ec 100644 --- a/tracing-subscriber/src/filter/directive.rs +++ b/tracing-subscriber/src/filter/directive.rs @@ -289,9 +289,9 @@ impl fmt::Display for StaticDirective { let mut fields = self.field_names.iter(); if let Some(field) = fields.next() { - write!(f, "{{{}", field)?; + write!(f, "{{{field}")?; for field in fields { - write!(f, ",{}", field)?; + write!(f, ",{field}")?; } f.write_str("}")?; } @@ -407,10 +407,10 @@ impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.kind { ParseErrorKind::Other(None) => f.pad("invalid filter directive"), - ParseErrorKind::Other(Some(msg)) => write!(f, "invalid filter directive: {}", msg), + ParseErrorKind::Other(Some(msg)) => write!(f, "invalid filter directive: {msg}"), ParseErrorKind::Level(ref l) => l.fmt(f), #[cfg(feature = "std")] - ParseErrorKind::Field(ref e) => write!(f, "invalid field filter: {}", e), + ParseErrorKind::Field(ref e) => write!(f, "invalid field filter: {e}"), } } } diff --git a/tracing-subscriber/src/filter/env/builder.rs b/tracing-subscriber/src/filter/env/builder.rs index 8d126af2de..d10d576bbd 100644 --- a/tracing-subscriber/src/filter/env/builder.rs +++ b/tracing-subscriber/src/filter/env/builder.rs @@ -141,7 +141,7 @@ impl Builder { .filter_map(|s| match Directive::parse(s, self.regex) { Ok(d) => Some(d), Err(err) => { - eprintln!("ignoring `{}`: {}", s, err); + eprintln!("ignoring `{s}`: {err}"); None } }); @@ -225,7 +225,7 @@ impl Builder { warning.style_ref_mut().is_bold = true; format!("{}{} {}", warning, bold.paint(":"), bold.paint(msg)) }; - eprintln!("{}", msg); + eprintln!("{msg}"); }; let ctx_prefixed = |prefix: &str, msg: &str| { #[cfg(not(feature = "nu-ansi-term"))] @@ -236,7 +236,7 @@ impl Builder { equal.style_ref_mut().is_bold = true; format!(" {} {} {}", equal, Style::new().bold().paint(prefix), msg) }; - eprintln!("{}", msg); + eprintln!("{msg}"); }; let ctx_help = |msg| ctx_prefixed("help:", msg); let ctx_note = |msg| ctx_prefixed("note:", msg); @@ -247,14 +247,14 @@ impl Builder { let msg = { let mut pipe = Color::Fixed(21).paint("|"); pipe.style_ref_mut().is_bold = true; - format!(" {} {}", pipe, msg) + format!(" {pipe} {msg}") }; - eprintln!("{}", msg); + eprintln!("{msg}"); }; warn("some trace filter directives would enable traces that are disabled statically"); for directive in disabled { let target = if let Some(target) = &directive.target { - format!("the `{}` target", target) + format!("the `{target}` target") } else { "all targets".into() }; @@ -263,11 +263,10 @@ impl Builder { .into_level() .expect("=off would not have enabled any filters"); ctx(&format!( - "`{}` would enable the {} level for {}", - directive, level, target + "`{directive}` would enable the {level} level for {target}" )); } - ctx_note(&format!("the static max level is `{}`", STATIC_MAX_LEVEL)); + ctx_note(&format!("the static max level is `{STATIC_MAX_LEVEL}`")); let help_msg = || { let (feature, filter) = match STATIC_MAX_LEVEL.into_level() { Some(Level::TRACE) => unreachable!( @@ -279,12 +278,11 @@ impl Builder { Some(Level::ERROR) => ("max_level_error", Level::WARN), None => return ("max_level_off", String::new()), }; - (feature, format!("{} ", filter)) + (feature, format!("{filter} ")) }; let (feature, earlier_level) = help_msg(); ctx_help(&format!( - "to enable {}logging, remove the `{}` feature from the `tracing` crate", - earlier_level, feature + "to enable {earlier_level}logging, remove the `{feature}` feature from the `tracing` crate" )); } diff --git a/tracing-subscriber/src/filter/env/directive.rs b/tracing-subscriber/src/filter/env/directive.rs index 1f0b118661..a1dbada9bd 100644 --- a/tracing-subscriber/src/filter/env/directive.rs +++ b/tracing-subscriber/src/filter/env/directive.rs @@ -344,9 +344,9 @@ impl fmt::Display for Directive { let mut fields = self.fields.iter(); if let Some(field) = fields.next() { - write!(f, "{{{}", field)?; + write!(f, "{{{field}")?; for field in fields { - write!(f, ",{}", field)?; + write!(f, ",{field}")?; } f.write_str("}")?; } @@ -568,7 +568,7 @@ mod test { #[test] fn parse_directives_ralith() { let dirs = parse_directives("common=trace,server=trace"); - assert_eq!(dirs.len(), 2, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 2, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("common".to_string())); assert_eq!(dirs[0].level, LevelFilter::TRACE); assert_eq!(dirs[0].in_span, None); @@ -581,7 +581,7 @@ mod test { #[test] fn parse_directives_ralith_uc() { let dirs = parse_directives("common=INFO,server=DEBUG"); - assert_eq!(dirs.len(), 2, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 2, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("common".to_string())); assert_eq!(dirs[0].level, LevelFilter::INFO); assert_eq!(dirs[0].in_span, None); @@ -594,7 +594,7 @@ mod test { #[test] fn parse_directives_ralith_mixed() { let dirs = parse_directives("common=iNfo,server=dEbUg"); - assert_eq!(dirs.len(), 2, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 2, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("common".to_string())); assert_eq!(dirs[0].level, LevelFilter::INFO); assert_eq!(dirs[0].in_span, None); @@ -607,7 +607,7 @@ mod test { #[test] fn parse_directives_valid() { let dirs = parse_directives("crate1::mod1=error,crate1::mod2,crate2=debug,crate3=off"); - assert_eq!(dirs.len(), 4, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 4, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LevelFilter::ERROR); assert_eq!(dirs[0].in_span, None); @@ -632,7 +632,7 @@ mod test { "crate1::mod1=error,crate1::mod2=warn,crate1::mod2::mod3=info,\ crate2=debug,crate3=trace,crate3::mod2::mod1=off", ); - assert_eq!(dirs.len(), 6, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 6, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LevelFilter::ERROR); assert_eq!(dirs[0].in_span, None); @@ -664,7 +664,7 @@ mod test { "crate1::mod1=ERROR,crate1::mod2=WARN,crate1::mod2::mod3=INFO,\ crate2=DEBUG,crate3=TRACE,crate3::mod2::mod1=OFF", ); - assert_eq!(dirs.len(), 6, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 6, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LevelFilter::ERROR); assert_eq!(dirs[0].in_span, None); @@ -696,7 +696,7 @@ mod test { "crate1::mod1=1,crate1::mod2=2,crate1::mod2::mod3=3,crate2=4,\ crate3=5,crate3::mod2::mod1=0", ); - assert_eq!(dirs.len(), 6, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 6, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LevelFilter::ERROR); assert_eq!(dirs[0].in_span, None); @@ -726,7 +726,7 @@ mod test { fn parse_directives_invalid_crate() { // test parse_directives with multiple = in specification let dirs = parse_directives("crate1::mod1=warn=info,crate2=debug"); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate2".to_string())); assert_eq!(dirs[0].level, LevelFilter::DEBUG); assert_eq!(dirs[0].in_span, None); @@ -736,7 +736,7 @@ mod test { fn parse_directives_invalid_level() { // test parse_directives with 'noNumber' as log level let dirs = parse_directives("crate1::mod1=noNumber,crate2=debug"); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate2".to_string())); assert_eq!(dirs[0].level, LevelFilter::DEBUG); assert_eq!(dirs[0].in_span, None); @@ -746,7 +746,7 @@ mod test { fn parse_directives_string_level() { // test parse_directives with 'warn' as log level let dirs = parse_directives("crate1::mod1=wrong,crate2=warn"); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate2".to_string())); assert_eq!(dirs[0].level, LevelFilter::WARN); assert_eq!(dirs[0].in_span, None); @@ -756,7 +756,7 @@ mod test { fn parse_directives_empty_level() { // test parse_directives with '' as log level let dirs = parse_directives("crate1::mod1=wrong,crate2="); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate2".to_string())); assert_eq!(dirs[0].level, LevelFilter::TRACE); assert_eq!(dirs[0].in_span, None); @@ -766,7 +766,7 @@ mod test { fn parse_directives_global() { // test parse_directives with no crate let dirs = parse_directives("warn,crate2=debug"); - assert_eq!(dirs.len(), 2, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 2, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, None); assert_eq!(dirs[0].level, LevelFilter::WARN); assert_eq!(dirs[1].in_span, None); @@ -782,9 +782,7 @@ mod test { assert_eq!( dirs.len(), 1, - "\ninput: \"{}\"; parsed: {:#?}", - directive_to_test, - dirs + "\ninput: \"{directive_to_test}\"; parsed: {dirs:#?}" ); assert_eq!(dirs[0].target, None); assert_eq!(dirs[0].level, level_expected); @@ -812,7 +810,7 @@ mod test { #[test] fn parse_directives_valid_with_spans() { let dirs = parse_directives("crate1::mod1[foo]=error,crate1::mod2[bar],crate2[baz]=debug"); - assert_eq!(dirs.len(), 3, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 3, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LevelFilter::ERROR); assert_eq!(dirs[0].in_span, Some("foo".to_string())); @@ -829,7 +827,7 @@ mod test { #[test] fn parse_directives_with_dash_in_target_name() { let dirs = parse_directives("target-name=info"); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("target-name".to_string())); assert_eq!(dirs[0].level, LevelFilter::INFO); assert_eq!(dirs[0].in_span, None); @@ -840,7 +838,7 @@ mod test { // Reproduces https://github.com/tokio-rs/tracing/issues/1367 let dirs = parse_directives("target[span-name]=info"); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("target".to_string())); assert_eq!(dirs[0].level, LevelFilter::INFO); assert_eq!(dirs[0].in_span, Some("span-name".to_string())); @@ -850,8 +848,8 @@ mod test { fn parse_directives_with_special_characters_in_span_name() { let span_name = "!\"#$%&'()*+-./:;<=>?@^_`|~[}"; - let dirs = parse_directives(format!("target[{}]=info", span_name)); - assert_eq!(dirs.len(), 1, "\nparsed: {:#?}", dirs); + let dirs = parse_directives(format!("target[{span_name}]=info")); + assert_eq!(dirs.len(), 1, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("target".to_string())); assert_eq!(dirs[0].level, LevelFilter::INFO); assert_eq!(dirs[0].in_span, Some(span_name.to_string())); @@ -861,7 +859,7 @@ mod test { fn parse_directives_with_invalid_span_chars() { let invalid_span_name = "]{"; - let dirs = parse_directives(format!("target[{}]=info", invalid_span_name)); - assert_eq!(dirs.len(), 0, "\nparsed: {:#?}", dirs); + let dirs = parse_directives(format!("target[{invalid_span_name}]=info")); + assert_eq!(dirs.len(), 0, "\nparsed: {dirs:#?}"); } } diff --git a/tracing-subscriber/src/filter/env/field.rs b/tracing-subscriber/src/filter/env/field.rs index d6d97afe3b..b4d15a4c29 100644 --- a/tracing-subscriber/src/filter/env/field.rs +++ b/tracing-subscriber/src/filter/env/field.rs @@ -181,7 +181,7 @@ impl fmt::Display for Match { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.name, f)?; if let Some(ref value) = self.value { - write!(f, "={}", value)?; + write!(f, "={value}")?; } Ok(()) } @@ -399,7 +399,7 @@ impl MatchDebug { // Try to "write" the value's `fmt::Debug` output to a `Matcher`. This // returns an error if the `fmt::Debug` implementation wrote any // characters that did not match the expected pattern. - write!(matcher, "{:?}", d).is_ok() + write!(matcher, "{d:?}").is_ok() } } @@ -592,7 +592,7 @@ mod tests { let pattern = "MyStruct { answer: 42, question: \"life, the universe, and everything\" }"; assert_eq!( - format!("{:?}", my_struct), + format!("{my_struct:?}"), pattern, "`MyStruct`'s `Debug` impl doesn't output the expected string" ); @@ -613,7 +613,7 @@ mod tests { let pattern = "MyStruct { answer: 42, question: \"life, the universe, and everything\" }"; assert_eq!( - format!("{:?}", my_struct), + format!("{my_struct:?}"), "MyStruct { answer: 42, question: \"what shall we have for lunch?\" }", "`MyStruct`'s `Debug` impl doesn't output the expected string" ); diff --git a/tracing-subscriber/src/filter/env/mod.rs b/tracing-subscriber/src/filter/env/mod.rs index 4819e7936b..d81dca787f 100644 --- a/tracing-subscriber/src/filter/env/mod.rs +++ b/tracing-subscriber/src/filter/env/mod.rs @@ -754,7 +754,7 @@ impl fmt::Display for EnvFilter { let wrote_statics = if let Some(next) = statics.next() { fmt::Display::fmt(next, f)?; for directive in statics { - write!(f, ",{}", directive)?; + write!(f, ",{directive}")?; } true } else { @@ -768,7 +768,7 @@ impl fmt::Display for EnvFilter { } fmt::Display::fmt(next, f)?; for directive in dynamics { - write!(f, ",{}", directive)?; + write!(f, ",{directive}")?; } } Ok(()) @@ -947,7 +947,7 @@ mod tests { "[span1{foo=1}]=error,[span2{bar=2 baz=false}],crate2[{quux=\"quuux\"}]=debug" .parse() .unwrap(); - let f2: EnvFilter = format!("{}", f1).parse().unwrap(); + let f2: EnvFilter = format!("{f1}").parse().unwrap(); assert_eq!(f1.statics, f2.statics); assert_eq!(f1.dynamics, f2.dynamics); } diff --git a/tracing-subscriber/src/filter/targets.rs b/tracing-subscriber/src/filter/targets.rs index d26c428a73..14f3244a90 100644 --- a/tracing-subscriber/src/filter/targets.rs +++ b/tracing-subscriber/src/filter/targets.rs @@ -493,9 +493,9 @@ impl fmt::Display for Targets { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut directives = self.0.directives(); if let Some(directive) = directives.next() { - write!(f, "{}", directive)?; + write!(f, "{directive}")?; for directive in directives { - write!(f, ",{}", directive)?; + write!(f, ",{directive}")?; } } @@ -617,7 +617,7 @@ mod tests { fn expect_parse_ralith(s: &str) { let dirs = expect_parse(s).0.into_vec(); - assert_eq!(dirs.len(), 2, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 2, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("server".to_string())); assert_eq!(dirs[0].level, LevelFilter::DEBUG); assert_eq!(dirs[0].field_names, Vec::::new()); @@ -629,7 +629,7 @@ mod tests { fn expect_parse_level_directives(s: &str) { let dirs = expect_parse(s).0.into_vec(); - assert_eq!(dirs.len(), 6, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 6, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate3::mod2::mod1".to_string())); assert_eq!(dirs[0].level, LevelFilter::OFF); @@ -676,7 +676,7 @@ mod tests { let dirs = expect_parse("crate1::mod1=error,crate1::mod2,crate2=debug,crate3=off") .0 .into_vec(); - assert_eq!(dirs.len(), 4, "\nparsed: {:#?}", dirs); + assert_eq!(dirs.len(), 4, "\nparsed: {dirs:#?}"); assert_eq!(dirs[0].target, Some("crate1::mod2".to_string())); assert_eq!(dirs[0].level, LevelFilter::TRACE); assert_eq!(dirs[0].field_names, Vec::::new()); diff --git a/tracing-subscriber/src/fmt/fmt_subscriber.rs b/tracing-subscriber/src/fmt/fmt_subscriber.rs index 90027f02fe..be0c57b248 100644 --- a/tracing-subscriber/src/fmt/fmt_subscriber.rs +++ b/tracing-subscriber/src/fmt/fmt_subscriber.rs @@ -845,8 +845,7 @@ where extensions.insert(fields); } else { eprintln!( - "[tracing-subscriber] Unable to format the following event, ignoring: {:?}", - attrs + "[tracing-subscriber] Unable to format the following event, ignoring: {attrs:?}" ); } } @@ -997,7 +996,7 @@ where let res = io::Write::write_all(&mut writer, buf.as_bytes()); if self.log_internal_errors { if let Err(e) = res { - eprintln!("[tracing-subscriber] Unable to write an event to the Writer for this Subscriber! Error: {}\n", e); + eprintln!("[tracing-subscriber] Unable to write an event to the Writer for this Subscriber! Error: {e}\n"); } } } else if self.log_internal_errors { @@ -1006,7 +1005,7 @@ where let mut writer = self.make_writer.make_writer_for(event.metadata()); let res = io::Write::write_all(&mut writer, err_msg.as_bytes()); if let Err(e) = res { - eprintln!("[tracing-subscriber] Unable to write an \"event formatting error\" to the Writer for this Subscriber! Error: {}\n", e); + eprintln!("[tracing-subscriber] Unable to write an \"event formatting error\" to the Writer for this Subscriber! Error: {e}\n"); } } @@ -1586,8 +1585,7 @@ mod test { let subscriber: Subscriber<()> = fmt::Subscriber::default(); assert_eq!( subscriber.is_ansi, ansi, - "NO_COLOR={:?}; Subscriber::default().is_ansi should be {}", - var, ansi + "NO_COLOR={var:?}; Subscriber::default().is_ansi should be {ansi}" ); // with_ansi should override any `NO_COLOR` value diff --git a/tracing-subscriber/src/fmt/format/json.rs b/tracing-subscriber/src/fmt/format/json.rs index 41ed58a3f7..9d9f36ab57 100644 --- a/tracing-subscriber/src/fmt/format/json.rs +++ b/tracing-subscriber/src/fmt/format/json.rs @@ -186,7 +186,7 @@ where // If we *aren't* in debug mode, it's probably best not // crash the program, but let's at least make sure it's clear // that the fields are not supposed to be missing. - Err(e) => serializer.serialize_entry("field_error", &format!("{}", e))?, + Err(e) => serializer.serialize_entry("field_error", &format!("{e}"))?, }; serializer.serialize_entry("name", self.0.metadata().name())?; serializer.end() @@ -500,11 +500,11 @@ impl<'a> field::Visit for JsonVisitor<'a> { name if name.starts_with("log.") => (), name if name.starts_with("r#") => { self.values - .insert(&name[2..], serde_json::Value::from(format!("{:?}", value))); + .insert(&name[2..], serde_json::Value::from(format!("{value:?}"))); } name => { self.values - .insert(name, serde_json::Value::from(format!("{:?}", value))); + .insert(name, serde_json::Value::from(format!("{value:?}"))); } }; } diff --git a/tracing-subscriber/src/fmt/format/mod.rs b/tracing-subscriber/src/fmt/format/mod.rs index f979121da2..e55c426d81 100644 --- a/tracing-subscriber/src/fmt/format/mod.rs +++ b/tracing-subscriber/src/fmt/format/mod.rs @@ -834,7 +834,7 @@ impl Format { F::format_level(level) } }; - return write!(writer, "{} ", fmt_level); + return write!(writer, "{fmt_level} "); } Ok(()) @@ -1208,7 +1208,7 @@ impl<'a> field::Visit for DefaultVisitor<'a> { } if field.name() == "message" { - self.record_debug(field, &format_args!("{}", value)) + self.record_debug(field, &format_args!("{value}")) } else { self.record_debug(field, &value) } @@ -1229,7 +1229,7 @@ impl<'a> field::Visit for DefaultVisitor<'a> { ), ) } else { - self.record_debug(field, &format_args!("{}", value)) + self.record_debug(field, &format_args!("{value}")) } } @@ -1240,7 +1240,7 @@ impl<'a> field::Visit for DefaultVisitor<'a> { self.maybe_pad(); self.result = match field.name() { - "message" => write!(self.writer, "{:?}", value), + "message" => write!(self.writer, "{value:?}"), // Skip fields that are actually log metadata that have already been handled #[cfg(feature = "tracing-log")] name if name.starts_with("log.") => Ok(()), @@ -1282,7 +1282,7 @@ impl<'a> Display for ErrorSourceList<'a> { let mut list = f.debug_list(); let mut curr = Some(self.0); while let Some(curr_err) = curr { - list.entry(&format_args!("{}", curr_err)); + list.entry(&format_args!("{curr_err}")); curr = curr_err.source(); } list.finish() @@ -1635,11 +1635,11 @@ impl Display for TimingDisplay { let mut t = self.0 as f64; for unit in ["ns", "µs", "ms", "s"].iter() { if t < 10.0 { - return write!(f, "{:.2}{}", t, unit); + return write!(f, "{t:.2}{unit}"); } else if t < 100.0 { - return write!(f, "{:.1}{}", t, unit); + return write!(f, "{t:.1}{unit}"); } else if t < 1000.0 { - return write!(f, "{:.0}{}", t, unit); + return write!(f, "{t:.0}{unit}"); } t /= 1000.0; } diff --git a/tracing-subscriber/src/fmt/format/pretty.rs b/tracing-subscriber/src/fmt/format/pretty.rs index 1a0edd428c..4285b9177c 100644 --- a/tracing-subscriber/src/fmt/format/pretty.rs +++ b/tracing-subscriber/src/fmt/format/pretty.rs @@ -257,7 +257,7 @@ where write!(writer, " {} {}", dimmed.paint("at"), file,)?; if let Some(line) = line_number { - write!(writer, ":{}", line)?; + write!(writer, ":{line}")?; } writer.write_char(if thread { ' ' } else { '\n' })?; } else if thread { @@ -269,7 +269,7 @@ where let thread = std::thread::current(); if self.display_thread_name { if let Some(name) = thread.name() { - write!(writer, "{}", name)?; + write!(writer, "{name}")?; if self.display_thread_id { writer.write_char(' ')?; } @@ -413,7 +413,7 @@ impl<'a> PrettyVisitor<'a> { } else { ", " }; - self.result = write!(self.writer, "{}{:?}", padding, value); + self.result = write!(self.writer, "{padding}{value:?}"); } fn bold(&self) -> Style { @@ -432,7 +432,7 @@ impl<'a> field::Visit for PrettyVisitor<'a> { } if field.name() == "message" { - self.record_debug(field, &format_args!("{}", value)) + self.record_debug(field, &format_args!("{value}")) } else { self.record_debug(field, &value) } @@ -453,7 +453,7 @@ impl<'a> field::Visit for PrettyVisitor<'a> { ), ) } else { - self.record_debug(field, &format_args!("{}", value)) + self.record_debug(field, &format_args!("{value}")) } } diff --git a/tracing-subscriber/src/fmt/writer.rs b/tracing-subscriber/src/fmt/writer.rs index fcd529a563..bae070e099 100644 --- a/tracing-subscriber/src/fmt/writer.rs +++ b/tracing-subscriber/src/fmt/writer.rs @@ -675,7 +675,7 @@ impl TestWriter { impl io::Write for TestWriter { fn write(&mut self, buf: &[u8]) -> io::Result { let out_str = String::from_utf8_lossy(buf); - print!("{}", out_str); + print!("{out_str}"); Ok(buf.len()) } diff --git a/tracing-subscriber/src/registry/sharded.rs b/tracing-subscriber/src/registry/sharded.rs index 5ad789e9fb..7700c1af2c 100644 --- a/tracing-subscriber/src/registry/sharded.rs +++ b/tracing-subscriber/src/registry/sharded.rs @@ -317,8 +317,7 @@ impl Collect for Registry { let refs = span.ref_count.fetch_add(1, Ordering::Relaxed); assert_ne!( refs, 0, - "tried to clone a span ({:?}) that already closed", - id + "tried to clone a span ({id:?}) that already closed" ); id.clone() } @@ -614,13 +613,12 @@ mod tests { span } else { println!( - "span {:?} did not exist in `on_close`, are we panicking?", - id + "span {id:?} did not exist in `on_close`, are we panicking?" ); return; }; let name = span.name(); - println!("close {} ({:?})", name, id); + println!("close {name} ({id:?})"); if let Ok(mut lock) = self.inner.lock() { if let Some(is_removed) = lock.open.remove(name) { assert!(is_removed.upgrade().is_some()); @@ -723,8 +721,7 @@ mod tests { assert_eq!( last, span.as_ref(), - "expected {:?} to have closed last", - span + "expected {span:?} to have closed last" ); } diff --git a/tracing-subscriber/tests/multiple_subscriber_filter_interests_cached.rs b/tracing-subscriber/tests/multiple_subscriber_filter_interests_cached.rs index ef1223785b..d8b006f637 100644 --- a/tracing-subscriber/tests/multiple_subscriber_filter_interests_cached.rs +++ b/tracing-subscriber/tests/multiple_subscriber_filter_interests_cached.rs @@ -79,8 +79,7 @@ fn multiple_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the INFO subscriber (after first set of events)", - level + "level {level:?} should have been seen 1 time by the INFO subscriber (after first set of events)" ); } @@ -91,8 +90,7 @@ fn multiple_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the WARN subscriber (after first set of events)", - level + "level {level:?} should have been seen 1 time by the WARN subscriber (after first set of events)" ); } } @@ -106,8 +104,7 @@ fn multiple_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the INFO subscriber (after second set of events)", - level + "level {level:?} should have been seen 1 time by the INFO subscriber (after second set of events)" ); } @@ -118,8 +115,7 @@ fn multiple_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the WARN subscriber (after second set of events)", - level + "level {level:?} should have been seen 1 time by the WARN subscriber (after second set of events)" ); } } diff --git a/tracing-subscriber/tests/option.rs b/tracing-subscriber/tests/option.rs index 92585e700b..b982d1b9e9 100644 --- a/tracing-subscriber/tests/option.rs +++ b/tracing-subscriber/tests/option.rs @@ -66,8 +66,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), None, - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // The `None`-returning layer still wins @@ -77,8 +76,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::ERROR), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // Check that we aren't doing anything truly wrong @@ -88,8 +86,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // Test that per-subscriber filters aren't affected @@ -101,8 +98,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), None, - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // The max-levels wins @@ -112,8 +108,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // Test filter on the other layer @@ -123,8 +118,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); let subscriber = tracing_subscriber::registry() .with(BasicLayer(None).with_filter(LevelFilter::DEBUG)) @@ -132,8 +126,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // The `OFF` from `None` over overridden. @@ -143,8 +136,7 @@ fn none_outside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::INFO), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); } @@ -158,8 +150,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), None, - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // The `None`-returning layer still wins @@ -169,8 +160,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::ERROR), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // Check that we aren't doing anything truly wrong @@ -180,8 +170,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // Test that per-subscriber filters aren't affected @@ -193,8 +182,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), None, - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // The max-levels wins @@ -204,8 +192,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // Test filter on the other layer @@ -215,8 +202,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); let subscriber = tracing_subscriber::registry() .with(None::) @@ -224,8 +210,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::DEBUG), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); // The `OFF` from `None` over overridden. @@ -235,8 +220,7 @@ fn none_inside_doesnt_override_max_level() { assert_eq!( subscriber.max_level_hint(), Some(LevelFilter::INFO), - "\n stack: {:#?}", - subscriber + "\n stack: {subscriber:#?}" ); } diff --git a/tracing-subscriber/tests/registry_with_subscriber.rs b/tracing-subscriber/tests/registry_with_subscriber.rs index efe0fb1bb0..f7e278664e 100644 --- a/tracing-subscriber/tests/registry_with_subscriber.rs +++ b/tracing-subscriber/tests/registry_with_subscriber.rs @@ -13,7 +13,7 @@ async fn future_with_subscriber() { async { async { let span = tracing::Span::current(); - println!("{:?}", span); + println!("{span:?}"); } .instrument(tracing::info_span!("hi")) .await diff --git a/tracing-subscriber/tests/reload.rs b/tracing-subscriber/tests/reload.rs index 58b75c01fb..a4571f6f72 100644 --- a/tracing-subscriber/tests/reload.rs +++ b/tracing-subscriber/tests/reload.rs @@ -67,12 +67,12 @@ fn reload_handle() { impl tracing_subscriber::Subscribe for Filter { fn register_callsite(&self, m: &Metadata<'_>) -> Interest { - println!("REGISTER: {:?}", m); + println!("REGISTER: {m:?}"); Interest::sometimes() } fn enabled(&self, m: &Metadata<'_>, _: subscribe::Context<'_, S>) -> bool { - println!("ENABLED: {:?}", m); + println!("ENABLED: {m:?}"); match self { Filter::One => FILTER1_CALLS.fetch_add(1, Ordering::SeqCst), Filter::Two => FILTER2_CALLS.fetch_add(1, Ordering::SeqCst), @@ -123,7 +123,7 @@ fn reload_filter() { impl tracing_subscriber::subscribe::Filter for Filter { fn enabled(&self, m: &Metadata<'_>, _: &subscribe::Context<'_, S>) -> bool { - println!("ENABLED: {:?}", m); + println!("ENABLED: {m:?}"); match self { Filter::One => FILTER1_CALLS.fetch_add(1, Ordering::SeqCst), Filter::Two => FILTER2_CALLS.fetch_add(1, Ordering::SeqCst), diff --git a/tracing-subscriber/tests/subscriber_filter_interests_are_cached.rs b/tracing-subscriber/tests/subscriber_filter_interests_are_cached.rs index 83df726ba2..94d22d4eba 100644 --- a/tracing-subscriber/tests/subscriber_filter_interests_are_cached.rs +++ b/tracing-subscriber/tests/subscriber_filter_interests_are_cached.rs @@ -45,8 +45,7 @@ fn subscriber_filter_interests_are_cached() { for (callsite, &count) in lock.iter() { assert_eq!( count, 1, - "callsite {:?} should have been seen 1 time (after first set of events)", - callsite + "callsite {callsite:?} should have been seen 1 time (after first set of events)" ); } } @@ -57,8 +56,7 @@ fn subscriber_filter_interests_are_cached() { for (callsite, &count) in lock.iter() { assert_eq!( count, 1, - "callsite {:?} should have been seen 1 time (after second set of events)", - callsite + "callsite {callsite:?} should have been seen 1 time (after second set of events)" ); } } diff --git a/tracing-subscriber/tests/subscriber_filters/filter_scopes.rs b/tracing-subscriber/tests/subscriber_filters/filter_scopes.rs index 68dfab6d03..21476538b4 100644 --- a/tracing-subscriber/tests/subscriber_filters/filter_scopes.rs +++ b/tracing-subscriber/tests/subscriber_filters/filter_scopes.rs @@ -81,7 +81,7 @@ fn filters_span_scopes() { #[test] fn filters_interleaved_span_scopes() { fn target_subscriber(target: &'static str) -> (MockSubscriber, collector::MockHandle) { - subscriber::named(format!("target_{}", target)) + subscriber::named(format!("target_{target}")) .enter(expect::span().with_target(target)) .enter(expect::span().with_target(target)) .event( diff --git a/tracing-subscriber/tests/subscriber_filters/trees.rs b/tracing-subscriber/tests/subscriber_filters/trees.rs index 486be8cbb1..9715582042 100644 --- a/tracing-subscriber/tests/subscriber_filters/trees.rs +++ b/tracing-subscriber/tests/subscriber_filters/trees.rs @@ -68,7 +68,7 @@ fn basic_trees() { #[test] fn filter_span_scopes() { fn target_subscriber(target: &'static str) -> (MockSubscriber, collector::MockHandle) { - subscriber::named(format!("target_{}", target)) + subscriber::named(format!("target_{target}")) .enter(expect::span().with_target(target).at_level(Level::INFO)) .event( expect::event() diff --git a/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs b/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs index a5eaa051c3..6c36e55fad 100644 --- a/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs +++ b/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs @@ -68,8 +68,7 @@ fn vec_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the INFO subscriber (after first set of events)", - level + "level {level:?} should have been seen 1 time by the INFO subscriber (after first set of events)" ); } @@ -80,8 +79,7 @@ fn vec_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the WARN subscriber (after first set of events)", - level + "level {level:?} should have been seen 1 time by the WARN subscriber (after first set of events)" ); } } @@ -95,8 +93,7 @@ fn vec_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the INFO subscriber (after second set of events)", - level + "level {level:?} should have been seen 1 time by the INFO subscriber (after second set of events)" ); } @@ -107,8 +104,7 @@ fn vec_subscriber_filter_interests_are_cached() { } assert_eq!( count, 1, - "level {:?} should have been seen 1 time by the WARN subscriber (after second set of events)", - level + "level {level:?} should have been seen 1 time by the WARN subscriber (after second set of events)" ); } } diff --git a/tracing/benches/shared.rs b/tracing/benches/shared.rs index d0cdbb8ed1..736851cfca 100644 --- a/tracing/benches/shared.rs +++ b/tracing/benches/shared.rs @@ -86,7 +86,7 @@ struct Visitor<'a>(MutexGuard<'a, String>); impl<'a> field::Visit for Visitor<'a> { fn record_debug(&mut self, _field: &field::Field, value: &dyn fmt::Debug) { - let _ = write!(&mut *self.0, "{:?}", value); + let _ = write!(&mut *self.0, "{value:?}"); } } diff --git a/tracing/tests/event.rs b/tracing/tests/event.rs index d40a7778ae..24e23f8f61 100644 --- a/tracing/tests/event.rs +++ b/tracing/tests/event.rs @@ -180,7 +180,7 @@ fn moved_field() { .run_with_handle(); with_default(collector, || { let from = "my event"; - tracing::event!(Level::INFO, foo = display(format!("hello from {}", from))) + tracing::event!(Level::INFO, foo = display(format!("hello from {from}"))) }); handle.assert_finished(); @@ -222,7 +222,7 @@ fn borrowed_field() { .run_with_handle(); with_default(collector, || { let from = "my event"; - let mut message = format!("hello from {}", from); + let mut message = format!("hello from {from}"); tracing::event!(Level::INFO, foo = display(&message)); message.push_str(", which happened!"); }); diff --git a/tracing/tests/span.rs b/tracing/tests/span.rs index bc0798f162..26a30c7a28 100644 --- a/tracing/tests/span.rs +++ b/tracing/tests/span.rs @@ -359,7 +359,7 @@ fn moved_field() { let span = tracing::span!( Level::TRACE, "foo", - bar = display(format!("hello from {}", from)) + bar = display(format!("hello from {from}")) ); span.in_scope(|| {}); }); @@ -404,7 +404,7 @@ fn borrowed_field() { with_default(collector, || { let from = "my span"; - let mut message = format!("hello from {}", from); + let mut message = format!("hello from {from}"); let span = tracing::span!(Level::TRACE, "foo", bar = display(&message)); span.in_scope(|| { message.insert_str(10, " inside");