about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2022-09-15 20:27:23 +0400
committerMaybe Waffle <waffle.lapkin@gmail.com>2022-10-01 10:13:02 +0000
commitd86f9cd4640c9ad81ad4aec45c358d1931d40f30 (patch)
tree08417ec5fcd94d686f0385549d3cbe62aa65e142 /compiler/rustc_ast/src
parent38b086524875c1ed9904f94eca64a162f7572dae (diff)
downloadrust-d86f9cd4640c9ad81ad4aec45c358d1931d40f30.tar.gz
rust-d86f9cd4640c9ad81ad4aec45c358d1931d40f30.zip
Replace some `bool` params with an enum
Diffstat (limited to 'compiler/rustc_ast/src')
-rw-r--r--compiler/rustc_ast/src/lib.rs1
-rw-r--r--compiler/rustc_ast/src/token.rs7
-rw-r--r--compiler/rustc_ast/src/util/case.rs6
3 files changed, 11 insertions, 3 deletions
diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs
index eeb7e56e2b1..9c1dfeb1a61 100644
--- a/compiler/rustc_ast/src/lib.rs
+++ b/compiler/rustc_ast/src/lib.rs
@@ -29,6 +29,7 @@ extern crate rustc_macros;
 extern crate tracing;
 
 pub mod util {
+    pub mod case;
     pub mod classify;
     pub mod comments;
     pub mod literal;
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index 3f7e32f4fae..5cdd0bf60a9 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -5,6 +5,7 @@ pub use TokenKind::*;
 
 use crate::ast;
 use crate::ptr::P;
+use crate::util::case::Case;
 
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_data_structures::sync::Lrc;
@@ -618,10 +619,10 @@ impl Token {
         self.is_non_raw_ident_where(|id| id.name == kw)
     }
 
-    /// Returns `true` if the token is a given keyword, `kw` or if `case_insensitive` is true and this token is an identifier equal to `kw` ignoring the case.
-    pub fn is_keyword_case(&self, kw: Symbol, case_insensitive: bool) -> bool {
+    /// Returns `true` if the token is a given keyword, `kw` or if `case` is `Insensitive` and this token is an identifier equal to `kw` ignoring the case.
+    pub fn is_keyword_case(&self, kw: Symbol, case: Case) -> bool {
         self.is_keyword(kw)
-            || (case_insensitive
+            || (case == Case::Insensitive
                 && self.is_non_raw_ident_where(|id| {
                     id.name.as_str().to_lowercase() == kw.as_str().to_lowercase()
                 }))
diff --git a/compiler/rustc_ast/src/util/case.rs b/compiler/rustc_ast/src/util/case.rs
new file mode 100644
index 00000000000..1afd7dea740
--- /dev/null
+++ b/compiler/rustc_ast/src/util/case.rs
@@ -0,0 +1,6 @@
+/// Whatever to ignore case (`fn` vs `Fn` vs `FN`) or not. Used for recovering.
+#[derive(Copy, Clone, Debug, Eq, PartialEq)]
+pub enum Case {
+    Sensitive,
+    Insensitive,
+}