File tree 4 files changed +11
-11
lines changed
rustc_middle/src/mir/interpret
rustc_query_system/src/dep_graph
4 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ impl AllocDecodingState {
285
285
let counter = DECODER_SESSION_ID . fetch_add ( 1 , Ordering :: SeqCst ) ;
286
286
287
287
// Make sure this is never zero.
288
- let session_id = DecodingSessionId :: new ( ( counter & 0x7FFFFFFF ) + 1 ) . unwrap ( ) ;
288
+ let session_id = DecodingSessionId :: new ( ( counter & 0x7FFFFFFF ) . wrapping_add ( 1 ) ) . unwrap ( ) ;
289
289
290
290
AllocDecodingSession { state : self , session_id }
291
291
}
Original file line number Diff line number Diff line change @@ -101,14 +101,14 @@ impl SerializedDepGraph {
101
101
// edge list, or the end of the array if this is the last edge.
102
102
let end = self
103
103
. edge_list_indices
104
- . get ( source + 1 )
104
+ . get ( SerializedDepNodeIndex :: from_usize ( source. index ( ) . wrapping_add ( 1 ) ) )
105
105
. map ( |h| h. start ( ) )
106
- . unwrap_or_else ( || self . edge_list_data . len ( ) - DEP_NODE_PAD ) ;
106
+ . unwrap_or_else ( || self . edge_list_data . len ( ) . wrapping_sub ( DEP_NODE_PAD ) ) ;
107
107
108
108
// The number of edges for this node is implicitly stored in the combination of the byte
109
109
// width and the length.
110
110
let bytes_per_index = header. bytes_per_index ( ) ;
111
- let len = ( end - header. start ( ) ) / bytes_per_index;
111
+ let len = ( end. wrapping_sub ( header. start ( ) ) ) / bytes_per_index;
112
112
113
113
// LLVM doesn't hoist EdgeHeader::mask so we do it ourselves.
114
114
let mask = header. mask ( ) ;
Original file line number Diff line number Diff line change @@ -24,15 +24,15 @@ macro_rules! impl_write_unsigned_leb128 {
24
24
* out. get_unchecked_mut( i) = value as u8 ;
25
25
}
26
26
27
- i += 1 ;
27
+ i = i . wrapping_add ( 1 ) ;
28
28
break ;
29
29
} else {
30
30
unsafe {
31
31
* out. get_unchecked_mut( i) = ( ( value & 0x7f ) | 0x80 ) as u8 ;
32
32
}
33
33
34
34
value >>= 7 ;
35
- i += 1 ;
35
+ i = i . wrapping_add ( 1 ) ;
36
36
}
37
37
}
38
38
@@ -60,7 +60,7 @@ macro_rules! impl_read_unsigned_leb128 {
60
60
return byte as $int_ty;
61
61
}
62
62
let mut result = ( byte & 0x7F ) as $int_ty;
63
- let mut shift = 7 ;
63
+ let mut shift = 7_usize ;
64
64
loop {
65
65
let byte = decoder. read_u8( ) ;
66
66
if ( byte & 0x80 ) == 0 {
@@ -69,7 +69,7 @@ macro_rules! impl_read_unsigned_leb128 {
69
69
} else {
70
70
result |= ( ( byte & 0x7F ) as $int_ty) << shift;
71
71
}
72
- shift += 7 ;
72
+ shift = shift . wrapping_add ( 7 ) ;
73
73
}
74
74
}
75
75
} ;
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ impl FileEncoder {
65
65
// Tracking position this way instead of having a `self.position` field
66
66
// means that we only need to update `self.buffered` on a write call,
67
67
// as opposed to updating `self.position` and `self.buffered`.
68
- self . flushed + self . buffered
68
+ self . flushed . wrapping_add ( self . buffered )
69
69
}
70
70
71
71
#[ cold]
@@ -119,7 +119,7 @@ impl FileEncoder {
119
119
}
120
120
if let Some ( dest) = self . buffer_empty ( ) . get_mut ( ..buf. len ( ) ) {
121
121
dest. copy_from_slice ( buf) ;
122
- self . buffered += buf. len ( ) ;
122
+ self . buffered = self . buffered . wrapping_add ( buf. len ( ) ) ;
123
123
} else {
124
124
self . write_all_cold_path ( buf) ;
125
125
}
@@ -158,7 +158,7 @@ impl FileEncoder {
158
158
if written > N {
159
159
Self :: panic_invalid_write :: < N > ( written) ;
160
160
}
161
- self . buffered += written;
161
+ self . buffered = self . buffered . wrapping_add ( written) ;
162
162
}
163
163
164
164
#[ cold]
You can’t perform that action at this time.
0 commit comments