Skip to content

Commit 6c056d3

Browse files
committed
Satisfy rc_buffer lint in Constant::Binary byte string by copying data
We can avoid the data copy again by fixing rustc_ast::ast::LitKind later.
1 parent 2720085 commit 6c056d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum Constant {
2121
/// A `String` (e.g., "abc").
2222
Str(String),
2323
/// A binary string (e.g., `b"abc"`).
24-
Binary(Lrc<Vec<u8>>),
24+
Binary(Lrc<[u8]>),
2525
/// A single `char` (e.g., `'a'`).
2626
Char(char),
2727
/// An integer's bit representation.
@@ -155,7 +155,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
155155
match *lit {
156156
LitKind::Str(ref is, _) => Constant::Str(is.to_string()),
157157
LitKind::Byte(b) => Constant::Int(u128::from(b)),
158-
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
158+
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::from(s.as_slice())),
159159
LitKind::Char(c) => Constant::Char(c),
160160
LitKind::Int(n, _) => Constant::Int(n),
161161
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {

0 commit comments

Comments
 (0)