about summary refs log tree commit diff
path: root/compiler/rustc_lexer
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-10-30 01:10:33 +0000
committerMichael Goulet <michael@errs.io>2024-10-30 01:13:18 +0000
commit1990f1560801ca3f9e6a3286e58204aa329ee037 (patch)
tree202e7d5d71ffa26940df9820de6b90959b46f77c /compiler/rustc_lexer
parent3f1be1ec7ec3d8e80beb381ee82164a0aa3ca777 (diff)
downloadrust-1990f1560801ca3f9e6a3286e58204aa329ee037.tar.gz
rust-1990f1560801ca3f9e6a3286e58204aa329ee037.zip
Reject raw lifetime followed by \' as well
Diffstat (limited to 'compiler/rustc_lexer')
-rw-r--r--compiler/rustc_lexer/src/lib.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs
index b0ab50dd773..f9f2a14dbd2 100644
--- a/compiler/rustc_lexer/src/lib.rs
+++ b/compiler/rustc_lexer/src/lib.rs
@@ -715,7 +715,17 @@ impl Cursor<'_> {
             self.bump();
             self.bump();
             self.eat_while(is_id_continue);
-            return RawLifetime;
+            match self.first() {
+                '\'' => {
+                    // Check if after skipping literal contents we've met a closing
+                    // single quote (which means that user attempted to create a
+                    // string with single quotes).
+                    self.bump();
+                    let kind = Char { terminated: true };
+                    return Literal { kind, suffix_start: self.pos_within_token() };
+                }
+                _ => return RawLifetime,
+            }
         }
 
         // Either a lifetime or a character literal with