Skip to content

Commit 54c8725

Browse files
committed
Use Symbol equality in is_ident_named.
1 parent babd1a1 commit 54c8725

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,15 +737,15 @@ impl<'a> Parser<'a> {
737737
};
738738
self.last_unexpected_token_span = Some(self.span);
739739
let mut err = self.fatal(&msg_exp);
740-
if self.token.is_ident_named("and") {
740+
if self.token.is_ident_named(sym::and) {
741741
err.span_suggestion_short(
742742
self.span,
743743
"use `&&` instead of `and` for the boolean operator",
744744
"&&".to_string(),
745745
Applicability::MaybeIncorrect,
746746
);
747747
}
748-
if self.token.is_ident_named("or") {
748+
if self.token.is_ident_named(sym::or) {
749749
err.span_suggestion_short(
750750
self.span,
751751
"use `||` instead of `or` for the boolean operator",
@@ -3269,7 +3269,7 @@ impl<'a> Parser<'a> {
32693269
let (span, e) = self.interpolated_or_expr_span(e)?;
32703270
(lo.to(span), ExprKind::Box(e))
32713271
}
3272-
token::Ident(..) if self.token.is_ident_named("not") => {
3272+
token::Ident(..) if self.token.is_ident_named(sym::not) => {
32733273
// `not` is just an ordinary identifier in Rust-the-language,
32743274
// but as `rustc`-the-compiler, we can issue clever diagnostics
32753275
// for confused users who really want to say `!`
@@ -5147,15 +5147,15 @@ impl<'a> Parser<'a> {
51475147
let do_not_suggest_help =
51485148
self.token.is_keyword(kw::In) || self.token == token::Colon;
51495149

5150-
if self.token.is_ident_named("and") {
5150+
if self.token.is_ident_named(sym::and) {
51515151
e.span_suggestion_short(
51525152
self.span,
51535153
"use `&&` instead of `and` for the boolean operator",
51545154
"&&".to_string(),
51555155
Applicability::MaybeIncorrect,
51565156
);
51575157
}
5158-
if self.token.is_ident_named("or") {
5158+
if self.token.is_ident_named(sym::or) {
51595159
e.span_suggestion_short(
51605160
self.span,
51615161
"use `||` instead of `or` for the boolean operator",

src/libsyntax/parse/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ impl Token {
391391

392392
/// Returns `true` if the token is a identifier whose name is the given
393393
/// string slice.
394-
crate fn is_ident_named(&self, name: &str) -> bool {
394+
crate fn is_ident_named(&self, name: Symbol) -> bool {
395395
match self.ident() {
396-
Some((ident, _)) => ident.as_str() == name,
396+
Some((ident, _)) => ident.name == name,
397397
None => false
398398
}
399399
}

src/libsyntax_pos/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ symbols! {
133133
allow_internal_unstable,
134134
allow_internal_unstable_backcompat_hack,
135135
always,
136+
and,
136137
any,
137138
arbitrary_self_types,
138139
Arguments,
@@ -420,6 +421,7 @@ symbols! {
420421
option,
421422
Option,
422423
opt_out_copy,
424+
or,
423425
Ord,
424426
Ordering,
425427
Output,

0 commit comments

Comments
 (0)