1
- use std:: fmt:: { self , Display } ;
2
- use std:: convert:: TryFrom ;
1
+ use super :: { AllocId , InterpResult } ;
3
2
4
3
use crate :: mir;
5
4
use crate :: ty:: layout:: { self , HasDataLayout , Size } ;
5
+
6
6
use rustc_macros:: HashStable ;
7
7
8
- use super :: { AllocId , InterpResult } ;
8
+ use std:: convert:: TryFrom ;
9
+ use std:: fmt:: { self , Display } ;
9
10
10
11
/// Used by `check_in_alloc` to indicate context of check
11
12
#[ derive( Debug , Copy , Clone , RustcEncodable , RustcDecodable , HashStable ) ]
@@ -74,8 +75,8 @@ pub trait PointerArithmetic: layout::HasDataLayout {
74
75
fn overflowing_signed_offset ( & self , val : u64 , i : i128 ) -> ( u64 , bool ) {
75
76
// FIXME: is it possible to over/underflow here?
76
77
if i < 0 {
77
- // Trickery to ensure that i64::min_value() works fine: compute n = -i.
78
- // This formula only works for true negative values, it overflows for zero!
78
+ // Trickery to ensure that ` i64::min_value()` works fine: compute ` n = -i` .
79
+ // This formula only works for true negative values; it overflows for zero!
79
80
let n = u64:: max_value ( ) - ( i as u64 ) + 1 ;
80
81
let res = val. overflowing_sub ( n) ;
81
82
self . truncate_to_ptr ( res)
@@ -105,7 +106,7 @@ impl<T: layout::HasDataLayout> PointerArithmetic for T {}
105
106
///
106
107
/// Defaults to the index based and loosely coupled `AllocId`.
107
108
///
108
- /// Pointer is also generic over the `Tag` associated with each pointer,
109
+ /// ` Pointer` is also generic over the `Tag` associated with each pointer,
109
110
/// which is used to do provenance tracking during execution.
110
111
#[ derive( Copy , Clone , Eq , PartialEq , Ord , PartialOrd ,
111
112
RustcEncodable , RustcDecodable , Hash , HashStable ) ]
@@ -129,7 +130,7 @@ impl<Id: fmt::Debug> fmt::Debug for Pointer<(), Id> {
129
130
}
130
131
}
131
132
132
- /// Produces a `Pointer` which points to the beginning of the `Allocation`.
133
+ /// Produces a `Pointer` that points to the beginning of the `Allocation`.
133
134
impl From < AllocId > for Pointer {
134
135
#[ inline( always) ]
135
136
fn from ( alloc_id : AllocId ) -> Self {
0 commit comments