From 1a2964a541ddd38ac358635fa2a8adeb5926d474 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 24 May 2018 10:50:05 +0200 Subject: [PATCH] Simplify a ScalarPair creation --- src/librustc_mir/hair/pattern/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index dd79e0cdd0f..5c22462c4c7 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -1134,13 +1134,8 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind, LitKind::Str(ref s, _) => { let s = s.as_str(); let id = tcx.allocate_bytes(s.as_bytes()); - ConstValue::ScalarPair( - Scalar::Ptr(id.into()), - Scalar::Bits { - bits: s.len() as u128, - defined: tcx.data_layout.pointer_size.bits() as u8, - }, - ) + let value = Scalar::Ptr(id.into()).to_value_with_len(s.len() as u64, tcx); + ConstValue::from_byval_value(value) }, LitKind::ByteStr(ref data) => { let id = tcx.allocate_bytes(data);