Skip to content

Commit 8f3e862

Browse files
committed
fixed shift overflow
Fix according to oli-obk (#58717 (comment))
1 parent 7330525 commit 8f3e862

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustc_codegen_llvm/debuginfo/metadata.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc::hir::CodegenFnAttrFlags;
2222
use rustc::hir::def::CtorKind;
2323
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
2424
use rustc::ich::NodeIdHashingMode;
25+
use rustc::mir::interpret::truncate;
2526
use rustc_data_structures::fingerprint::Fingerprint;
2627
use rustc::ty::Instance;
2728
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
@@ -1366,7 +1367,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
13661367
let value = (i.as_u32() as u128)
13671368
.wrapping_sub(niche_variants.start().as_u32() as u128)
13681369
.wrapping_add(niche_start);
1369-
let value = value & ((1u128 << niche.value.size(cx).bits()) - 1);
1370+
let value = truncate(value, niche.value.size(cx));
13701371
Some(value as u64)
13711372
};
13721373

0 commit comments

Comments
 (0)