Skip to content

refactor(allocator/vec): use assert_unchecked over unreachable_unchecked#15511

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-09-refactor_allocator_vec_use_assert_unchecked_over_unreachable_unchecked_
Nov 9, 2025
Merged

refactor(allocator/vec): use assert_unchecked over unreachable_unchecked#15511
graphite-app[bot] merged 1 commit intomainfrom
11-09-refactor_allocator_vec_use_assert_unchecked_over_unreachable_unchecked_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 9, 2025

Pure refactor. Use the newer assert_unchecked function instead of unreachable_unchecked. This does exactly the same thing, but is clearer.

Also add a comment as to why this code exists.

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Nov 9, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review November 9, 2025 09:36
Copilot AI review requested due to automatic review settings November 9, 2025 09:36
@overlookmotel
Copy link
Member Author

Small change, so merging without review.

@overlookmotel overlookmotel self-assigned this Nov 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the pointer null-check assertions in Vec::as_ptr() and Vec::as_mut_ptr() methods to use the more direct std::hint::assert_unchecked function instead of the previous pattern using hint::unreachable_unchecked().

  • Replaced conditional unreachable_unchecked() calls with direct assert_unchecked() calls
  • Updated the import from hint to hint::assert_unchecked for direct function access
  • Simplified and modernized the implementation while maintaining identical semantics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 9, 2025

CodSpeed Performance Report

Merging #15511 will not alter performance

Comparing 11-09-refactor_allocator_vec_use_assert_unchecked_over_unreachable_unchecked_ (ffa9d76) with main (6f3cd77)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on main (25d577e) during the generation of this report, so 6f3cd77 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel force-pushed the 11-09-refactor_allocator_vec_use_assert_unchecked_over_unreachable_unchecked_ branch from 4736143 to ffa9d76 Compare November 9, 2025 10:29
@overlookmotel
Copy link
Member Author

overlookmotel commented Nov 9, 2025

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Nov 9, 2025
Copy link
Member Author

overlookmotel commented Nov 9, 2025

Merge activity

…hecked` (#15511)

Pure refactor. Use the newer `assert_unchecked` function instead of `unreachable_unchecked`. This does exactly the same thing, but is clearer.

Also add a comment as to why this code exists.
@graphite-app graphite-app bot force-pushed the 11-09-refactor_allocator_vec_use_assert_unchecked_over_unreachable_unchecked_ branch from ffa9d76 to 31718a8 Compare November 9, 2025 10:54
@graphite-app graphite-app bot merged commit 31718a8 into main Nov 9, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 11-09-refactor_allocator_vec_use_assert_unchecked_over_unreachable_unchecked_ branch November 9, 2025 11:00
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 9, 2025
Copilot AI pushed a commit that referenced this pull request Nov 9, 2025
…hecked` (#15511)

Pure refactor. Use the newer `assert_unchecked` function instead of `unreachable_unchecked`. This does exactly the same thing, but is clearer.

Also add a comment as to why this code exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants