Skip to content

Commit

Permalink
Fix undefined behaviour by removing MayebUninit usage (v2) (#5)
Browse files Browse the repository at this point in the history
* Fix undefined behaviour by removing `MayebUninit` usage (#4)

* Experiments with less uninit

* Some more experimentation

* Some progress on box, ptr, ref (still no mut ref)

* Upgraded MSRV to 1.60.0

* Added more examples

* Mutable ref with const uninit fn

* Clean up const generation

* Removed core->alloc dependency for ptr+ref

* Removed extraneous Static type alias

* Feature `const_ptr_offset_from` stabilised in 1.65.0

* Added back derive attrs for custom PhantomData

* Cleaned up some TODOs

* Added the ! type

* Added the ground attribute

* Use power tools in CI

* Add miri to CI

* Explicit miri component in CI

* Removed rust-toolchain

* Clarified unsafe uninit() API by constructing MaybeUninit

* Added initial inhabited calculation

* Implemented uninit() for uninhabited types

* Fixed enum + union uninit order with #[layout(bound)]

* Ignore clippy::forget_copy

* Patch for rust-lang/rust#101932

* feature(let_else) is stable in 1.66

* Annotated traits with #[const_trait]

* Strengthen TypeGraphLayout bounds

* Small clippy fixes

* Fix TypeLayoutGraph::new const bound
  • Loading branch information
juntyr authored Oct 30, 2022
1 parent ea8e270 commit aa5ad03
Show file tree
Hide file tree
Showing 27 changed files with 1,431 additions and 702 deletions.
74 changes: 51 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,16 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true

- name: Check without default features
run: |
cargo check --all \
--no-default-features
- name: Check with the default features
run: |
cargo check --all
- name: Install power tools
uses: taiki-e/install-action@cargo-hack

- name: Check with all features
- name: Check the powerset
run: |
cargo check --all \
--all-features
cargo hack check --all \
--feature-powerset --keep-going
test:
name: Test Suite
Expand All @@ -62,11 +57,16 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true

- name: Install power tools
uses: taiki-e/install-action@cargo-hack

- name: Run the test-suite
- name: Run the test-suite powerset
run: |
cargo test --workspace --no-fail-fast
cargo hack test --workspace \
--no-fail-fast --feature-powerset --keep-going
fmt:
name: Rustfmt
Expand All @@ -80,6 +80,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt
override: true

Expand All @@ -102,22 +103,49 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
components: clippy
override: true

- name: Check the code style without default features
- name: Install power tools
uses: taiki-e/install-action@cargo-hack

- name: Check the code style powerset
run: |
cargo clippy --all \
--no-default-features \
cargo hack clippy --all \
--feature-powerset --keep-going \
-- -D warnings
- name: Check the code style with the default features
miri:
name: Miri
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust: [nightly]

steps:
- name: Checkout the Repository
uses: actions/checkout@v2

- name: Install the Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
components: miri, rust-src
override: true

- name: Install power tools
uses: taiki-e/install-action@cargo-hack

- name: Run the miri powerset tests
run: |
cargo clippy --all \
-- -D warnings
cargo hack miri test --workspace \
--no-fail-fast --feature-powerset --keep-going
- name: Check the code style with all features
- name: Run the miri trycrate powerset
run: |
cargo clippy --all \
--all-features \
-- -D warnings
cd try-crate
cargo hack miri run \
--feature-powerset --keep-going
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "const-type-layout"
description = "Derivable trait to view the layout of a struct, useful for debugging."
version = "0.1.0"
edition = "2021"
authors = ["Momo Langenstein <momo.langenstein@helsinki.fi>", "Lucien Greathouse <me@lpghatguy.com>"]
authors = ["Juniper Langenstein <juniper.langenstein@helsinki.fi>", "Lucien Greathouse <me@lpghatguy.com>"]
documentation = "https://momolangenstein.github.io/const-type-layout/const_type_layout/"
homepage = "https://github.com/MomoLangenstein/const-type-layout"
repository = "https://github.com/MomoLangenstein/const-type-layout"
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# const-type-layout &emsp; [![CI Status]][workflow] [![Rust Doc]][docs] [![License Status]][fossa] [![Code Coverage]][codecov] [![Gitpod Ready-to-Code]][gitpod]
# const-type-layout &emsp; [![CI Status]][workflow] [![MSRV]][repo] [![Rust Doc]][docs] [![License Status]][fossa] [![Code Coverage]][codecov] [![Gitpod Ready-to-Code]][gitpod]

[CI Status]: https://img.shields.io/github/workflow/status/MomoLangenstein/const-type-layout/CI/main?label=CI
[workflow]: https://github.com/MomoLangenstein/const-type-layout/actions/workflows/ci.yml?query=branch%3Amain

[MSRV]: https://img.shields.io/badge/MSRV-1.60.0-orange
[repo]: https://github.com/ron-rs/ron

[Rust Doc]: https://img.shields.io/badge/docs-main-blue
[docs]: https://momolangenstein.github.io/const-type-layout/const_type_layout

Expand Down Expand Up @@ -32,7 +35,7 @@ The layout of types is only defined if they're `#[repr(C)]`. This crate works on
non-`#[repr(C)]` types, but their layout is unpredictable.

```rust
use type_layout::TypeLayout;
use const_type_layout::TypeLayout;

#[derive(TypeLayout)]
#[repr(C)]
Expand Down Expand Up @@ -70,7 +73,7 @@ Over-aligned types have trailing padding, which can be a source of bugs in some
FFI scenarios:

```rust
use type_layout::TypeLayout;
use const_type_layout::TypeLayout;

#[derive(TypeLayout)]
#[repr(C, align(128))]
Expand Down
2 changes: 1 addition & 1 deletion const-type-layout-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "const-type-layout-derive"
description = "Derive macro implementation for const-type-layout crate"
version = "0.1.0"
edition = "2021"
authors = ["Momo Langenstein <momo.langenstein@helsinki.fi>", "Lucien Greathouse <me@lpghatguy.com>"]
authors = ["Juniper Langenstein <juniper.langenstein@helsinki.fi>", "Lucien Greathouse <me@lpghatguy.com>"]
homepage = "https://github.com/MomoLangenstein/const-type-layout"
license = "MIT OR Apache-2.0"

Expand Down
Loading

0 comments on commit aa5ad03

Please sign in to comment.