Skip to content

Commit 9243168

Browse files
committed
Auto merge of #100085 - RalfJung:op-ty-len, r=oli-obk
interpret: use new OpTy::len for Len rvalue This avoids a `force_allocation`.
2 parents 4fd4de7 + 7913edb commit 9243168

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_const_eval/src/interpret/step.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
251251

252252
Len(place) => {
253253
let src = self.eval_place(place)?;
254-
let mplace = self.force_allocation(&src)?;
255-
let len = mplace.len(self)?;
254+
let op = self.place_to_op(&src)?;
255+
let len = op.len(self)?;
256256
self.write_scalar(Scalar::from_machine_usize(len, self), &dest)?;
257257
}
258258

src/tools/clippy/tests/ui/indexing_slicing_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
44
// we want to avoid false positives.
55
#![warn(clippy::out_of_bounds_indexing)]
6-
#![allow(const_err, clippy::no_effect, clippy::unnecessary_operation)]
6+
#![allow(const_err, unconditional_panic, clippy::no_effect, clippy::unnecessary_operation)]
77

88
const ARR: [i32; 2] = [1, 2];
99
const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr.

0 commit comments

Comments
 (0)