From 57c53affe3542cb6bd4e79ee4c18f20a1bd76b2d Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 17 Aug 2026 05:49:19 +0800 Subject: refactor!: replace pack! macros with derive-based pipeline types Remove the `pack!`, `pack_err!`, `pack_structural!`, and `pack_err_structural!` macros, replacing all pipeline type definitions with `#[derive(Grouped)]` and `#[derive(Grouped, Wrap)]` attributes. This changes the generated struct shape from named-field structs with an `inner` field to tuple structs accessed via `.0`, and removes the auto-generated `name` and `info` fields from error types. --- mingling_cli/src/linter/cmd_explain.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'mingling_cli/src/linter/cmd_explain.rs') diff --git a/mingling_cli/src/linter/cmd_explain.rs b/mingling_cli/src/linter/cmd_explain.rs index 5346255..923e890 100644 --- a/mingling_cli/src/linter/cmd_explain.rs +++ b/mingling_cli/src/linter/cmd_explain.rs @@ -1,10 +1,7 @@ use crate::{Next, eprintln_cargo, linter::registry::ResLintRegistry}; use mingling::{ - Grouped, LazyRes, RenderResult, Routable, ShellContext, Suggest, SuggestItem, - macros::{ - arg, buffer, chain, completion, dispatcher, metadata, pack, pack_err, r_println, renderer, - routeify, - }, + Grouped, LazyRes, RenderResult, Routable, ShellContext, Suggest, SuggestItem, Wrap, + macros::{arg, buffer, chain, completion, dispatcher, metadata, r_println, renderer, routeify}, metadata::Description, picker::EntryPicker, }; @@ -16,9 +13,14 @@ pub fn desc_explain() -> Description { "Explain the meaning of the specified Lint".into() } -pack!(StateExplainLint = String); -pack_err!(ErrorNoExplainLintProvided); -pack_err!(ErrorNoSuchLint = String); +#[derive(Grouped, Wrap)] +pub struct StateExplainLint(String); + +#[derive(Grouped, Default)] +pub struct ErrorNoExplainLintProvided; + +#[derive(Grouped, Wrap)] +pub struct ErrorNoSuchLint(String); #[derive(Debug, Default, Grouped)] pub struct ResultExplainLint { @@ -33,11 +35,9 @@ pub struct ResultExplainLint { #[chain(routeify)] pub fn handle_explain(args: EntryExplain) -> Next { let lint_name = args - .pick_or_route(&arg![String], || { - ErrorNoExplainLintProvided::default().to_chain() - }) + .pick_or_route(&arg![String], || ErrorNoExplainLintProvided.to_chain()) .to_result()?; - StateExplainLint::new(lint_name).into() + StateExplainLint(lint_name).into() } #[chain] @@ -46,9 +46,9 @@ pub fn handle_state_explain_lint( registry: &mut LazyRes, ) -> Next { let registry = registry.get_ref(); - let lint_name = p.inner; + let lint_name = p.0; let Some(entry) = registry.lints.iter().find(|l| l.name == lint_name) else { - return ErrorNoSuchLint::new(lint_name).to_chain(); + return ErrorNoSuchLint(lint_name).to_chain(); }; ResultExplainLint { lint_name: entry.name.clone(), @@ -87,7 +87,7 @@ pub fn render_error_no_such_lint( ) -> RenderResult { let mut r = RenderResult::new(); let registry = registry.get_ref(); - eprintln_cargo!(r, "No such lint: \"{}\"", err.info); + eprintln_cargo!(r, "No such lint: \"{}\"", err.0); r_println!(r, ""); r_println!(r, "Available lints:"); for entry in registry.lints.iter() { -- cgit