Skip to content

tests/ui: A New Order [21/N] #143296

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

Merged
merged 2 commits into from
Jul 5, 2025
Merged

tests/ui: A New Order [21/N] #143296

merged 2 commits into from
Jul 5, 2025

Conversation

Kivooeo
Copy link
Contributor

@Kivooeo Kivooeo commented Jul 1, 2025

Note

Intermediate commits are intended to help review, but will be squashed prior to merge.

Some tests/ui/ housekeeping, to trim down number of tests directly under tests/ui/. Part of #133895.

r? @tgross35

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 1, 2025
Comment on lines 3 to 4
//! Verifies that Option<T> has the same size as T for nullable pointer types,
//! and that custom enums get the same optimization.
Copy link
Contributor

Choose a reason for hiding this comment

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

Slight correction

Suggested change
//! Verifies that Option<T> has the same size as T for nullable pointer types,
//! and that custom enums get the same optimization.
//! Verifies that Option<T> has the same size as T for non-nullable pointer types,
//! and for custom enums that have a niche.

@@ -1,27 +1,34 @@
//@ run-pass
//! Nullable pointer optimization with iota-reduction for enums.
Copy link
Contributor

Choose a reason for hiding this comment

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

The term should be "null pointer optimization", not "nullable"; because types like &T and Box<T> are not nullable.

Also for the file name

@@ -1,31 +1,41 @@
//! Nullable pointer optimization preserves type sizes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nullable -> Null (also the file name)

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Few small comments, please also squash!

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 4, 2025
@Kivooeo
Copy link
Contributor Author

Kivooeo commented Jul 4, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 4, 2025
@@ -1,31 +1,41 @@
//! null pointer optimization preserves type sizes.
//!
//! Verifies that Option<T> has the same size as T for null pointer types,
Copy link
Contributor

Choose a reason for hiding this comment

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

"null" -> "non-nullable" (A strictly-null pointer type would be a ZST :D )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

names also should be non-null in both tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm, just hopes that not, pushed as it replaced null with non-null

Copy link
Contributor

@tgross35 tgross35 Jul 4, 2025

Choose a reason for hiding this comment

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

So for some context here: NPO (null pointer optimization) is an optimization on non-nullable pointer types (&T, Box<T>, etc) using the null representation. (I know, a bit confusing). Basically it knows that &T has an identical layout to *T; but &T can never be 0x0, because that it's a non-nullable type. So that is what's known as a "niche", and it can use that to store something; e.g. for Option<&T>, 0x0 means None (since it can't be &T) and any other value is Some(&T).

All that to say that comment should be "...same size as T for non-nullable pointer types", since the type has to be non-nullable for NPO to mean anything (so what you have is 👍). And then the test could be named null-pointer-optimization-sizes.rs or npo-sizes.rs (keeping null-pointer-optimization together rather than putting size in the middle)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so last changes should be fine, thanks for detailed explanation!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, wait need some adjustments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now i believe should be fine

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I was asking for one last thing 😄 null-pointer-size-optimization.rs -> null-pointer-optimization-sizes.rs since "null pointer optimization" is a phrase

Looks like it's still at tests/ui/layout/null-pointer-size-optimization.rs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait again then! for some reasons this message didnt rendered on my side 0_0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ready, also recheck comments in those tests

@Kivooeo Kivooeo force-pushed the tf21 branch 2 times, most recently from 50f65e8 to 1778762 Compare July 4, 2025 20:21
@tgross35
Copy link
Contributor

tgross35 commented Jul 4, 2025

Thank you!
@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 4, 2025

📌 Commit 62ada47 has been approved by tgross35

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 4, 2025
bors added a commit that referenced this pull request Jul 5, 2025
Rollup of 11 pull requests

Successful merges:

 - #142440 (`tests/ui`: A New Order [14/N])
 - #143040 (Add `const Rem`)
 - #143086 (Update poison.rs to fix the typo (sys->sync))
 - #143202 (`tests/ui`: A New Order [18/N])
 - #143296 (`tests/ui`: A New Order [21/N])
 - #143297 (`tests/ui`: A New Order [22/N])
 - #143299 (`tests/ui`: A New Order [24/N])
 - #143300 (`tests/ui`: A New Order [25/N])
 - #143397 (test passing a `VaList` from rust to C)
 - #143410 (Block SIMD in transmute_immediate; delete `OperandValueKind`)
 - #143452 (Fix CLI completion check in `tidy`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 19a7f0f into rust-lang:master Jul 5, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 5, 2025
rust-timer added a commit that referenced this pull request Jul 5, 2025
Rollup merge of #143296 - Kivooeo:tf21, r=tgross35

`tests/ui`: A New Order [21/N]

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of #133895.

r? `@tgross35`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants