Skip to content

Commit

Permalink
Auto merge of #100085 - RalfJung:op-ty-len, r=oli-obk
Browse files Browse the repository at this point in the history
interpret: use new OpTy::len for Len rvalue

This avoids a `force_allocation`.
  • Loading branch information
bors committed Aug 31, 2022
2 parents 4fd4de7 + 7913edb commit 9243168
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

Len(place) => {
let src = self.eval_place(place)?;
let mplace = self.force_allocation(&src)?;
let len = mplace.len(self)?;
let op = self.place_to_op(&src)?;
let len = op.len(self)?;
self.write_scalar(Scalar::from_machine_usize(len, self), &dest)?;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/indexing_slicing_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
// we want to avoid false positives.
#![warn(clippy::out_of_bounds_indexing)]
#![allow(const_err, clippy::no_effect, clippy::unnecessary_operation)]
#![allow(const_err, unconditional_panic, clippy::no_effect, clippy::unnecessary_operation)]

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

0 comments on commit 9243168

Please sign in to comment.