Commit graph

3 commits

Author SHA1 Message Date
David Tolnay
2727413c10 edition: Update assertions crate to 2018 edition
Separated out of CL:1513058 to make it possible to land parts
individually while the affected crate has no other significant CLs
pending. This avoids repeatedly introducing non-textual conflicts with
new code that adds `use` statements.

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I99843b923094e4df7a139f22a30eb19527d11d98
Reviewed-on: https://chromium-review.googlesource.com/1519689
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-03-13 21:05:03 -07:00
paulhsia
d1eceeca7b crosvm: Split sub-crates into independent workspace
Split sub-crates under crosvm root directory into several independent
workspaces for adding ebuild files for those crates.

data_model and sys_util could only be built by emerge after creating
their ebuilds.

BUG=chromium:916921
TEST='emerge-eve crosvm'
TEST=Run 'cargo build' under crosvm directory

Change-Id: I2dddbbb7c7344e643183a5885e867f134b299591
Reviewed-on: https://chromium-review.googlesource.com/1385972
Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-01-03 15:04:23 -08:00
David Tolnay
3c0aac44d7 assertions: Add compile-time assertion macro
A static assertion is particularly appropriate when unsafe code relies
on two types to have the same size, or on some type to have a particular
size. This is a pattern I observed in USB code, for example:

ff7068402e/devices/src/usb/xhci/xhci_abi_schema.rs (522)

EXAMPLE:

    extern crate assertions;
    use assertions::const_assert;

    fn main() {
        const_assert!(std::mem::size_of::<String>() == 24);
    }

EXAMPLE THAT FAILS TO COMPILE:

    extern crate assertions;
    use assertions::const_assert;

    fn main() {
        // fails to compile:
        const_assert!(std::mem::size_of::<String>() == 8);
    }

FAILURE LOOKS LIKE:

    error[E0271]: type mismatch resolving `<[(); 0] as assertions::Expr>::Value == assertions::True`
     --> src/main.rs:5:5
      |
    5 |     const_assert!(std::mem::size_of::<String>() == 8);
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `assertions::True`, found struct `assertions::False`

TEST=`cargo test` the new crate

Change-Id: I6abe36d5a6a4bd4acb1a02e3aa7c1ece5357f007
Reviewed-on: https://chromium-review.googlesource.com/1366819
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-12-09 00:48:17 -08:00