about summary refs log tree commit diff
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2023-06-11 17:03:26 +0800
committeryukang <moorekang@gmail.com>2023-06-13 22:14:05 +0800
commit3bbc598d16bbaab62ec3f460d1832236908607d8 (patch)
tree384a18979c383cf536b66a31cefa2b95b52dbfaa
parentb133841bfca673f26e6f1b779b1c8cdd36600c84 (diff)
downloadrust-3bbc598d16bbaab62ec3f460d1832236908607d8.tar.gz
rust-3bbc598d16bbaab62ec3f460d1832236908607d8.zip
use bug! for overflow of u128
-rw-r--r--compiler/rustc_hir_typeck/src/intrinsicck.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs
index e1837eb5582..362c07431e0 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)) => {