Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vec::try_with_capacity #120504

Merged
merged 3 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Move capacity_overflow function to make ui tests change less
Code changes in raw_vec require blessing UI tests every time
  • Loading branch information
kornelski committed Mar 1, 2024
commit 784e6a1e080e5ba18e5c246e744e2d20525d1c3d
18 changes: 9 additions & 9 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 17,15 @@ use crate::collections::TryReserveErrorKind::*;
#[cfg(test)]
mod tests;

// One central function responsible for reporting capacity overflows. This'll
// ensure that the code generation related to these panics is minimal as there's
// only one location which panics rather than a bunch throughout the module.
#[cfg(not(no_global_oom_handling))]
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
fn capacity_overflow() -> ! {
panic!("capacity overflow");
}

enum AllocInit {
/// The contents of the new memory are uninitialized.
Uninitialized,
Expand Down Expand Up @@ -576,12 585,3 @@ fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
Ok(())
}
}

// One central function responsible for reporting capacity overflows. This'll
// ensure that the code generation related to these panics is minimal as there's
// only one location which panics rather than a bunch throughout the module.
#[cfg(not(no_global_oom_handling))]
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
fn capacity_overflow() -> ! {
panic!("capacity overflow");
}
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:571:5:
thread 'main' panicked at library/alloc/src/raw_vec.rs:26:5:
capacity overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Loading