Revert the lexing of c_str_literals

This commit is contained in:
León Orell Valerian Liehr 2023-07-04 19:40:48 +02:00
parent 4dbc7e3092
commit c6643b50ea
No known key found for this signature in database
GPG Key ID: D17A07215F68E713
9 changed files with 96 additions and 23 deletions

View File

@ -367,13 +367,6 @@ 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(),

View File

@ -1,4 +1,6 @@
// run-pass
// FIXME(c_str_literals): This should be `run-pass`
// known-bug: #113333
// edition: 2021
#![feature(c_str_literals)]

View File

@ -0,0 +1,25 @@
error: prefix `c` is unknown
--> $DIR/basic.rs:8:27
|
LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul());
| ^ unknown prefix
|
= note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
|
LL | assert_eq!(b"test\0", c "test".to_bytes_with_nul());
| +
error: no rules expected the token `"test"`
--> $DIR/basic.rs:8:28
|
LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul());
| -^^^^^
| |
| no rules expected this token in macro call
| help: missing comma here
|
= note: while trying to match sequence start
error: aborting due to 2 previous errors

View File

@ -1,4 +1,6 @@
// gate-test-c_str_literals
// known-bug: #113333
// edition: 2021
macro_rules! m {
($t:tt) => {}
@ -6,8 +8,8 @@ macro_rules! m {
fn main() {
c"foo";
//~^ ERROR: `c".."` literals are experimental
// FIXME(c_str_literals): This should be ``c".."` literals are experimental`
m!(c"test");
//~^ ERROR: `c".."` literals are experimental
// FIXME(c_str_literals): This should be ``c".."` literals are experimental`
}

View File

@ -1,21 +1,32 @@
error[E0658]: `c".."` literals are experimental
--> $DIR/gate.rs:8:5
error: prefix `c` is unknown
--> $DIR/gate.rs:10:5
|
LL | c"foo";
| ^^^^^^
| ^ unknown prefix
|
= note: see issue #105723 <https://github.com/rust-lang/rust/issues/105723> for more information
= help: add `#![feature(c_str_literals)]` to the crate attributes to enable
= note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
|
LL | c "foo";
| +
error[E0658]: `c".."` literals are experimental
--> $DIR/gate.rs:11:8
error: prefix `c` is unknown
--> $DIR/gate.rs:13:8
|
LL | m!(c"test");
| ^^^^^^^
| ^ unknown prefix
|
= note: see issue #105723 <https://github.com/rust-lang/rust/issues/105723> for more information
= help: add `#![feature(c_str_literals)]` to the crate attributes to enable
= note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
|
LL | m!(c "test");
| +
error: aborting due to 2 previous errors
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"foo"`
--> $DIR/gate.rs:10:6
|
LL | c"foo";
| ^^^^^ expected one of 8 possible tokens
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,4 +1,6 @@
// run-pass
// FIXME(c_str_literals): This should be `run-pass`
// known-bug: #113333
// edition: 2021
#![feature(c_str_literals)]

View File

@ -0,0 +1,38 @@
error: prefix `c` is unknown
--> $DIR/non-ascii.rs:9:9
|
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(),
| ^ unknown prefix
|
= note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
|
LL | c "\xEF\x80🦀\u{1F980}".to_bytes_with_nul(),
| +
error: out of range hex escape
--> $DIR/non-ascii.rs:9:11
|
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(),
| ^^^^ must be a character in the range [\x00-\x7f]
error: out of range hex escape
--> $DIR/non-ascii.rs:9:15
|
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(),
| ^^^^ must be a character in the range [\x00-\x7f]
error: no rules expected the token `"\xEF\x80🦀\u{1F980}"`
--> $DIR/non-ascii.rs:9:10
|
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(),
| -^^^^^^^^^^^^^^^^^^^^
| |
| no rules expected this token in macro call
| help: missing comma here
|
note: while trying to match `,`
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
error: aborting due to 4 previous errors