Skip to content

Commit 1a2964a

Browse files
committed
Simplify a ScalarPair creation
1 parent ca8c27e commit 1a2964a

File tree

1 file changed

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

1 file changed

+2
-7
lines changed

src/librustc_mir/hair/pattern/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,13 +1134,8 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind,
11341134
LitKind::Str(ref s, _) => {
11351135
let s = s.as_str();
11361136
let id = tcx.allocate_bytes(s.as_bytes());
1137-
ConstValue::ScalarPair(
1138-
Scalar::Ptr(id.into()),
1139-
Scalar::Bits {
1140-
bits: s.len() as u128,
1141-
defined: tcx.data_layout.pointer_size.bits() as u8,
1142-
},
1143-
)
1137+
let value = Scalar::Ptr(id.into()).to_value_with_len(s.len() as u64, tcx);
1138+
ConstValue::from_byval_value(value)
11441139
},
11451140
LitKind::ByteStr(ref data) => {
11461141
let id = tcx.allocate_bytes(data);

0 commit comments

Comments
 (0)