about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2025-01-18 22:08:53 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2025-01-18 22:09:34 +0000
commit0bb4880581a6963e0b895f9550e9147c68b9537a (patch)
tree9baf2ee379ece1ec3055fb5cbe2f36afd94302a7 /compiler
parentca1c17c88d1f625763859396ba7a50f36ac45cc0 (diff)
downloadrust-0bb4880581a6963e0b895f9550e9147c68b9537a.tar.gz
rust-0bb4880581a6963e0b895f9550e9147c68b9537a.zip
Revert "Rollup merge of #134371 - scottmcm:fix-134352, r=oli-obk"
This reverts commit 7c301ecdf5e806b7aa3c44e4a185049fabbc4381, reversing
changes made to dffaad83327454430129802f240121f8c7866208.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_build/src/builder/expr/as_place.rs32
1 files changed, 7 insertions, 25 deletions
diff --git a/compiler/rustc_mir_build/src/builder/expr/as_place.rs b/compiler/rustc_mir_build/src/builder/expr/as_place.rs
index 01aec70f437..2c88a48424f 100644
--- a/compiler/rustc_mir_build/src/builder/expr/as_place.rs
+++ b/compiler/rustc_mir_build/src/builder/expr/as_place.rs
@@ -647,31 +647,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
         match place_ty.kind() {
             ty::Array(_elem_ty, len_const) => {
-                let ty_const = if let Some((_, len_ty)) = len_const.try_to_valtree()
-                    && len_ty != self.tcx.types.usize
-                {
-                    // Bad const generics can give us a constant from the type that's
-                    // not actually a `usize`, so in that case give an error instead.
-                    // FIXME: It'd be nice if the type checker made sure this wasn't
-                    // possible, instead.
-                    let err = self.tcx.dcx().span_delayed_bug(
-                        span,
-                        format!(
-                            "Array length should have already been a type error, as it's {len_ty:?}"
-                        ),
-                    );
-                    ty::Const::new_error(self.tcx, err)
-                } else {
-                    // We know how long an array is, so just use that as a constant
-                    // directly -- no locals needed. We do need one statement so
-                    // that borrow- and initialization-checking consider it used,
-                    // though. FIXME: Do we really *need* to count this as a use?
-                    // Could partial array tracking work off something else instead?
-                    self.cfg.push_fake_read(block, source_info, FakeReadCause::ForIndex, place);
-                    *len_const
-                };
-
-                let const_ = Const::from_ty_const(ty_const, usize_ty, self.tcx);
+                // We know how long an array is, so just use that as a constant
+                // directly -- no locals needed. We do need one statement so
+                // that borrow- and initialization-checking consider it used,
+                // though. FIXME: Do we really *need* to count this as a use?
+                // Could partial array tracking work off something else instead?
+                self.cfg.push_fake_read(block, source_info, FakeReadCause::ForIndex, place);
+                let const_ = Const::from_ty_const(*len_const, usize_ty, self.tcx);
                 Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
             }
             ty::Slice(_elem_ty) => {