Improve is_doc_keyword
.
This is part of the implementation of `#[doc(keyword = "match")]` attributes used by `std` to provide documentation for keywords. `is_doc_keyword` currently does a crude keyword range test that's intended to catch all keywords but misses `kw::Yeet`. This commit changes it to use `Symbol` methods, including the new `is_weak` method (required for `union`). `Symbol` methods are much less prone to falling out of date if new keywords are added.
This commit is contained in:
parent
9fb0defa52
commit
929749d801
2 changed files with 7 additions and 3 deletions
|
@ -131,7 +131,7 @@ symbols! {
|
|||
// tidy-alphabetical-end
|
||||
|
||||
// Weak keywords, have special meaning only in specific contexts.
|
||||
// Matching predicates: none
|
||||
// Matching predicates: `is_weak`
|
||||
// tidy-alphabetical-start
|
||||
Auto: "auto",
|
||||
Builtin: "builtin",
|
||||
|
@ -2725,6 +2725,10 @@ impl Symbol {
|
|||
|| self.is_unused_keyword_conditional(edition)
|
||||
}
|
||||
|
||||
pub fn is_weak(self) -> bool {
|
||||
self >= kw::Auto && self <= kw::Yeet
|
||||
}
|
||||
|
||||
/// A keyword or reserved identifier that can be used as a path segment.
|
||||
pub fn is_path_segment_keyword(self) -> bool {
|
||||
self == kw::Super
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue