Skip to content

Commit aa5ad03

Browse files
authored
Fix undefined behaviour by removing MayebUninit usage (v2) (#5)
* 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
1 parent ea8e270 commit aa5ad03

27 files changed

+1431
-702
lines changed

.github/workflows/ci.yml

+51-23
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,16 @@ jobs:
3030
uses: actions-rs/toolchain@v1
3131
with:
3232
toolchain: ${{ matrix.rust }}
33+
profile: minimal
3334
override: true
3435

35-
- name: Check without default features
36-
run: |
37-
cargo check --all \
38-
--no-default-features
39-
40-
- name: Check with the default features
41-
run: |
42-
cargo check --all
36+
- name: Install power tools
37+
uses: taiki-e/install-action@cargo-hack
4338

44-
- name: Check with all features
39+
- name: Check the powerset
4540
run: |
46-
cargo check --all \
47-
--all-features
41+
cargo hack check --all \
42+
--feature-powerset --keep-going
4843
4944
test:
5045
name: Test Suite
@@ -62,11 +57,16 @@ jobs:
6257
uses: actions-rs/toolchain@v1
6358
with:
6459
toolchain: ${{ matrix.rust }}
60+
profile: minimal
6561
override: true
62+
63+
- name: Install power tools
64+
uses: taiki-e/install-action@cargo-hack
6665

67-
- name: Run the test-suite
66+
- name: Run the test-suite powerset
6867
run: |
69-
cargo test --workspace --no-fail-fast
68+
cargo hack test --workspace \
69+
--no-fail-fast --feature-powerset --keep-going
7070
7171
fmt:
7272
name: Rustfmt
@@ -80,6 +80,7 @@ jobs:
8080
uses: actions-rs/toolchain@v1
8181
with:
8282
toolchain: nightly
83+
profile: minimal
8384
components: rustfmt
8485
override: true
8586

@@ -102,22 +103,49 @@ jobs:
102103
uses: actions-rs/toolchain@v1
103104
with:
104105
toolchain: ${{ matrix.rust }}
106+
profile: minimal
105107
components: clippy
106108
override: true
107109

108-
- name: Check the code style without default features
110+
- name: Install power tools
111+
uses: taiki-e/install-action@cargo-hack
112+
113+
- name: Check the code style powerset
109114
run: |
110-
cargo clippy --all \
111-
--no-default-features \
115+
cargo hack clippy --all \
116+
--feature-powerset --keep-going \
112117
-- -D warnings
113118
114-
- name: Check the code style with the default features
119+
miri:
120+
name: Miri
121+
runs-on: ${{ matrix.os }}
122+
strategy:
123+
matrix:
124+
os: [ubuntu-latest]
125+
rust: [nightly]
126+
127+
steps:
128+
- name: Checkout the Repository
129+
uses: actions/checkout@v2
130+
131+
- name: Install the Rust toolchain
132+
uses: actions-rs/toolchain@v1
133+
with:
134+
toolchain: ${{ matrix.rust }}
135+
profile: minimal
136+
components: miri, rust-src
137+
override: true
138+
139+
- name: Install power tools
140+
uses: taiki-e/install-action@cargo-hack
141+
142+
- name: Run the miri powerset tests
115143
run: |
116-
cargo clippy --all \
117-
-- -D warnings
144+
cargo hack miri test --workspace \
145+
--no-fail-fast --feature-powerset --keep-going
118146
119-
- name: Check the code style with all features
147+
- name: Run the miri trycrate powerset
120148
run: |
121-
cargo clippy --all \
122-
--all-features \
123-
-- -D warnings
149+
cd try-crate
150+
cargo hack miri run \
151+
--feature-powerset --keep-going

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "const-type-layout"
33
description = "Derivable trait to view the layout of a struct, useful for debugging."
44
version = "0.1.0"
55
edition = "2021"
6-
authors = ["Momo Langenstein <momo[email protected]>", "Lucien Greathouse <[email protected]>"]
6+
authors = ["Juniper Langenstein <juniper[email protected]>", "Lucien Greathouse <[email protected]>"]
77
documentation = "https://momolangenstein.github.io/const-type-layout/const_type_layout/"
88
homepage = "https://github.com/MomoLangenstein/const-type-layout"
99
repository = "https://github.com/MomoLangenstein/const-type-layout"

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# const-type-layout &emsp; [![CI Status]][workflow] [![Rust Doc]][docs] [![License Status]][fossa] [![Code Coverage]][codecov] [![Gitpod Ready-to-Code]][gitpod]
1+
# const-type-layout &emsp; [![CI Status]][workflow] [![MSRV]][repo] [![Rust Doc]][docs] [![License Status]][fossa] [![Code Coverage]][codecov] [![Gitpod Ready-to-Code]][gitpod]
22

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

6+
[MSRV]: https://img.shields.io/badge/MSRV-1.60.0-orange
7+
[repo]: https://github.com/ron-rs/ron
8+
69
[Rust Doc]: https://img.shields.io/badge/docs-main-blue
710
[docs]: https://momolangenstein.github.io/const-type-layout/const_type_layout
811

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

3437
```rust
35-
use type_layout::TypeLayout;
38+
use const_type_layout::TypeLayout;
3639

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

7275
```rust
73-
use type_layout::TypeLayout;
76+
use const_type_layout::TypeLayout;
7477

7578
#[derive(TypeLayout)]
7679
#[repr(C, align(128))]

const-type-layout-derive/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "const-type-layout-derive"
33
description = "Derive macro implementation for const-type-layout crate"
44
version = "0.1.0"
55
edition = "2021"
6-
authors = ["Momo Langenstein <momo[email protected]>", "Lucien Greathouse <[email protected]>"]
6+
authors = ["Juniper Langenstein <juniper[email protected]>", "Lucien Greathouse <[email protected]>"]
77
homepage = "https://github.com/MomoLangenstein/const-type-layout"
88
license = "MIT OR Apache-2.0"
99

0 commit comments

Comments
 (0)