Skip to content

Commit

Permalink
Rename is_special/is_special_ident as is_reserved_ident.
Browse files Browse the repository at this point in the history
Because "special" isn't a term used anywhere else, but "reserved
identifier" is. (E.g. in error messages.)
  • Loading branch information
nnethercote committed Dec 16, 2024
1 parent b5933c8 commit af44a52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ impl Token {
}

/// Returns true for reserved identifiers.
pub fn is_special_ident(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_special)
pub fn is_reserved_ident(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_reserved_ident)
}

/// Returns `true` if the token is a keyword used in the language.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ pub(super) enum TokenDescription {
impl TokenDescription {
pub(super) fn from_token(token: &Token) -> Option<Self> {
match token.kind {
_ if token.is_special_ident() => Some(TokenDescription::ReservedIdentifier),
_ if token.is_reserved_ident() => Some(TokenDescription::ReservedIdentifier),
_ if token.is_used_keyword() => Some(TokenDescription::Keyword),
_ if token.is_unused_keyword() => Some(TokenDescription::ReservedKeyword),
token::DocComment(..) => Some(TokenDescription::DocComment),
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod tests;

// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
symbols! {
// If you modify this list, adjust `is_any_keyword`, `is_special`,
// If you modify this list, adjust `is_any_keyword`, `is_reserved_ident`,
// `is_used_keyword`/`is_unused_keyword` and `AllKeywords`.
// But this should rarely be necessary if the keywords are kept in alphabetic order.
Keywords {
Expand Down Expand Up @@ -2586,7 +2586,7 @@ impl Symbol {
self >= kw::As && self <= kw::Yeet
}

fn is_special(self) -> bool {
fn is_reserved_ident(self) -> bool {
self == sym::dollar_crate || self == sym::underscore
}

Expand All @@ -2608,7 +2608,7 @@ impl Symbol {
}

pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
self.is_special()
self.is_reserved_ident()
|| self.is_used_keyword_always()
|| self.is_unused_keyword_always()
|| self.is_used_keyword_conditional(edition)
Expand Down Expand Up @@ -2648,8 +2648,8 @@ impl Ident {
}

/// Returns `true` for reserved identifiers.
pub fn is_special(self) -> bool {
self.name.is_special()
pub fn is_reserved_ident(self) -> bool {
self.name.is_reserved_ident()
}

/// Returns `true` if the token is a keyword used in the language.
Expand Down

0 comments on commit af44a52

Please sign in to comment.