From 29c372bf8b612dd9e23eb2503a1f1167e2f2f47c Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 7 Jan 2020 15:51:43 +0100 Subject: [PATCH] Add more documentation --- src/librustc_mir/const_eval/eval_queries.rs | 7 ++++++- src/librustc_mir/interpret/place.rs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index 9fbb6e1a39d9..d2a0798249ad 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -124,7 +124,12 @@ pub(super) fn op_to_const<'tcx>( ConstValue::ByRef { alloc, offset: ptr.offset } } Scalar::Raw { data, .. } => { - assert_eq!(data, mplace.layout.align.abi.bytes().into()); + assert_eq!( + data, + mplace.layout.align.abi.bytes().into(), + "this MPlaceTy must come from `try_as_mplace` being used on a zst, so we know what + value this integer address must have", + ); assert!(mplace.layout.is_zst()); ConstValue::Scalar(Scalar::zst()) } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 1f7db45ccff5..69563c5a08de 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -21,7 +21,9 @@ use super::{ }; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)] +/// Information required for the sound usage of a `MemPlace`. pub enum MemPlaceMeta { + /// The unsized payload (e.g. length for slices or vtable pointer for trait objects). Unsized(Scalar), /// `Sized` types or unsized `extern type` None,