From d6e8c7f7a0813c1f8cd42c00cb43d4c1b3f562ac Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 31 Jan 2025 00:11:55 +0000 Subject: Delay a bug when indexing unsized slices --- compiler/rustc_const_eval/src/check_consts/check.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 16ead1b9785..4834fd3d34c 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -634,7 +634,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::RawPtr(RawPtrKind::FakeForPtrMetadata, place) => { // These are only inserted for slice length, so the place must already be indirect. // This implies we do not have to worry about whether the borrow escapes. - assert!(place.is_indirect(), "fake borrows are always indirect"); + if !place.is_indirect() { + self.tcx.dcx().span_delayed_bug( + self.body.source_info(location).span, + "fake borrows are always indirect", + ); + } } Rvalue::Cast( -- cgit 1.4.1-3-g733a5