@@ -138,9 +138,11 @@ impl<'tcx> Scalar<()> {
138
138
"Scalar value {:#x} exceeds size of {} bytes" , data, size) ;
139
139
}
140
140
141
+ /// Tag this scalar with `new_tag` if it is a pointer, leave it unchanged otherwise.
142
+ ///
143
+ /// Used by `MemPlace::replace_tag`.
141
144
#[ inline]
142
145
pub fn with_tag < Tag > ( self , new_tag : Tag ) -> Scalar < Tag > {
143
- // Used by `MemPlace::replace_tag`
144
146
match self {
145
147
Scalar :: Ptr ( ptr) => Scalar :: Ptr ( ptr. with_tag ( new_tag) ) ,
146
148
Scalar :: Raw { data, size } => Scalar :: Raw { data, size } ,
@@ -149,9 +151,11 @@ impl<'tcx> Scalar<()> {
149
151
}
150
152
151
153
impl < ' tcx , Tag > Scalar < Tag > {
154
+ /// Erase the tag from the scalar, if any.
155
+ ///
156
+ /// Used by error reporting code to avoid having the error type depend on `Tag`.
152
157
#[ inline]
153
158
pub fn erase_tag ( self ) -> Scalar {
154
- // Used by error reporting code to avoid having the error type depend on `Tag`
155
159
match self {
156
160
Scalar :: Ptr ( ptr) => Scalar :: Ptr ( ptr. erase_tag ( ) ) ,
157
161
Scalar :: Raw { data, size } => Scalar :: Raw { data, size } ,
@@ -472,10 +476,12 @@ impl<Tag> fmt::Display for ScalarMaybeUndef<Tag> {
472
476
}
473
477
474
478
impl < ' tcx , Tag > ScalarMaybeUndef < Tag > {
479
+ /// Erase the tag from the scalar, if any.
480
+ ///
481
+ /// Used by error reporting code to avoid having the error type depend on `Tag`.
475
482
#[ inline]
476
483
pub fn erase_tag ( self ) -> ScalarMaybeUndef
477
484
{
478
- // Used by error reporting code to avoid having the error type depend on `Tag`
479
485
match self {
480
486
ScalarMaybeUndef :: Scalar ( s) => ScalarMaybeUndef :: Scalar ( s. erase_tag ( ) ) ,
481
487
ScalarMaybeUndef :: Undef => ScalarMaybeUndef :: Undef ,
0 commit comments