about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-31 12:28:18 +0100
committerGitHub <noreply@github.com>2025-01-31 12:28:18 +0100
commitf1daf9e2c4f0771b4c1aa6c979c6d6499eb7a45e (patch)
tree2b6099d6c15c0e7aad7087e4058eb5e4e332affb /compiler
parent12a7f06e3c9207fd6b7b66fd51b995bb879514bc (diff)
parentd6e8c7f7a0813c1f8cd42c00cb43d4c1b3f562ac (diff)
downloadrust-f1daf9e2c4f0771b4c1aa6c979c6d6499eb7a45e.tar.gz
rust-f1daf9e2c4f0771b4c1aa6c979c6d6499eb7a45e.zip
Rollup merge of #136325 - compiler-errors:indirectly, r=RalfJung
Delay a bug when indexing unsized slices

Fixes #136298

r? RalfJung or reassign
Diffstat (limited to 'compiler')
-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(