Skip to content

Commit 37127b8

Browse files
committed
initial step towards implementing C string literals
1 parent eac589b commit 37127b8

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ impl<'a> NormalizedPat<'a> {
284284
LitKind::Str(sym, _) => Self::LitStr(sym),
285285
LitKind::ByteStr(ref bytes, _) => Self::LitBytes(bytes),
286286
LitKind::Byte(val) => Self::LitInt(val.into()),
287+
LitKind::CStr(ref bytes, _) => Self::LitBytes(bytes),
287288
LitKind::Char(val) => Self::LitInt(val.into()),
288289
LitKind::Int(val, _) => Self::LitInt(val),
289290
LitKind::Bool(val) => Self::LitBool(val),

clippy_lints/src/utils/author.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
304304
kind!("ByteStr(ref {vec})");
305305
chain!(self, "let [{:?}] = **{vec}", vec.value);
306306
},
307+
LitKind::CStr(ref vec, _) => {
308+
bind!(self, vec);
309+
kind!("CStr(ref {vec})");
310+
chain!(self, "let [{:?}] = **{vec}", vec.value);
311+
}
307312
LitKind::Str(s, _) => {
308313
bind!(self, s);
309314
kind!("Str({s}, _)");

clippy_utils/src/consts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ pub fn lit_to_mir_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
211211
LitKind::Str(ref is, _) => Constant::Str(is.to_string()),
212212
LitKind::Byte(b) => Constant::Int(u128::from(b)),
213213
LitKind::ByteStr(ref s, _) => Constant::Binary(Lrc::clone(s)),
214+
LitKind::CStr(ref s, _) => Constant::Binary(Lrc::clone(s)),
214215
LitKind::Char(c) => Constant::Char(c),
215216
LitKind::Int(n, _) => Constant::Int(n),
216217
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {

0 commit comments

Comments
 (0)