about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/check_consts/check.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-01-31 00:11:55 +0000
committerMichael Goulet <michael@errs.io>2025-01-31 00:12:09 +0000
commitd6e8c7f7a0813c1f8cd42c00cb43d4c1b3f562ac (patch)
tree8c5f4395ac5d22d665b513b9af03a4b43e2ef08f /compiler/rustc_const_eval/src/check_consts/check.rs
parenta6434ef9c0246fa39eecb34e22807da2a68f3904 (diff)
downloadrust-d6e8c7f7a0813c1f8cd42c00cb43d4c1b3f562ac.tar.gz
rust-d6e8c7f7a0813c1f8cd42c00cb43d4c1b3f562ac.zip
Delay a bug when indexing unsized slices
Diffstat (limited to 'compiler/rustc_const_eval/src/check_consts/check.rs')
-rw-r--r--compiler/rustc_const_eval/src/check_consts/check.rs7
1 files changed, 6 insertions, 1 deletions
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(