Skip to content

Extra assertions and cargo features #618

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
Apr 7, 2017

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Apr 6, 2017

  • Clean up testing-only cargo features

    This commit ensures that all of the cargo features we have that only exist for
    CI/testing purposes, and aren't for external consumption, have a "testing_only_"
    prefix.

  • Define extra assertion macros

    This commit defines a new set of assertion macros that are only checked in
    testing/CI when the testing_only_extra_assertions feature is enabled. This
    makes it so that users of bindgen that happen to be making a debug build don't
    enable all these extra and expensive assertions.

    Additionally, this removes the testing_only_assert_no_dangling_items feature,
    and runs the assertions that were previously gated on that feature when the new
    testing_only_extra_assertions feature is enabled.

r? @emilio

This commit ensures that all of the cargo features we have that only exist for
CI/testing purposes, and aren't for external consumption, have a "testing_only_"
prefix.
current_bitfield_layout.is_some());
debug_assert_eq!(current_bitfield_width.is_some(),
extra_assert_eq!(current_bitfield_width.is_some(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to keep the cheap ones debug_assert_eq!s, etc, wdyt?

I believe this could hide real bugs.

This commit defines a new set of assertion macros that are only checked in
testing/CI when the `testing_only_extra_assertions` feature is enabled. This
makes it so that *users* of bindgen that happen to be making a debug build don't
enable all these extra and expensive assertions.

Additionally, this removes the `testing_only_assert_no_dangling_items` feature,
and runs the assertions that were previously gated on that feature when the new
`testing_only_extra_assertions` feature is enabled.
@fitzgen fitzgen force-pushed the extra-assertions branch from 2e14b19 to 5004ed4 Compare April 7, 2017 16:59
@fitzgen
Copy link
Member Author

fitzgen commented Apr 7, 2017

@emilio I went over each assertion, and if it was trivial, I left it as a debug_assert (note that all non-debug asserts were left alone). If it involved heap allocation or looping or anything non-trivial like that, I made it an extra_assert.

@emilio
Copy link
Contributor

emilio commented Apr 7, 2017

Looks great, thanks!

@bors-servo r+

@bors-servo
Copy link

📌 Commit 5004ed4 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 5004ed4 with merge 9d362ef...

bors-servo pushed a commit that referenced this pull request Apr 7, 2017
Extra assertions and cargo features

* Clean up testing-only cargo features

  This commit ensures that all of the cargo features we have that only exist for
  CI/testing purposes, and aren't for external consumption, have a "testing_only_"
  prefix.

* Define extra assertion macros

  This commit defines a new set of assertion macros that are only checked in
  testing/CI when the `testing_only_extra_assertions` feature is enabled. This
  makes it so that *users* of bindgen that happen to be making a debug build don't
  enable all these extra and expensive assertions.

  Additionally, this removes the `testing_only_assert_no_dangling_items` feature,
  and runs the assertions that were previously gated on that feature when the new
  `testing_only_extra_assertions` feature is enabled.

r? @emilio
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: emilio
Pushing 9d362ef to master...

@bors-servo bors-servo merged commit 5004ed4 into rust-lang:master Apr 7, 2017
@fitzgen fitzgen deleted the extra-assertions branch April 7, 2017 23:35
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.

4 participants