diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 1c24f5c116cc..b8d6c1224463 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -138,9 +138,11 @@ impl<'tcx> Scalar<()> { "Scalar value {:#x} exceeds size of {} bytes", data, size); } + /// Tag this scalar with `new_tag` if it is a pointer, leave it unchanged otherwise. + /// + /// Used by `MemPlace::replace_tag`. #[inline] pub fn with_tag(self, new_tag: Tag) -> Scalar { - // Used by `MemPlace::replace_tag` match self { Scalar::Ptr(ptr) => Scalar::Ptr(ptr.with_tag(new_tag)), Scalar::Raw { data, size } => Scalar::Raw { data, size }, @@ -149,9 +151,11 @@ impl<'tcx> Scalar<()> { } impl<'tcx, Tag> Scalar { + /// Erase the tag from the scalar, if any. + /// + /// Used by error reporting code to avoid having the error type depend on `Tag`. #[inline] pub fn erase_tag(self) -> Scalar { - // Used by error reporting code to avoid having the error type depend on `Tag` match self { Scalar::Ptr(ptr) => Scalar::Ptr(ptr.erase_tag()), Scalar::Raw { data, size } => Scalar::Raw { data, size }, @@ -472,10 +476,12 @@ impl fmt::Display for ScalarMaybeUndef { } impl<'tcx, Tag> ScalarMaybeUndef { + /// Erase the tag from the scalar, if any. + /// + /// Used by error reporting code to avoid having the error type depend on `Tag`. #[inline] pub fn erase_tag(self) -> ScalarMaybeUndef { - // Used by error reporting code to avoid having the error type depend on `Tag` match self { ScalarMaybeUndef::Scalar(s) => ScalarMaybeUndef::Scalar(s.erase_tag()), ScalarMaybeUndef::Undef => ScalarMaybeUndef::Undef,