Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4b94c23

Browse files
committedMay 5, 2023
Auto merge of rust-lang#111248 - Dylan-DPC:rollup-lbp0ui3, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#103056 (Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds) - rust-lang#108801 (Implement RFC 3348, `c"foo"` literals) - rust-lang#110773 (Reduce MIR dump file count for MIR-opt tests) - rust-lang#110876 (Added default target cpu to `--print target-cpus` output and updated docs) - rust-lang#111068 (Improve check-cfg implementation) - rust-lang#111238 (btree_map: `Cursor{,Mut}::peek_prev` must agree) Failed merges: - rust-lang#110694 (Implement builtin # syntax and use it for offset_of!(...)) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4a18324 + c99ab29 commit 4b94c23

File tree

70 files changed

+1164
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1164
-524
lines changed
 

‎compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,8 @@ pub enum LitKind {
18211821
/// A byte string (`b"foo"`). Not stored as a symbol because it might be
18221822
/// non-utf8, and symbols only allow utf8 strings.
18231823
ByteStr(Lrc<[u8]>, StrStyle),
1824+
/// A C String (`c"foo"`). Guaranteed to only have `\0` at the end.
1825+
CStr(Lrc<[u8]>, StrStyle),
18241826
/// A byte char (`b'f'`).
18251827
Byte(u8),
18261828
/// A character literal (`'a'`).
@@ -1875,6 +1877,7 @@ impl LitKind {
18751877
// unsuffixed variants
18761878
LitKind::Str(..)
18771879
| LitKind::ByteStr(..)
1880+
| LitKind::CStr(..)
18781881
| LitKind::Byte(..)
18791882
| LitKind::Char(..)
18801883
| LitKind::Int(_, LitIntType::Unsuffixed)

‎compiler/rustc_ast/src/token.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ pub enum LitKind {
7474
StrRaw(u8), // raw string delimited by `n` hash symbols
7575
ByteStr,
7676
ByteStrRaw(u8), // raw byte string delimited by `n` hash symbols
77+
CStr,
78+
CStrRaw(u8),
7779
Err,
7880
}
7981

@@ -141,6 +143,10 @@ impl fmt::Display for Lit {
141143
delim = "#".repeat(n as usize),
142144
string = symbol
143145
)?,
146+
CStr => write!(f, "c\"{symbol}\"")?,
147+
CStrRaw(n) => {
148+
write!(f, "cr{delim}\"{symbol}\"{delim}", delim = "#".repeat(n as usize))?
149+
}
144150
Integer | Float | Bool | Err => write!(f, "{symbol}")?,
145151
}
146152

@@ -170,6 +176,7 @@ impl LitKind {
170176
Float => "float",
171177
Str | StrRaw(..) => "string",
172178
ByteStr | ByteStrRaw(..) => "byte string",
179+
CStr | CStrRaw(..) => "C string",
173180
Err => "error",
174181
}
175182
}

0 commit comments

Comments
 (0)