1
Fork 0

Auto merge of #113476 - fee1-dead-contrib:c-str-lit, r=petrochenkov

Reimplement C-str literals

This reverts #113334, cc `@fmease.`

While converting lexer tokens to ast Tokens in `rustc_parse`, we check the edition of the span of the token. If the edition < 2021, we split the token into two, one being the identifier and other being the str literal.
This commit is contained in:
bors 2023-07-25 12:04:34 +00:00
commit 23405bb123
12 changed files with 85 additions and 97 deletions

View file

@ -24,6 +24,10 @@ impl<'a> Cursor<'a> {
}
}
pub fn as_str(&self) -> &'a str {
self.chars.as_str()
}
/// Returns the last eaten symbol (or `'\0'` in release builds).
/// (For debug assertions only.)
pub(crate) fn prev(&self) -> char {

View file

@ -367,6 +367,13 @@ impl Cursor<'_> {
Some(|terminated| Byte { terminated }),
),
// c-string literal, raw c-string literal or identifier.
'c' => self.c_or_byte_string(
|terminated| CStr { terminated },
|n_hashes| RawCStr { n_hashes },
None,
),
// Identifier (this should be checked after other variant that can
// start as identifier).
c if is_id_start(c) => self.ident_or_unknown_prefix(),