From 3bbc598d16bbaab62ec3f460d1832236908607d8 Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 11 Jun 2023 17:03:26 +0800 Subject: [PATCH] use bug! for overflow of u128 --- compiler/rustc_hir_typeck/src/intrinsicck.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index e1837eb55826..362c07431e0a 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -87,7 +87,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(v) = u128::from(size.bytes()).checked_mul(8) { format!("{} bits", v) } else { - format!("{} bytes", size.bytes()) + // `u128` should definitely be able to hold the size of different architectures + // larger sizes should be reported as error `are too big for the current architecture` + // otherwise we have a bug somewhere + bug!("{:?} overflow for u128", size) } } Ok(SizeSkeleton::Generic(size)) => {