Skip to content

Commit 80a1488

Browse files
committed
Prefer to_value_with_len over manual expanison of it
1 parent 6d513f7 commit 80a1488

File tree

1 file changed

+2
-7
lines changed
  • src/librustc_mir/hair/cx

1 file changed

+2
-7
lines changed

src/librustc_mir/hair/cx/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
173173
LitKind::Str(ref s, _) => {
174174
let s = s.as_str();
175175
let id = self.tcx.allocate_bytes(s.as_bytes());
176-
ConstValue::ScalarPair(
177-
Scalar::Ptr(id.into()),
178-
Scalar::Bits {
179-
bits: s.len() as u128,
180-
defined: self.tcx.data_layout.pointer_size.bits() as u8,
181-
}
182-
)
176+
let value = Scalar::Ptr(id.into()).to_value_with_len(s.len() as u64, self.tcx);
177+
ConstValue::from_byval_value(value)
183178
},
184179
LitKind::ByteStr(ref data) => {
185180
let id = self.tcx.allocate_bytes(data);

0 commit comments

Comments
 (0)