diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-03-14 00:40:25 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-03-17 23:35:19 +0000 |
| commit | ea1883d7b2207d1a0f08046f11ca493803bc8a55 (patch) | |
| tree | 6fd695414bc60ada3be73bcdd46388d8f6a13ea8 /compiler/rustc_lexer/src | |
| parent | 6f388ef1fb3964fb83bae5c277f9c83bbde4c76b (diff) | |
| download | rust-ea1883d7b2207d1a0f08046f11ca493803bc8a55.tar.gz rust-ea1883d7b2207d1a0f08046f11ca493803bc8a55.zip | |
Silence redundant error on char literal that was meant to be a string in 2021 edition
Diffstat (limited to 'compiler/rustc_lexer/src')
| -rw-r--r-- | compiler/rustc_lexer/src/cursor.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_lexer/src/cursor.rs b/compiler/rustc_lexer/src/cursor.rs index 8d8cc9ecc3e..d173c3ac032 100644 --- a/compiler/rustc_lexer/src/cursor.rs +++ b/compiler/rustc_lexer/src/cursor.rs @@ -59,6 +59,15 @@ impl<'a> Cursor<'a> { iter.next().unwrap_or(EOF_CHAR) } + /// Peeks the third symbol from the input stream without consuming it. + pub fn third(&self) -> char { + // `.next()` optimizes better than `.nth(1)` + let mut iter = self.chars.clone(); + iter.next(); + iter.next(); + iter.next().unwrap_or(EOF_CHAR) + } + /// Checks if there is nothing more to consume. pub(crate) fn is_eof(&self) -> bool { self.chars.as_str().is_empty() |
