Revert the lexing of c_str_literals
This commit is contained in:
parent
4dbc7e3092
commit
c6643b50ea
9 changed files with 96 additions and 23 deletions
|
@ -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(),
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// run-pass
|
||||
// FIXME(c_str_literals): This should be `run-pass`
|
||||
// known-bug: #113333
|
||||
// edition: 2021
|
||||
|
||||
#![feature(c_str_literals)]
|
||||
|
||||
|
|
25
tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr
Normal file
25
tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr
Normal 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
|
||||
|
|
@ -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`
|
||||
}
|
||||
|
|
|
@ -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`.
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,6 @@
|
|||
// run-pass
|
||||
// FIXME(c_str_literals): This should be `run-pass`
|
||||
// known-bug: #113333
|
||||
// edition: 2021
|
||||
|
||||
#![feature(c_str_literals)]
|
||||
|
||||
|
|
38
tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr
Normal file
38
tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr
Normal 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
|
||||
|
Loading…
Add table
Reference in a new issue