Skip to content

Comments

refactor(data_structures)!: make NonEmptyStack::is_empty a compile-time error#13673

Merged
graphite-app[bot] merged 1 commit intomainfrom
09-11-refactor_data_structures_make_nonemptystack_is_empty_a_compile-time_error
Sep 11, 2025
Merged

refactor(data_structures)!: make NonEmptyStack::is_empty a compile-time error#13673
graphite-app[bot] merged 1 commit intomainfrom
09-11-refactor_data_structures_make_nonemptystack_is_empty_a_compile-time_error

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Sep 11, 2025

Continuation from #13672.

Calling NonEmptyStack::is_empty is always a logic error. NonEmptyStack can never be empty, and NonEmptyStack::is_exhausted is very likely what was intended.

Make calling NonEmptyStack::is_empty a compile-time error, to prevent this erroneous usage.

Ideally, we'd remove the method entirely, but &NonEmptyStack<T> derefs to &[T], so without defining is_empty method on NonEmptyStack, stack.is_empty() falls through to [T]::is_empty, which is not what we want.

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

overlookmotel commented Sep 11, 2025


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 11, 2025

CodSpeed Instrumentation Performance Report

Merging #13673 will not alter performance

Comparing 09-11-refactor_data_structures_make_nonemptystack_is_empty_a_compile-time_error (e433633) with main (8f37e88)1

Summary

✅ 37 untouched benchmarks

Footnotes

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

@overlookmotel overlookmotel marked this pull request as ready for review September 11, 2025 05:54
@overlookmotel overlookmotel force-pushed the 09-11-feat_data_structures_add_is_exhausted_method_to_nonemptystack_and_sparsestack_ branch from d39f9d7 to a6e1ace Compare September 11, 2025 06:01
@overlookmotel overlookmotel force-pushed the 09-11-refactor_data_structures_make_nonemptystack_is_empty_a_compile-time_error branch from 71381d1 to 41f48d5 Compare September 11, 2025 06:01
@overlookmotel overlookmotel self-assigned this Sep 11, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Sep 11, 2025
Copy link
Member Author

overlookmotel commented Sep 11, 2025

Merge activity

…time error (#13673)

Continuation from #13672.

Calling `NonEmptyStack::is_empty` is always a logic error. `NonEmptyStack` can never be empty, and `NonEmptyStack::is_exhausted` is very likely what was intended.

Make calling `NonEmptyStack::is_empty` a compile-time error, to prevent this erroneous usage.

Ideally, we'd remove the method entirely, but `&NonEmptyStack<T>` derefs to `&[T]`, so without defining `is_empty` method on `NonEmptyStack`, `stack.is_empty()` falls through to `[T]::is_empty`, which is not what we want.
@graphite-app graphite-app bot force-pushed the 09-11-feat_data_structures_add_is_exhausted_method_to_nonemptystack_and_sparsestack_ branch from a6e1ace to 1a58e99 Compare September 11, 2025 06:06
@graphite-app graphite-app bot force-pushed the 09-11-refactor_data_structures_make_nonemptystack_is_empty_a_compile-time_error branch from 41f48d5 to e433633 Compare September 11, 2025 06:07
Base automatically changed from 09-11-feat_data_structures_add_is_exhausted_method_to_nonemptystack_and_sparsestack_ to main September 11, 2025 06:11
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 11, 2025
@graphite-app graphite-app bot merged commit e433633 into main Sep 11, 2025
27 checks passed
@graphite-app graphite-app bot deleted the 09-11-refactor_data_structures_make_nonemptystack_is_empty_a_compile-time_error branch September 11, 2025 06:12
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.

1 participant