diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-28 16:15:18 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-29 15:00:32 +1000 |
| commit | 5a05b614bf3c837f0984ff3a1d6d3e357ac6d1bd (patch) | |
| tree | 1cf27e5a9f465184a337bd2856c6c280797a2f34 | |
| parent | baaa3b682986879c7784b5733ecea942e9ae7de3 (diff) | |
| download | rust-5a05b614bf3c837f0984ff3a1d6d3e357ac6d1bd.tar.gz rust-5a05b614bf3c837f0984ff3a1d6d3e357ac6d1bd.zip | |
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.
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 15 |
1 files 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<Target = pp::Printer> + 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(); |
