about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2022-01-14 14:38:15 -0800
committerDavid Tolnay <dtolnay@gmail.com>2022-01-18 11:14:41 -0800
commitc70c646a0f7d7e9a1a481d5ae5b26b140cfd4cf2 (patch)
tree6e8a9fb903561ebaaef483137e7c69c350b760b2
parentaff5296c78438759f9ea2b6d6f24ddab25d05407 (diff)
downloadrust-c70c646a0f7d7e9a1a481d5ae5b26b140cfd4cf2.tar.gz
rust-c70c646a0f7d7e9a1a481d5ae5b26b140cfd4cf2.zip
Eliminate string comparison from rustdoc keyword spacing logic
-rw-r--r--src/librustdoc/clean/render_macro_matchers.rs39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs
index 14990c2e9e6..a6faa0d6857 100644
--- a/src/librustdoc/clean/render_macro_matchers.rs
+++ b/src/librustdoc/clean/render_macro_matchers.rs
@@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust::PrintState;
 use rustc_middle::ty::TyCtxt;
 use rustc_session::parse::ParseSess;
 use rustc_span::source_map::FilePathMapping;
-use rustc_span::symbol::Symbol;
+use rustc_span::symbol::{kw, Symbol};
 
 /// Render a macro matcher in a format suitable for displaying to the user
 /// as part of an item declaration.
@@ -181,11 +181,38 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) {
 // `f(0)` (no space between ident and paren) from tokens resembling `if let (0,
 // 0) = x` (space between ident and paren).
 fn usually_needs_space_between_keyword_and_open_delim(symbol: Symbol) -> bool {
-    match symbol.as_str() {
-        "as" | "box" | "break" | "const" | "continue" | "crate" | "else" | "enum" | "extern"
-        | "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" | "mod" | "move"
-        | "mut" | "ref" | "return" | "static" | "struct" | "trait" | "type" | "unsafe" | "use"
-        | "where" | "while" | "yield" => true,
+    match symbol {
+        kw::As
+        | kw::Box
+        | kw::Break
+        | kw::Const
+        | kw::Continue
+        | kw::Crate
+        | kw::Else
+        | kw::Enum
+        | kw::Extern
+        | kw::For
+        | kw::If
+        | kw::Impl
+        | kw::In
+        | kw::Let
+        | kw::Loop
+        | kw::Macro
+        | kw::Match
+        | kw::Mod
+        | kw::Move
+        | kw::Mut
+        | kw::Ref
+        | kw::Return
+        | kw::Static
+        | kw::Struct
+        | kw::Trait
+        | kw::Type
+        | kw::Unsafe
+        | kw::Use
+        | kw::Where
+        | kw::While
+        | kw::Yield => true,
         _ => false,
     }
 }