From 290db47ad67ee2ef0a43fb4b9b6561d00c4a078e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Oct 2018 08:37:27 +0200 Subject: [PATCH] comment on keeping validity in sync --- src/librustc_mir/interpret/validity.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index c446980d0499..83b9705c1fe8 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -163,6 +163,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> scalar_format(value), path, "a valid unicode codepoint"); }, ty::Float(_) | ty::Int(_) | ty::Uint(_) => { + // NOTE: Keep this in sync with the array optimization for int/float + // types below! let size = value.layout.size; let value = value.to_scalar_or_undef(); if const_mode { @@ -511,6 +513,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // This is the size in bytes of the whole array. let size = Size::from_bytes(ty_size * len); + // NOTE: Keep this in sync with the handling of integer and float + // types above, in `validate_primitive_type`. // In run-time mode, we accept pointers in here. This is actually more // permissive than a per-element check would be, e.g. we accept // an &[u8] that contains a pointer even though bytewise checking would