Skip to content

Conversation

@michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented May 9, 2019

This PR implements a minimal version of file format compatibility checking.

r? @wesleywiser

Closes #40

bytes: &[u8],
expected_magic: &[u8; 4]
) -> Result<u32, Box<dyn Error>> {
debug_assert_eq!(FILE_HEADER_SIZE, 8);
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused by these asserts -- they don't need to be debug as I expect LLVM to constant-fold them away, and either way I'm not sure what this is intended to do (i.e., because we're comparing against a constant declared in this file). Maybe a comment on the constant that these functions need updating would be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

The assertions are meant to be an extra safeguard against accidentally changing something here. I'd like to leave them in (since it's easy to overlook a comment but not so easy to overlook CI going red). I'll add some comments explaining their purpose though.

@michaelwoerister
Copy link
Member Author

I've added some comments and tried to address @Mark-Simulacrum's remarks.

@wesleywiser wesleywiser merged commit 86e555e into rust-lang:master May 10, 2019
@wesleywiser wesleywiser mentioned this pull request May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add versioning to the binary profile format

3 participants