提交 da7b6b4b 编写于 作者: T Tom Tromey

Avoid possible integer overflow in niche value computation

@EddyB pointed out in review that the niche value computation had a
possible integer overflow problem, fixed here as he suggested.
上级 e7c49a73
......@@ -1361,8 +1361,11 @@ fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
let niche_value = if i == dataful_variant {
None
} else {
Some((i.wrapping_sub(*niche_variants.start()) as u128)
.wrapping_add(niche_start) as u64)
let niche = (i as u128)
.wrapping_sub(*niche_variants.start() as u128)
.wrapping_add(niche_start);
assert_eq!(niche as u64 as u128, niche);
Some(niche as u64)
};
MemberDescription {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册