From 9fecdbd23b7b14eb615223192e76fbea8a79a24c Mon Sep 17 00:00:00 2001 From: Xiami <1927254+Xiami2012@users.noreply.github.com> Date: Sat, 17 Sep 2022 04:39:07 +0800 Subject: [PATCH] tracing: add `dyn` keyword for trait objects in `valueset!` expansion (#2308) ## Motivation `bare_trait_objects` lint will become a hard error in Rust 2021. While tracing is still using Rust 2018, `bare_trait_objects` is a warning in the MSRV and `dyn` keyword is recommended. ## Solution Replace all `&Value` with `&dyn Value` in macro expansions. --- tracing/src/macros.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tracing/src/macros.rs b/tracing/src/macros.rs index b134af6e81..f3968e5c11 100644 --- a/tracing/src/macros.rs +++ b/tracing/src/macros.rs @@ -2193,79 +2193,79 @@ macro_rules! valueset { // }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = ?$val:expr, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = %$val:expr, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&display(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = $val:expr, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&$val as &Value)) }, + @ { $($out),*, (&$next, Some(&$val as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&$($k).+ as &Value)) }, + @ { $($out),*, (&$next, Some(&$($k).+ as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, ?$($k:ident).+, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &Value)) }, + @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, %$($k:ident).+, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&display(&$($k).+) as &Value)) }, + @ { $($out),*, (&$next, Some(&display(&$($k).+) as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = ?$val:expr) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = %$val:expr) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&display(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = $val:expr) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&$val as &Value)) }, + @ { $($out),*, (&$next, Some(&$val as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&$($k).+ as &Value)) }, + @ { $($out),*, (&$next, Some(&$($k).+ as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, ?$($k:ident).+) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &Value)) }, + @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, %$($k:ident).+) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&display(&$($k).+) as &Value)) }, + @ { $($out),*, (&$next, Some(&display(&$($k).+) as &dyn Value)) }, $next, ) }; @@ -2273,47 +2273,47 @@ macro_rules! valueset { // Handle literal names (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = ?$val:expr, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = %$val:expr, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&display(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = $val:expr, $($rest:tt)*) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&$val as &Value)) }, + @ { $($out),*, (&$next, Some(&$val as &dyn Value)) }, $next, $($rest)* ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = ?$val:expr) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = %$val:expr) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&display(&$val) as &Value)) }, + @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) }, $next, ) }; (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = $val:expr) => { $crate::valueset!( - @ { $($out),*, (&$next, Some(&$val as &Value)) }, + @ { $($out),*, (&$next, Some(&$val as &dyn Value)) }, $next, ) }; // Remainder is unparseable, but exists --- must be format args! (@ { $(,)* $($out:expr),* }, $next:expr, $($rest:tt)+) => { - $crate::valueset!(@ { (&$next, Some(&format_args!($($rest)+) as &Value)), $($out),* }, $next, ) + $crate::valueset!(@ { (&$next, Some(&format_args!($($rest)+) as &dyn Value)), $($out),* }, $next, ) }; // === entry ===