Skip to content

Commit c70c646

Browse files
committed
Eliminate string comparison from rustdoc keyword spacing logic
1 parent aff5296 commit c70c646

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

src/librustdoc/clean/render_macro_matchers.rs

+33-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust::PrintState;
55
use rustc_middle::ty::TyCtxt;
66
use rustc_session::parse::ParseSess;
77
use rustc_span::source_map::FilePathMapping;
8-
use rustc_span::symbol::Symbol;
8+
use rustc_span::symbol::{kw, Symbol};
99

1010
/// Render a macro matcher in a format suitable for displaying to the user
1111
/// as part of an item declaration.
@@ -181,11 +181,38 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) {
181181
// `f(0)` (no space between ident and paren) from tokens resembling `if let (0,
182182
// 0) = x` (space between ident and paren).
183183
fn usually_needs_space_between_keyword_and_open_delim(symbol: Symbol) -> bool {
184-
match symbol.as_str() {
185-
"as" | "box" | "break" | "const" | "continue" | "crate" | "else" | "enum" | "extern"
186-
| "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" | "mod" | "move"
187-
| "mut" | "ref" | "return" | "static" | "struct" | "trait" | "type" | "unsafe" | "use"
188-
| "where" | "while" | "yield" => true,
184+
match symbol {
185+
kw::As
186+
| kw::Box
187+
| kw::Break
188+
| kw::Const
189+
| kw::Continue
190+
| kw::Crate
191+
| kw::Else
192+
| kw::Enum
193+
| kw::Extern
194+
| kw::For
195+
| kw::If
196+
| kw::Impl
197+
| kw::In
198+
| kw::Let
199+
| kw::Loop
200+
| kw::Macro
201+
| kw::Match
202+
| kw::Mod
203+
| kw::Move
204+
| kw::Mut
205+
| kw::Ref
206+
| kw::Return
207+
| kw::Static
208+
| kw::Struct
209+
| kw::Trait
210+
| kw::Type
211+
| kw::Unsafe
212+
| kw::Use
213+
| kw::Where
214+
| kw::While
215+
| kw::Yield => true,
189216
_ => false,
190217
}
191218
}

0 commit comments

Comments
 (0)