Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ impl<T, A: Allocator> RawVec<T, A> {
if self.needs_to_grow(len, additional) {
do_reserve_and_handle(self, len, additional);
}

unsafe {
// Inform the optimizer that the reservation has succeeded or wasn't needed
core::intrinsics::assume(!self.needs_to_grow(len, additional));
}
}

/// A specialized version of `reserve()` used only by the hot and
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/hygiene/panic-location.run.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
thread 'main' panicked at library/alloc/src/raw_vec.rs:545:5:
thread 'main' panicked at library/alloc/src/raw_vec.rs:550:5:
capacity overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace