From 12eedafc38b1d3af02c9c15333d0ba2f1aee1253 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 18 Jun 2025 12:51:47 +0000 Subject: Report the range of uninit bytes in CTFE errors --- compiler/rustc_middle/src/mir/interpret/allocation.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_middle') diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index 133111ff15d..27ead514531 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -702,8 +702,11 @@ impl Allocation read_provenance: bool, ) -> AllocResult> { // First and foremost, if anything is uninit, bail. - if self.init_mask.is_range_initialized(range).is_err() { - return Err(AllocError::InvalidUninitBytes(None)); + if let Err(bad) = self.init_mask.is_range_initialized(range) { + return Err(AllocError::InvalidUninitBytes(Some(BadBytesAccess { + access: range, + bad, + }))); } // Get the integer part of the result. We HAVE TO check provenance before returning this! -- cgit 1.4.1-3-g733a5