about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2023-07-04 19:40:48 +0200
committerLeón Orell Valerian Liehr <me@fmease.dev>2023-07-05 13:11:17 +0200
commitc6643b50ea7290daf0a9f0e33d1f27c6f52796ce (patch)
tree46090e779d455c2c5458fadb6a1ab4832ef79761
parent4dbc7e3092fce6f3d5712733e5206226183dbe1e (diff)
downloadrust-c6643b50ea7290daf0a9f0e33d1f27c6f52796ce.tar.gz
rust-c6643b50ea7290daf0a9f0e33d1f27c6f52796ce.zip
Revert the lexing of c_str_literals
-rw-r--r--compiler/rustc_lexer/src/lib.rs7
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs4
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr25
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs6
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr35
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rsbin565 -> 760 bytes
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderrbin674 -> 4477 bytes
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs4
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr38
9 files changed, 96 insertions, 23 deletions
diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs
index d511d2b1280..29335a8c0f4 100644
--- a/compiler/rustc_lexer/src/lib.rs
+++ b/compiler/rustc_lexer/src/lib.rs
@@ -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(),
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs
index e4b07ab8108..3fc5fd481ea 100644
--- a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs
@@ -1,4 +1,6 @@
-// run-pass
+// FIXME(c_str_literals): This should be `run-pass`
+// known-bug: #113333
+// edition: 2021
 
 #![feature(c_str_literals)]
 
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr
new file mode 100644
index 00000000000..571c319d8c5
--- /dev/null
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr
@@ -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
+
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs
index b27da26ed23..ddd6d9a25da 100644
--- a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs
@@ -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`
 }
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr
index bc0c537aada..8de36ca4a6e 100644
--- a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr
@@ -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: prefixed identifiers and literals are reserved since Rust 2021
+help: consider inserting whitespace here
    |
-   = 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
+LL |     m!(c "test");
+   |         +
+
+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 2 previous errors
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs
index 7bc6097f124..96945f125da 100644
--- a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs
Binary files differdiff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr
index ff9006f6f97..2226c7aa6a9 100644
--- a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr
Binary files differdiff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs
index 82e8e2090d7..066505c23df 100644
--- a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs
@@ -1,4 +1,6 @@
-// run-pass
+// FIXME(c_str_literals): This should be `run-pass`
+// known-bug: #113333
+// edition: 2021
 
 #![feature(c_str_literals)]
 
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr
new file mode 100644
index 00000000000..47361fb61d2
--- /dev/null
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr
@@ -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
+