Skip to content

Commit a624c8e

Browse files
committed
Stabilize C string literals
1 parent a395214 commit a624c8e

File tree

14 files changed

+4
-53
lines changed

14 files changed

+4
-53
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
536536
}
537537
};
538538
}
539-
gate_all!(c_str_literals, "`c\"..\"` literals are experimental");
540539
gate_all!(
541540
if_let_guard,
542541
"`if let` guards are experimental",

compiler/rustc_builtin_macros/src/concat_bytes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ fn invalid_type_err(
1919
let snippet = cx.sess.source_map().span_to_snippet(span).ok();
2020
match ast::LitKind::from_token_lit(token_lit) {
2121
Ok(ast::LitKind::CStr(_, _)) => {
22-
// FIXME(c_str_literals): should concatenation of C string literals
23-
// include the null bytes in the end?
22+
// Avoid ambiguity in handling of terminal `NUL` by refusing to
23+
// concatenate C string literals as bytes.
2424
cx.emit_err(errors::ConcatCStrLit { span: span });
2525
}
2626
Ok(ast::LitKind::Char(_)) => {

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ declare_features! (
7777
(accepted, bindings_after_at, "1.56.0", Some(65490), None),
7878
/// Allows empty structs and enum variants with braces.
7979
(accepted, braced_empty_structs, "1.8.0", Some(29720), None),
80+
/// Allows `c"foo"` literals.
81+
(accepted, c_str_literals, "CURRENT_RUSTC_VERSION", Some(105723), None),
8082
/// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
8183
(accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
8284
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ declare_features! (
346346
(unstable, async_fn_track_caller, "1.73.0", Some(110011), None),
347347
/// Allows builtin # foo() syntax
348348
(unstable, builtin_syntax, "1.71.0", Some(110680), None),
349-
/// Allows `c"foo"` literals.
350-
(unstable, c_str_literals, "1.71.0", Some(105723), None),
351349
/// Treat `extern "C"` function as nounwind.
352350
(unstable, c_unwind, "1.52.0", Some(74990), None),
353351
/// Allows using C-variadics.

compiler/rustc_parse/src/lexer/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ impl<'a> StringReader<'a> {
221221
rustc_lexer::TokenKind::Literal { kind, suffix_start } => {
222222
let suffix_start = start + BytePos(suffix_start);
223223
let (kind, symbol) = self.cook_lexer_literal(start, suffix_start, kind);
224-
if let token::LitKind::CStr | token::LitKind::CStrRaw(_) = kind {
225-
self.sess.gated_spans.gate(sym::c_str_literals, self.mk_sp(start, self.pos));
226-
}
227224
let suffix = if suffix_start < self.pos {
228225
let string = self.str_from(suffix_start);
229226
if string == "_" {

src/tools/clippy/tests/ui/needless_raw_string.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::needless_raw_string_hashes, clippy::no_effect, unused)]
22
#![warn(clippy::needless_raw_strings)]
3-
#![feature(c_str_literals)]
43

54
fn main() {
65
"aaa";

src/tools/clippy/tests/ui/needless_raw_string.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::needless_raw_string_hashes, clippy::no_effect, unused)]
22
#![warn(clippy::needless_raw_strings)]
3-
#![feature(c_str_literals)]
43

54
fn main() {
65
r#"aaa"#;

src/tools/clippy/tests/ui/needless_raw_string_hashes.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::no_effect, unused)]
22
#![warn(clippy::needless_raw_string_hashes)]
3-
#![feature(c_str_literals)]
43

54
fn main() {
65
r"\aaa";

src/tools/clippy/tests/ui/needless_raw_string_hashes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::no_effect, unused)]
22
#![warn(clippy::needless_raw_string_hashes)]
3-
#![feature(c_str_literals)]
43

54
fn main() {
65
r#"\aaa"#;

tests/ui/proc-macro/literal-to-string.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// check-pass
22
// edition: 2021
3-
#![feature(c_str_literals)]
43

54
// aux-build: print-tokens.rs
65
extern crate print_tokens;
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// run-pass
22
// edition: 2021
33

4-
#![feature(c_str_literals)]
5-
64
fn main() {
75
assert_eq!(b"test\0", c"test".to_bytes_with_nul());
86
}

tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs

-15
This file was deleted.

tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr

-21
This file was deleted.

tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// run-pass
22
// edition: 2021
33

4-
#![feature(c_str_literals)]
5-
64
fn main() {
75
assert_eq!(
86
c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(),

0 commit comments

Comments
 (0)