From 6ea1dacc2b1f2f48853efed8b4fa2ab079514ca8 Mon Sep 17 00:00:00 2001 From: Cj Longoria Date: Mon, 25 Aug 2025 18:04:36 -0700 Subject: [PATCH] Edition 2024 cleanup: rename `expr_2021` -> `expr` (#949) Summary: This renames `expr_2021` to `expr` for rust macros. The `expr_2021` was used during the Rust Edition upgrade to ensure compatibility between the two editions. Now that we are using Rust Edition 2024 as the default, and none of the macros are triggering a build failure with this rename, we can rename this back to `expr` Reviewed By: diliop Differential Revision: D80508019 --- hyperactor/src/data.rs | 2 +- hyperactor/src/parse.rs | 4 ++-- hyperactor/src/reference.rs | 8 ++++---- hyperactor_mesh/src/actor_mesh.rs | 2 +- hyperactor_mesh/src/alloc.rs | 2 +- hyperactor_mesh/src/lib.rs | 2 +- hyperactor_telemetry/src/lib.rs | 16 ++++++++-------- ndslice/src/reshape.rs | 2 +- ndslice/src/selection.rs | 6 +++--- ndslice/src/selection/parse.rs | 2 +- ndslice/src/selection/routing.rs | 8 ++++---- ndslice/src/selection/test_utils.rs | 4 ++-- ndslice/src/shape.rs | 6 +++--- ndslice/src/view.rs | 2 +- torch-sys/src/ivalue.rs | 4 ++-- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/hyperactor/src/data.rs b/hyperactor/src/data.rs index 197b1252e..84a7018db 100644 --- a/hyperactor/src/data.rs +++ b/hyperactor/src/data.rs @@ -131,7 +131,7 @@ impl Named for bytes::Bytes { #[doc(hidden)] // not part of the public API #[macro_export] macro_rules! intern_typename { - ($key:ty, $format_string:expr_2021, $($args:ty),+) => { + ($key:ty, $format_string:expr, $($args:ty),+) => { { static CACHE: std::sync::LazyLock<$crate::dashmap::DashMap> = std::sync::LazyLock::new($crate::dashmap::DashMap::new); diff --git a/hyperactor/src/parse.rs b/hyperactor/src/parse.rs index 49fbec2d0..63aa72d05 100644 --- a/hyperactor/src/parse.rs +++ b/hyperactor/src/parse.rs @@ -104,9 +104,9 @@ impl<'a> Iterator for Lexer<'a> { // TODO: improve error reporting here macro_rules! parse { ( - $token_stream:expr_2021; + $token_stream:expr; $( - $($pattern:pat_param)* => $constructor:expr_2021 + $($pattern:pat_param)* => $constructor:expr ),* $(,)? ) => { { diff --git a/hyperactor/src/reference.rs b/hyperactor/src/reference.rs index be8723be8..900a1de00 100644 --- a/hyperactor/src/reference.rs +++ b/hyperactor/src/reference.rs @@ -253,13 +253,13 @@ macro_rules! id { ($world:ident) => { $crate::reference::WorldId(stringify!($world).to_string()) }; - ($world:ident [$rank:expr_2021]) => { + ($world:ident [$rank:expr]) => { $crate::reference::ProcId::Ranked( $crate::reference::WorldId(stringify!($world).to_string()), $rank, ) }; - ($world:ident [$rank:expr_2021] . $actor:ident) => { + ($world:ident [$rank:expr] . $actor:ident) => { $crate::reference::ActorId( $crate::reference::ProcId::Ranked( $crate::reference::WorldId(stringify!($world).to_string()), @@ -269,7 +269,7 @@ macro_rules! id { 0, ) }; - ($world:ident [$rank:expr_2021] . $actor:ident [$pid:expr_2021]) => { + ($world:ident [$rank:expr] . $actor:ident [$pid:expr]) => { $crate::reference::ActorId( $crate::reference::ProcId::Ranked( $crate::reference::WorldId(stringify!($world).to_string()), @@ -285,7 +285,7 @@ macro_rules! id { stringify!($actor).to_string(), ) }; - ($world:ident [$rank:expr_2021] . $actor:ident [$pid:expr_2021] [$port:expr_2021]) => { + ($world:ident [$rank:expr] . $actor:ident [$pid:expr] [$port:expr]) => { $crate::reference::PortId( $crate::reference::ActorId( $crate::reference::ProcId::Ranked( diff --git a/hyperactor_mesh/src/actor_mesh.rs b/hyperactor_mesh/src/actor_mesh.rs index 1bbbc5be7..f84cf9bc1 100644 --- a/hyperactor_mesh/src/actor_mesh.rs +++ b/hyperactor_mesh/src/actor_mesh.rs @@ -668,7 +668,7 @@ mod tests { // These tests are parametric over allocators. #[macro_export] macro_rules! actor_mesh_test_suite { - ($allocator:expr_2021) => { + ($allocator:expr) => { use std::assert_matches::assert_matches; use ndslice::extent; diff --git a/hyperactor_mesh/src/alloc.rs b/hyperactor_mesh/src/alloc.rs index ae44e5167..476a1b1a4 100644 --- a/hyperactor_mesh/src/alloc.rs +++ b/hyperactor_mesh/src/alloc.rs @@ -385,7 +385,7 @@ pub(crate) mod testing { #[macro_export] macro_rules! alloc_test_suite { - ($allocator:expr_2021) => { + ($allocator:expr) => { #[tokio::test] async fn test_allocator_basic() { $crate::alloc::testing::test_allocator_basic($allocator).await; diff --git a/hyperactor_mesh/src/lib.rs b/hyperactor_mesh/src/lib.rs index 97ec5fcaa..d63a6b116 100644 --- a/hyperactor_mesh/src/lib.rs +++ b/hyperactor_mesh/src/lib.rs @@ -80,7 +80,7 @@ mod tests { use ndslice::selection::Selection; macro_rules! assert_round_trip_match { - ($left:expr_2021, $right:expr_2021) => {{ + ($left:expr, $right:expr) => {{ assert_structurally_eq!($left, $right); assert_round_trip!($left); assert_round_trip!($right); diff --git a/hyperactor_telemetry/src/lib.rs b/hyperactor_telemetry/src/lib.rs index 5e31f1964..c61562810 100644 --- a/hyperactor_telemetry/src/lib.rs +++ b/hyperactor_telemetry/src/lib.rs @@ -159,7 +159,7 @@ pub fn swap_telemetry_clock(clock: impl TelemetryClock + Send + 'static) { /// so MY_COUNTER.add(42, &[key_value!("key", "value")]) and MY_COUNTER.add(42, &[key_value!("key", "other_value")]) will actually bump two separete counters. #[macro_export] macro_rules! key_value { - ($key:expr_2021, $val:expr_2021) => { + ($key:expr, $val:expr) => { $crate::opentelemetry::KeyValue::new( $crate::opentelemetry::Key::new($key), $crate::opentelemetry::Value::from($val), @@ -183,7 +183,7 @@ macro_rules! key_value { /// ``` #[macro_export] macro_rules! kv_pairs { - ($($k:expr_2021 => $v:expr_2021),* $(,)?) => { + ($($k:expr => $v:expr),* $(,)?) => { &[$($crate::key_value!($k, $v),)*] }; } @@ -260,7 +260,7 @@ impl<'a> Drop for TimerGuard<'a> { /// ``` #[macro_export] macro_rules! declare_static_timer { - ($name:ident, $key:expr_2021, $unit:path) => { + ($name:ident, $key:expr, $unit:path) => { #[doc = "a global histogram timer named: "] #[doc = $key] pub static $name: std::sync::LazyLock<$crate::Timer> = std::sync::LazyLock::new(|| { @@ -298,7 +298,7 @@ macro_rules! declare_static_timer { /// ``` #[macro_export] macro_rules! declare_static_counter { - ($name:ident, $key:expr_2021) => { + ($name:ident, $key:expr) => { #[doc = "a global counter named: "] #[doc = $key] pub static $name: std::sync::LazyLock> = @@ -329,7 +329,7 @@ macro_rules! declare_static_counter { /// ``` #[macro_export] macro_rules! declare_static_up_down_counter { - ($name:ident, $key:expr_2021) => { + ($name:ident, $key:expr) => { #[doc = "a global up down counter named: "] #[doc = $key] pub static $name: std::sync::LazyLock> = @@ -364,7 +364,7 @@ macro_rules! declare_static_up_down_counter { /// ``` #[macro_export] macro_rules! declare_static_gauge { - ($name:ident, $key:expr_2021) => { + ($name:ident, $key:expr) => { #[doc = "a global gauge named: "] #[doc = $key] pub static $name: std::sync::LazyLock> = @@ -390,7 +390,7 @@ macro_rules! declare_static_gauge { /// ``` #[macro_export] macro_rules! declare_observable_gauge { - ($name:ident, $key:expr_2021, $cb:expr_2021) => { + ($name:ident, $key:expr, $cb:expr) => { #[doc = "a global gauge named: "] #[doc = $key] pub static $name: std::sync::LazyLock> = @@ -425,7 +425,7 @@ macro_rules! declare_observable_gauge { /// ``` #[macro_export] macro_rules! declare_static_histogram { - ($name:ident, $key:expr_2021) => { + ($name:ident, $key:expr) => { #[doc = "a global histogram named: "] #[doc = $key] pub static $name: std::sync::LazyLock> = diff --git a/ndslice/src/reshape.rs b/ndslice/src/reshape.rs index e9bf91a63..a14926d1d 100644 --- a/ndslice/src/reshape.rs +++ b/ndslice/src/reshape.rs @@ -402,7 +402,7 @@ mod tests { // coordinate systems. #[macro_export] macro_rules! assert_layout_preserved { - ($original:expr_2021, $reshaped:expr_2021) => {{ + ($original:expr, $reshaped:expr) => {{ // Iterate over all coordinates in the original slice. for coord in $original.dim_iter($original.num_dim()) { let forward = to_reshaped_coord($original, &$reshaped); diff --git a/ndslice/src/selection.rs b/ndslice/src/selection.rs index 897c6ccfb..1e2f0a26a 100644 --- a/ndslice/src/selection.rs +++ b/ndslice/src/selection.rs @@ -1421,18 +1421,18 @@ where /// [`selection_from`]: crate::selection::selection_from #[macro_export] macro_rules! sel_from_shape { - ($shape:expr_2021, $label:ident = $range:expr_2021) => { + ($shape:expr, $label:ident = $range:expr) => { $crate::selection::selection_from_one($shape, stringify!($label), $range).unwrap() }; - ($shape:expr_2021, $($label:ident = $val:literal),* $(,)?) => { + ($shape:expr, $($label:ident = $val:literal),* $(,)?) => { $crate::selection::selection_from($shape, &[ $((stringify!($label), $val..$val+1)),* ]).unwrap() }; - ($shape:expr_2021, $($label:ident = $range:expr_2021),* $(,)?) => { + ($shape:expr, $($label:ident = $range:expr),* $(,)?) => { $crate::selection::selection_from($shape, &[ $((stringify!($label), $range)),* ]).unwrap() diff --git a/ndslice/src/selection/parse.rs b/ndslice/src/selection/parse.rs index 33042d365..8101d697a 100644 --- a/ndslice/src/selection/parse.rs +++ b/ndslice/src/selection/parse.rs @@ -191,7 +191,7 @@ mod tests { #[macro_export] macro_rules! assert_parses_to { - ($input:expr_2021, $expected:expr_2021) => {{ + ($input:expr, $expected:expr) => {{ let actual = $crate::selection::parse::tests::parse($input); $crate::assert_structurally_eq!($expected, actual); }}; diff --git a/ndslice/src/selection/routing.rs b/ndslice/src/selection/routing.rs index f7eb38c7b..53f346892 100644 --- a/ndslice/src/selection/routing.rs +++ b/ndslice/src/selection/routing.rs @@ -894,7 +894,7 @@ mod tests { /// assert_routing_eq_with!(slice, selection, collect_routed_nodes); /// ``` macro_rules! assert_routing_eq_with { - ($slice:expr_2021, $sel:expr_2021, $collector:expr_2021) => {{ + ($slice:expr, $sel:expr, $collector:expr) => {{ let sel = $sel; let slice = $slice.clone(); let mut expected: Vec<_> = sel.eval(&EvalOpts::lenient(), &slice).unwrap().collect(); @@ -908,7 +908,7 @@ mod tests { /// Asserts that `collect_routed_nodes` matches `Selection::eval` /// on the given slice. macro_rules! assert_collect_routed_nodes_eq { - ($slice:expr_2021, $sel:expr_2021) => { + ($slice:expr, $sel:expr) => { assert_routing_eq_with!($slice, $sel, collect_routed_nodes) }; } @@ -916,7 +916,7 @@ mod tests { /// Asserts that CommActor routing delivers to the same nodes as /// `Selection::eval`. macro_rules! assert_commactor_routing_eq { - ($slice:expr_2021, $sel:expr_2021) => { + ($slice:expr, $sel:expr) => { assert_routing_eq_with!($slice, $sel, |s, sl| { collect_commactor_routing_tree(s, sl) .delivered @@ -934,7 +934,7 @@ mod tests { /// (`collect_commactor_routing_tree`) against the expected output /// from `Selection::eval`. macro_rules! assert_all_routing_strategies_eq { - ($slice:expr_2021, $sel:expr_2021) => { + ($slice:expr, $sel:expr) => { assert_collect_routed_nodes_eq!($slice, $sel); assert_commactor_routing_eq!($slice, $sel); }; diff --git a/ndslice/src/selection/test_utils.rs b/ndslice/src/selection/test_utils.rs index 3d5893a7c..b60e4cc95 100644 --- a/ndslice/src/selection/test_utils.rs +++ b/ndslice/src/selection/test_utils.rs @@ -32,7 +32,7 @@ pub fn parse(input: &str) -> Selection { #[macro_export] macro_rules! assert_structurally_eq { - ($expected:expr_2021, $actual:expr_2021) => {{ + ($expected:expr, $actual:expr) => {{ let expected = &$expected; let actual = &$actual; assert!( @@ -46,7 +46,7 @@ macro_rules! assert_structurally_eq { #[macro_export] macro_rules! assert_round_trip { - ($selection:expr_2021) => {{ + ($selection:expr) => {{ let selection: Selection = $selection; // take ownership // Convert `Selection` to representation as compact // syntax. diff --git a/ndslice/src/shape.rs b/ndslice/src/shape.rs index 1583c076d..efcd90ed3 100644 --- a/ndslice/src/shape.rs +++ b/ndslice/src/shape.rs @@ -275,7 +275,7 @@ impl fmt::Display for Shape { /// ``` #[macro_export] macro_rules! shape { - ( $( $label:ident = $size:expr_2021 ),* $(,)? ) => { + ( $( $label:ident = $size:expr ),* $(,)? ) => { { let mut labels = Vec::new(); let mut sizes = Vec::new(); @@ -303,11 +303,11 @@ macro_rules! shape { /// ``` #[macro_export] macro_rules! select { - ($shape:ident, $label:ident = $range:expr_2021) => { + ($shape:ident, $label:ident = $range:expr) => { $shape.select(stringify!($label), $range) }; - ($shape:ident, $label:ident = $range:expr_2021, $($labels:ident = $ranges:expr_2021),+) => { + ($shape:ident, $label:ident = $range:expr, $($labels:ident = $ranges:expr),+) => { $shape.select(stringify!($label), $range).and_then(|shape| $crate::select!(shape, $($labels = $ranges),+)) }; } diff --git a/ndslice/src/view.rs b/ndslice/src/view.rs index bb85945ce..0e15c18e0 100644 --- a/ndslice/src/view.rs +++ b/ndslice/src/view.rs @@ -637,7 +637,7 @@ impl ViewExt for T { /// ``` #[macro_export] macro_rules! extent { - ( $( $label:ident = $size:expr_2021 ),* $(,)? ) => { + ( $( $label:ident = $size:expr ),* $(,)? ) => { { let mut labels = Vec::new(); let mut sizes = Vec::new(); diff --git a/torch-sys/src/ivalue.rs b/torch-sys/src/ivalue.rs index 34e2217f2..76c2923f9 100644 --- a/torch-sys/src/ivalue.rs +++ b/torch-sys/src/ivalue.rs @@ -503,7 +503,7 @@ mod tests { } macro_rules! generate_py_object_roundtrip_tests { - ($($kind:ident, $input:expr_2021);* $(;)?) => { + ($($kind:ident, $input:expr);* $(;)?) => { paste! { $( #[test] @@ -552,7 +552,7 @@ mod tests { } macro_rules! generate_serde_roundtrip_tests { - ($($kind:ident, $input:expr_2021);* $(;)?) => { + ($($kind:ident, $input:expr);* $(;)?) => { paste! { $( #[test]