Skip to content

Commit fe96f82

Browse files
committed
validity: check dynamic size, not static
also less verbose logging
1 parent 976880a commit fe96f82

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/librustc_mir/interpret/validity.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
148148
ref_tracking: Option<&mut RefTracking<'tcx>>,
149149
const_mode: bool,
150150
) -> EvalResult<'tcx> {
151-
trace!("validate scalar by type: {:#?}, {:#?}, {}",
152-
*value, value.layout.size, value.layout.ty);
153-
154151
// Go over all the primitive types
155152
let ty = value.layout.ty;
156153
match ty.sty {
@@ -225,7 +222,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
225222
}
226223
}
227224
// non-ZST also have to be dereferencable
228-
if !place.layout.is_zst() {
225+
if size != Size::ZERO {
229226
let ptr = try_validation!(place.ptr.to_ptr(),
230227
"integer pointer in non-ZST reference", path);
231228
if const_mode {
@@ -280,7 +277,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
280277
path: &Vec<PathElem>,
281278
layout: &layout::Scalar,
282279
) -> EvalResult<'tcx> {
283-
trace!("validate scalar by layout: {:#?}, {:#?}, {:#?}", value, size, layout);
284280
let (lo, hi) = layout.valid_range.clone().into_inner();
285281
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
286282
assert!(hi <= max_hi);
@@ -372,7 +368,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
372368
mut ref_tracking: Option<&mut RefTracking<'tcx>>,
373369
const_mode: bool,
374370
) -> EvalResult<'tcx> {
375-
trace!("validate_operand: {:?}, {:#?}", *dest, dest.layout);
371+
trace!("validate_operand: {:?}, {:?}", *dest, dest.layout.ty);
376372

377373
// If this is a multi-variant layout, we have find the right one and proceed with that.
378374
// (No good reasoning to make this recursion, but it is equivalent to that.)

0 commit comments

Comments
 (0)