Description
The knowledge about all the elements in an array can be used to run a single check instead of running the checks on each element one at a time (suggested in #53671 (comment)).
This is currently only done for strings, but could just as well be done for arrays of various types with Scalar
layout.
The E-easy part of this issue is to check for arrays/slices of the builtin integer types and simply verify that there are no relocations in the entire array and that the entire array has no undefined bytes. Should be possible by simply calling
rust/src/librustc_mir/interpret/memory.rs
Line 740 in 1114ab6
Ok
. No need to actually check the value.
The E-medium part is to refactor
to take a bunch of closures which do the final checks. Instead of doing the check for a single memory location, run it for the entire array at once. This means the function won't haverust/src/librustc_mir/interpret/validity.rs
Line 101 in 1114ab6
rust/src/librustc_mir/interpret/validity.rs
Lines 110 to 113 in 1114ab6
rust/src/librustc_mir/interpret/validity.rs
Line 166 in 1114ab6