Skip to content

Commit 53167c0

Browse files
committed
Rename ast::TokenKind::Not as ast::TokenKind::Bang.
For consistency with `rustc_lexer::TokenKind::Bang`, and because other `ast::TokenKind` variants generally have syntactic names instead of semantic names (e.g. `Star` and `DotDot` instead of `Mul` and `Range`).
1 parent 2a1e2e9 commit 53167c0

File tree

20 files changed

+48
-48
lines changed

20 files changed

+48
-48
lines changed

compiler/rustc_ast/src/token.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ pub enum TokenKind {
360360
/// `||`
361361
OrOr,
362362
/// `!`
363-
Not,
363+
Bang,
364364
/// `~`
365365
Tilde,
366366
// `+`
@@ -522,7 +522,7 @@ impl TokenKind {
522522
Some(match (self, n) {
523523
(Le, 1) => (Lt, Eq),
524524
(EqEq, 1) => (Eq, Eq),
525-
(Ne, 1) => (Not, Eq),
525+
(Ne, 1) => (Bang, Eq),
526526
(Ge, 1) => (Gt, Eq),
527527
(AndAnd, 1) => (And, And),
528528
(OrOr, 1) => (Or, Or),
@@ -604,7 +604,7 @@ impl Token {
604604

605605
pub fn is_punct(&self) -> bool {
606606
match self.kind {
607-
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | Plus | Minus
607+
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Bang | Tilde | Plus | Minus
608608
| Star | Slash | Percent | Caret | And | Or | Shl | Shr | PlusEq | MinusEq | StarEq
609609
| SlashEq | PercentEq | CaretEq | AndEq | OrEq | ShlEq | ShrEq | At | Dot | DotDot
610610
| DotDotDot | DotDotEq | Comma | Semi | Colon | PathSep | RArrow | LArrow
@@ -630,7 +630,7 @@ impl Token {
630630
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
631631
OpenDelim(Parenthesis | Brace | Bracket) | // tuple, array or block
632632
Literal(..) | // literal
633-
Not | // operator not
633+
Bang | // operator not
634634
Minus | // unary minus
635635
Star | // dereference
636636
Or | OrOr | // closure
@@ -701,7 +701,7 @@ impl Token {
701701
ident_can_begin_type(name, self.span, is_raw), // type name or keyword
702702
OpenDelim(Delimiter::Parenthesis) | // tuple
703703
OpenDelim(Delimiter::Bracket) | // array
704-
Not | // never
704+
Bang | // never
705705
Star | // raw pointer
706706
And | // reference
707707
AndAnd | // double reference
@@ -1004,8 +1004,8 @@ impl Token {
10041004
(Gt, Ge) => ShrEq,
10051005
(Gt, _) => return None,
10061006

1007-
(Not, Eq) => Ne,
1008-
(Not, _) => return None,
1007+
(Bang, Eq) => Ne,
1008+
(Bang, _) => return None,
10091009

10101010
(Plus, Eq) => PlusEq,
10111011
(Plus, _) => return None,

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl TokenStream {
651651
if attr_style == AttrStyle::Inner {
652652
vec![
653653
TokenTree::token_joint(token::Pound, span),
654-
TokenTree::token_joint_hidden(token::Not, span),
654+
TokenTree::token_joint_hidden(token::Bang, span),
655655
body,
656656
]
657657
} else {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
317317
(tt1, Tok(Token { kind: Comma | Semi | Dot, .. }, _)) if !is_punct(tt1) => false,
318318

319319
// IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if`
320-
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Not, .. }, _))
320+
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Bang, .. }, _))
321321
if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, IdentIsRaw::Yes) =>
322322
{
323323
false
@@ -896,7 +896,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
896896
token::Ne => "!=".into(),
897897
token::Ge => ">=".into(),
898898
token::Gt => ">".into(),
899-
token::Not => "!".into(),
899+
token::Bang => "!".into(),
900900
token::Tilde => "~".into(),
901901
token::OrOr => "||".into(),
902902
token::AndAnd => "&&".into(),

compiler/rustc_expand/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'a> StripUnconfigured<'a> {
328328

329329
// For inner attributes, we do the same thing for the `!` in `#![attr]`.
330330
let mut trees = if cfg_attr.style == AttrStyle::Inner {
331-
let Some(TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _)) =
331+
let Some(TokenTree::Token(bang_token @ Token { kind: TokenKind::Bang, .. }, _)) =
332332
orig_trees.next()
333333
else {
334334
panic!("Bad tokens for attribute {cfg_attr:?}");

compiler/rustc_expand/src/mbe/macro_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn check_nested_occurrences(
432432
}
433433
(
434434
NestedMacroState::MacroRules,
435-
&TokenTree::Token(Token { kind: TokenKind::Not, .. }),
435+
&TokenTree::Token(Token { kind: TokenKind::Bang, .. }),
436436
) => {
437437
state = NestedMacroState::MacroRulesNot;
438438
}

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ fn has_compile_error_macro(rhs: &mbe::TokenTree) -> bool {
690690
&& let TokenKind::Ident(ident, _) = ident.kind
691691
&& ident == sym::compile_error
692692
&& let mbe::TokenTree::Token(bang) = bang
693-
&& let TokenKind::Not = bang.kind
693+
&& let TokenKind::Bang = bang.kind
694694
&& let mbe::TokenTree::Delimited(.., del) = args
695695
&& !del.delim.skip()
696696
{

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
180180
Gt => op(">"),
181181
AndAnd => op("&&"),
182182
OrOr => op("||"),
183-
Not => op("!"),
183+
Bang => op("!"),
184184
Tilde => op("~"),
185185
Plus => op("+"),
186186
Minus => op("-"),
@@ -322,7 +322,7 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>>
322322
b'=' => Eq,
323323
b'<' => Lt,
324324
b'>' => Gt,
325-
b'!' => Not,
325+
b'!' => Bang,
326326
b'~' => Tilde,
327327
b'+' => Plus,
328328
b'-' => Minus,

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
384384
rustc_lexer::TokenKind::Colon => token::Colon,
385385
rustc_lexer::TokenKind::Dollar => token::Dollar,
386386
rustc_lexer::TokenKind::Eq => token::Eq,
387-
rustc_lexer::TokenKind::Bang => token::Not,
387+
rustc_lexer::TokenKind::Bang => token::Bang,
388388
rustc_lexer::TokenKind::Lt => token::Lt,
389389
rustc_lexer::TokenKind::Gt => token::Gt,
390390
rustc_lexer::TokenKind::Minus => token::Minus,

compiler/rustc_parse/src/lexer/unicode_chars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ const ASCII_ARRAY: &[(&str, &str, Option<token::TokenKind>)] = &[
312312
(",", "Comma", Some(token::Comma)),
313313
(";", "Semicolon", Some(token::Semi)),
314314
(":", "Colon", Some(token::Colon)),
315-
("!", "Exclamation Mark", Some(token::Not)),
315+
("!", "Exclamation Mark", Some(token::Bang)),
316316
("?", "Question Mark", Some(token::Question)),
317317
(".", "Period", Some(token::Dot)),
318318
("(", "Left Parenthesis", Some(token::OpenDelim(Delimiter::Parenthesis))),

compiler/rustc_parse/src/parser/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a> Parser<'a> {
130130
assert!(this.eat(exp!(Pound)), "parse_attribute called in non-attribute position");
131131

132132
let style =
133-
if this.eat(exp!(Not)) { ast::AttrStyle::Inner } else { ast::AttrStyle::Outer };
133+
if this.eat(exp!(Bang)) { ast::AttrStyle::Inner } else { ast::AttrStyle::Outer };
134134

135135
this.expect(exp!(OpenBracket))?;
136136
let item = this.parse_attr_item(ForceCollect::No)?;
@@ -312,7 +312,7 @@ impl<'a> Parser<'a> {
312312
loop {
313313
let start_pos = self.num_bump_calls;
314314
// Only try to parse if it is an inner attribute (has `!`).
315-
let attr = if self.check(exp!(Pound)) && self.look_ahead(1, |t| t == &token::Not) {
315+
let attr = if self.check(exp!(Pound)) && self.look_ahead(1, |t| t == &token::Bang) {
316316
Some(self.parse_attribute(InnerAttrPolicy::Permitted)?)
317317
} else if let token::DocComment(comment_kind, attr_style, data) = self.token.kind {
318318
if attr_style == ast::AttrStyle::Inner {

0 commit comments

Comments
 (0)