@@ -339,6 +339,10 @@ impl<'tcx, Tag> Scalar<Tag> {
339
339
Scalar :: Raw { data : f. to_bits ( ) , size : 8 }
340
340
}
341
341
342
+ /// This is very rarely the method you want! You should dispatch on the type
343
+ /// and use `force_bits`/`assert_bits`/`force_ptr`/`assert_ptr`.
344
+ /// This method only exists for the benefit of low-level memory operations
345
+ /// as well as the implementation of the `force_*` methods.
342
346
#[ inline]
343
347
pub fn to_bits_or_ptr (
344
348
self ,
@@ -359,6 +363,7 @@ impl<'tcx, Tag> Scalar<Tag> {
359
363
}
360
364
}
361
365
366
+ /// Do not call this method! Use either `assert_bits` or `force_bits`.
362
367
#[ inline]
363
368
pub fn to_bits ( self , target_size : Size ) -> InterpResult < ' tcx , u128 > {
364
369
match self {
@@ -372,6 +377,12 @@ impl<'tcx, Tag> Scalar<Tag> {
372
377
}
373
378
}
374
379
380
+ #[ inline( always) ]
381
+ pub fn assert_bits ( self , target_size : Size ) -> u128 {
382
+ self . to_bits ( target_size) . expect ( "Expected Raw bits but got a Pointer" )
383
+ }
384
+
385
+ /// Do not call this method! Use either `assert_ptr` or `force_ptr`.
375
386
#[ inline]
376
387
pub fn to_ptr ( self ) -> InterpResult < ' tcx , Pointer < Tag > > {
377
388
match self {
@@ -381,6 +392,12 @@ impl<'tcx, Tag> Scalar<Tag> {
381
392
}
382
393
}
383
394
395
+ #[ inline( always) ]
396
+ pub fn assert_ptr ( self ) -> Pointer < Tag > {
397
+ self . to_ptr ( ) . expect ( "Expected a Pointer but got Raw bits" )
398
+ }
399
+
400
+ /// Do not call this method! Dispatch based on the type instead.
384
401
#[ inline]
385
402
pub fn is_bits ( self ) -> bool {
386
403
match self {
@@ -389,6 +406,7 @@ impl<'tcx, Tag> Scalar<Tag> {
389
406
}
390
407
}
391
408
409
+ /// Do not call this method! Dispatch based on the type instead.
392
410
#[ inline]
393
411
pub fn is_ptr ( self ) -> bool {
394
412
match self {
@@ -536,11 +554,13 @@ impl<'tcx, Tag> ScalarMaybeUndef<Tag> {
536
554
}
537
555
}
538
556
557
+ /// Do not call this method! Use either `assert_ptr` or `force_ptr`.
539
558
#[ inline( always) ]
540
559
pub fn to_ptr ( self ) -> InterpResult < ' tcx , Pointer < Tag > > {
541
560
self . not_undef ( ) ?. to_ptr ( )
542
561
}
543
562
563
+ /// Do not call this method! Use either `assert_bits` or `force_bits`.
544
564
#[ inline( always) ]
545
565
pub fn to_bits ( self , target_size : Size ) -> InterpResult < ' tcx , u128 > {
546
566
self . not_undef ( ) ?. to_bits ( target_size)
0 commit comments