Skip to content
New issue

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

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

Already on GitHub? # to your account

Don't assume primitive type alignments #118

Merged
merged 1 commit into from
Nov 5, 2022
Merged

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Nov 3, 2022

Previously, we used the u16 and u64 types in a number of tests,
relying on them having the alignments 2 and 8 respectively. While those
types have those alignments on many platforms, those are not guaranteed
to be their alignments on all platforms. In this commit, we replace
most of these uses with types of the same size but guaranteed alignment.
In a few places, we have to leave the uses as-is, but this isn't a big
deal since our tests run in CI on platforms where the alignments are
actually the values we're relying upon.

Closes #116

@joshlf joshlf force-pushed the primitive-alignments branch 4 times, most recently from 3a580a9 to 4483f9f Compare November 3, 2022 06:07
@joshlf
Copy link
Member Author

joshlf commented Nov 3, 2022

Hey @djkoloski , mind reviewing this one? (Looks like I can't add you as a reviewer, at least not yet - I might be able to once you've commented on this thread)

@joshlf joshlf changed the title [WIP] Don't assume primitive type alignments Don't assume primitive type alignments Nov 3, 2022
@djkoloski
Copy link
Member

Yep, feel free to add me as a reviewer. 🙂

djkoloski
djkoloski previously approved these changes Nov 3, 2022
Copy link
Member

@djkoloski djkoloski left a comment

Choose a reason for hiding this comment

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

It would be neat if we could put this helper type in a mod, but I like how simple the test glob is in trybuild.rs. Maybe if more commonly used helper types are added, we could add some extra logic to handle that.

@joshlf
Copy link
Member Author

joshlf commented Nov 3, 2022

Do you think it'd be worth using include!?

@djkoloski
Copy link
Member

Eh, include! for source is also pretty nasty. Maybe we could add the module, keep the glob, and "test" that the helper module doesn't have any compiler errors?

@joshlf
Copy link
Member Author

joshlf commented Nov 3, 2022

Good call; done! I was able to use the #[path = ...] attribute to make the file usable from both UI and non-UI tests.

@joshlf joshlf requested a review from djkoloski November 3, 2022 19:34
Previously, we used the `u16` and `u64` types in a number of tests,
relying on them having the alignments 2 and 8 respectively. While those
types have those alignments on many platforms, those are not guaranteed
to be their alignments on all platforms. In this commit, we replace
most of these uses with types of the same size but guaranteed alignment.
In a few places, we have to leave the uses as-is, but this isn't a big
deal since our tests run in CI on platforms where the alignments are
actually the values we're relying upon.

Closes #116
@joshlf joshlf force-pushed the primitive-alignments branch from 077a639 to f424f1f Compare November 3, 2022 19:56
@joshlf joshlf merged commit bc3c9ac into main Nov 5, 2022
@joshlf joshlf deleted the primitive-alignments branch November 5, 2022 23:53
joshlf added a commit that referenced this pull request Aug 3, 2023
Previously, we used the `u16` and `u64` types in a number of tests,
relying on them having the alignments 2 and 8 respectively. While those
types have those alignments on many platforms, those are not guaranteed
to be their alignments on all platforms. In this commit, we replace
most of these uses with types of the same size but guaranteed alignment.
In a few places, we have to leave the uses as-is, but this isn't a big
deal since our tests run in CI on platforms where the alignments are
actually the values we're relying upon.

Closes #116
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't assume primitive alignments
2 participants