Skip to content

Commit adbf517

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 8b8378d commit adbf517

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
@@ -355,7 +355,7 @@ pub enum TokenKind {
355355
/// `||`
356356
OrOr,
357357
/// `!`
358-
Not,
358+
Bang,
359359
/// `~`
360360
Tilde,
361361
// `+`
@@ -517,7 +517,7 @@ impl TokenKind {
517517
Some(match (self, n) {
518518
(Le, 1) => (Lt, Eq),
519519
(EqEq, 1) => (Eq, Eq),
520-
(Ne, 1) => (Not, Eq),
520+
(Ne, 1) => (Bang, Eq),
521521
(Ge, 1) => (Gt, Eq),
522522
(AndAnd, 1) => (And, And),
523523
(OrOr, 1) => (Or, Or),
@@ -599,7 +599,7 @@ impl Token {
599599

600600
pub fn is_punct(&self) -> bool {
601601
match self.kind {
602-
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | Plus | Minus
602+
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Bang | Tilde | Plus | Minus
603603
| Star | Slash | Percent | Caret | And | Or | Shl | Shr | PlusEq | MinusEq | StarEq
604604
| SlashEq | PercentEq | CaretEq | AndEq | OrEq | ShlEq | ShrEq | At | Dot | DotDot
605605
| DotDotDot | DotDotEq | Comma | Semi | Colon | PathSep | RArrow | LArrow
@@ -625,7 +625,7 @@ impl Token {
625625
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
626626
OpenDelim(Parenthesis | Brace | Bracket) | // tuple, array or block
627627
Literal(..) | // literal
628-
Not | // operator not
628+
Bang | // operator not
629629
Minus | // unary minus
630630
Star | // dereference
631631
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
@@ -1007,8 +1007,8 @@ impl Token {
10071007
(Gt, Ge) => ShrEq,
10081008
(Gt, _) => return None,
10091009

1010-
(Not, Eq) => Ne,
1011-
(Not, _) => return None,
1010+
(Bang, Eq) => Ne,
1011+
(Bang, _) => return None,
10121012

10131013
(Plus, Eq) => PlusEq,
10141014
(Plus, _) => return None,

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ impl TokenStream {
655655
if attr_style == AttrStyle::Inner {
656656
vec![
657657
TokenTree::token_joint(token::Pound, span),
658-
TokenTree::token_joint_hidden(token::Not, span),
658+
TokenTree::token_joint_hidden(token::Bang, span),
659659
body,
660660
]
661661
} 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
@@ -892,7 +892,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
892892
token::Ne => "!=".into(),
893893
token::Ge => ">=".into(),
894894
token::Gt => ">".into(),
895-
token::Not => "!".into(),
895+
token::Bang => "!".into(),
896896
token::Tilde => "~".into(),
897897
token::OrOr => "||".into(),
898898
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
@@ -691,7 +691,7 @@ fn has_compile_error_macro(rhs: &mbe::TokenTree) -> bool {
691691
&& let TokenKind::Ident(ident, _) = ident.kind
692692
&& ident == sym::compile_error
693693
&& let mbe::TokenTree::Token(bang) = bang
694-
&& let TokenKind::Not = bang.kind
694+
&& let TokenKind::Bang = bang.kind
695695
&& let mbe::TokenTree::Delimited(.., del) = args
696696
&& !del.delim.skip()
697697
{

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
@@ -128,7 +128,7 @@ impl<'a> Parser<'a> {
128128
assert!(this.eat(exp!(Pound)), "parse_attribute called in non-attribute position");
129129

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

133133
this.expect(exp!(OpenBracket))?;
134134
let item = this.parse_attr_item(ForceCollect::No)?;
@@ -305,7 +305,7 @@ impl<'a> Parser<'a> {
305305
loop {
306306
let start_pos = self.num_bump_calls;
307307
// Only try to parse if it is an inner attribute (has `!`).
308-
let attr = if self.check(exp!(Pound)) && self.look_ahead(1, |t| t == &token::Not) {
308+
let attr = if self.check(exp!(Pound)) && self.look_ahead(1, |t| t == &token::Bang) {
309309
Some(self.parse_attribute(InnerAttrPolicy::Permitted)?)
310310
} else if let token::DocComment(comment_kind, attr_style, data) = self.token.kind {
311311
if attr_style == ast::AttrStyle::Inner {

0 commit comments

Comments
 (0)