From 5a05b614bf3c837f0984ff3a1d6d3e357ac6d1bd Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 28 Apr 2022 16:15:18 +1000 Subject: [PATCH] Tweak `print_attr_item`. This commit rearranges the `match`. The new code avoids testing for `MacArgs::Eq` twice, at the cost of repeating the `self.print_path()` call. I think this is worthwhile because it puts the `match` in a more standard and readable form. --- compiler/rustc_ast_pretty/src/pprust/state.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index a2ebe3048ce..c41de17212d 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -469,14 +469,15 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere true, span, ), - MacArgs::Empty | MacArgs::Eq(..) => { + MacArgs::Empty => { self.print_path(&item.path, false, 0); - if let MacArgs::Eq(_, token) = &item.args { - self.space(); - self.word_space("="); - let token_str = self.token_to_string_ext(token, true); - self.word(token_str); - } + } + MacArgs::Eq(_, token) => { + self.print_path(&item.path, false, 0); + self.space(); + self.word_space("="); + let token_str = self.token_to_string_ext(token, true); + self.word(token_str); } } self.end();