Skip to content

Commit 5108988

Browse files
committed
Use std::isize::MAX instead of isize::MAX
isize::MAX not working on Rust 1.42.0
1 parent a5f40fe commit 5108988

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sailfish/src/runtime/buffer.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ impl Buffer {
100100
/// This method panics if `size` overflows `isize::MAX`.
101101
#[inline]
102102
pub fn reserve(&mut self, size: usize) {
103-
assert!(size <= isize::MAX as usize);
103+
assert!(size <= std::isize::MAX as usize);
104104
unsafe { self.reserve_small(size) };
105105
}
106106

107107
/// Same as String::reserve except that undefined behaviour can result if `size`
108108
/// overflows `isize::MAX`.
109109
#[inline]
110110
pub(crate) unsafe fn reserve_small(&mut self, size: usize) {
111-
debug_assert!(size <= isize::MAX as usize);
111+
debug_assert!(size <= std::isize::MAX as usize);
112112
if self.len + size <= self.capacity {
113113
return;
114114
}
@@ -161,7 +161,7 @@ impl Buffer {
161161
#[cfg_attr(feature = "perf-inline", inline)]
162162
#[cold]
163163
fn reserve_internal(&mut self, size: usize) {
164-
debug_assert!(size <= isize::MAX as usize);
164+
debug_assert!(size <= std::isize::MAX as usize);
165165

166166
let new_capacity = std::cmp::max(self.capacity * 2, self.capacity + size);
167167
debug_assert!(new_capacity > self.capacity);
@@ -176,7 +176,10 @@ impl Buffer {
176176
#[inline(never)]
177177
fn safe_alloc(capacity: usize) -> *mut u8 {
178178
assert!(capacity > 0);
179-
assert!(capacity <= isize::MAX as usize, "capacity is too large");
179+
assert!(
180+
capacity <= std::isize::MAX as usize,
181+
"capacity is too large"
182+
);
180183

181184
// SAFETY: capacity is non-zero, and always multiple of alignment (1).
182185
unsafe {
@@ -198,7 +201,10 @@ fn safe_alloc(capacity: usize) -> *mut u8 {
198201
#[inline(never)]
199202
unsafe fn safe_realloc(ptr: *mut u8, capacity: usize, new_capacity: usize) -> *mut u8 {
200203
assert!(new_capacity > 0);
201-
assert!(new_capacity <= isize::MAX as usize, "capacity is too large");
204+
assert!(
205+
new_capacity <= std::isize::MAX as usize,
206+
"capacity is too large"
207+
);
202208

203209
let data = if unlikely!(capacity == 0) {
204210
let new_layout = Layout::from_size_align_unchecked(new_capacity, 1);

0 commit comments

Comments
 (0)