From: David Tolnay Date: Fri, 14 Jan 2022 22:38:15 +0000 (-0800) Subject: Eliminate string comparison from rustdoc keyword spacing logic X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=c70c646a0f7d7e9a1a481d5ae5b26b140cfd4cf2;hp=aff5296c78438759f9ea2b6d6f24ddab25d05407;p=rust.git Eliminate string comparison from rustdoc keyword spacing logic --- 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_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 @@ enum State { // `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, } }