Skip to content

Commit ac617b6

Browse files
author
bcoopers
committed
The panic! macro can't be called with a variable declared
with "let" when building on stage0. So change the error message to a static const.
1 parent f8493d0 commit ac617b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcollections/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ impl<T> Vec<T> {
309309
#[stable(feature = "rust1", since = "1.0.0")]
310310
pub fn reserve(&mut self, additional: usize) {
311311
if self.cap - self.len < additional {
312-
let err_msg = "Vec::reserve: `isize` overflow";
312+
const ERR_MSG: &'static str = "Vec::reserve: `isize` overflow";
313313

314-
let new_min_cap = self.len.checked_add(additional).expect(err_msg);
315-
if new_min_cap > MAX_MEMORY_SIZE { panic!(err_msg) }
314+
let new_min_cap = self.len.checked_add(additional).expect(ERR_MSG);
315+
if new_min_cap > MAX_MEMORY_SIZE { panic!(ERR_MSG) }
316316
self.grow_capacity(match new_min_cap.checked_next_power_of_two() {
317317
Some(x) if x > MAX_MEMORY_SIZE => MAX_MEMORY_SIZE,
318318
None => MAX_MEMORY_SIZE,

0 commit comments

Comments
 (0)