From df6330009232b9b2d5617b7b186ac7ef3cbe5938 Mon Sep 17 00:00:00 2001 From: randomicon00 <20146907+randomicon00@users.noreply.github.com> Date: Tue, 11 Jun 2024 08:49:30 -0400 Subject: [PATCH 1/2] edit: change 'Length' to 'Len' --- crates/mbe/src/expander/matcher.rs | 4 ++-- crates/mbe/src/expander/transcriber.rs | 2 +- crates/mbe/src/parser.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index 78d4bfee2a..0cec4e70da 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs @@ -566,7 +566,7 @@ fn match_loop_inner<'t>( error_items.push(item); } OpDelimited::Op( - Op::Ignore { .. } | Op::Index { .. } | Op::Count { .. } | Op::Length { .. }, + Op::Ignore { .. } | Op::Index { .. } | Op::Count { .. } | Op::Len { .. }, ) => { stdx::never!("metavariable expression in lhs found"); } @@ -832,7 +832,7 @@ fn collect_vars(collector_fun: &mut impl FnMut(SmolStr), pattern: &MetaTemplate) Op::Subtree { tokens, .. } => collect_vars(collector_fun, tokens), Op::Repeat { tokens, .. } => collect_vars(collector_fun, tokens), Op::Literal(_) | Op::Ident(_) | Op::Punct(_) => {} - Op::Ignore { .. } | Op::Index { .. } | Op::Count { .. } | Op::Length { .. } => { + Op::Ignore { .. } | Op::Index { .. } | Op::Count { .. } | Op::Len { .. } => { stdx::never!("metavariable expression in lhs found"); } } diff --git a/crates/mbe/src/expander/transcriber.rs b/crates/mbe/src/expander/transcriber.rs index 5e6e45f152..0f689a2692 100644 --- a/crates/mbe/src/expander/transcriber.rs +++ b/crates/mbe/src/expander/transcriber.rs @@ -242,7 +242,7 @@ fn expand_subtree( .into(), ); } - Op::Length { depth } => { + Op::Len { depth } => { let length = ctx.nesting.get(ctx.nesting.len() - 1 - depth).map_or(0, |_nest| { // FIXME: to be implemented 0 diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index eaf2fd8c27..bbe00f0afc 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs @@ -75,7 +75,7 @@ pub(crate) enum Op { Index { depth: usize, }, - Length { + Len { depth: usize, }, Count { @@ -345,7 +345,7 @@ fn parse_metavar_expr(new_meta_vars: bool, src: &mut TtIter<'_, Span>) -> Result Op::Ignore { name: ident.text.clone(), id: ident.span } } "index" => Op::Index { depth: parse_depth(&mut args)? }, - "length" => Op::Length { depth: parse_depth(&mut args)? }, + "len" => Op::Len { depth: parse_depth(&mut args)? }, "count" => { if new_meta_vars { args.expect_dollar()?; From bcf4221ab3b725095b1156b57f6ce3520e990a0b Mon Sep 17 00:00:00 2001 From: randomicon00 <20146907+randomicon00@users.noreply.github.com> Date: Tue, 11 Jun 2024 09:09:10 -0400 Subject: [PATCH 2/2] edit: Length to Len in benchmark --- crates/mbe/src/benchmark.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs index f73e188c79..19ba5c7a15 100644 --- a/crates/mbe/src/benchmark.rs +++ b/crates/mbe/src/benchmark.rs @@ -215,7 +215,7 @@ fn invocation_fixtures( token_trees.push(subtree.into()); } - Op::Ignore { .. } | Op::Index { .. } | Op::Count { .. } | Op::Length { .. } => {} + Op::Ignore { .. } | Op::Index { .. } | Op::Count { .. } | Op::Len { .. } => {} }; // Simple linear congruential generator for deterministic result