Skip to content

Commit

Permalink
generator: Emit new c"" CStr literals
Browse files Browse the repository at this point in the history
These will land in Rust 1.76 and automatically append a `\0` terminator
in the compiler without having to have a checked or `unsafe`-unchecked
constructor on `CStr`.

Hacking in an invalid `\0` anywhere in the string is disallowed with a
compiler error.

Note that `proc-macro`, and by extension `proc-macro2` only has support
for parsing this literal, but not for emitting it yet.
  • Loading branch information
MarijnS95 committed Dec 10, 2023
1 parent e6d80ba commit f6949e5
Show file tree
Hide file tree
Showing 6 changed files with 1,127 additions and 3,442 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo check --workspace --all-targets --all-features

check_msrv:
name: Check ash and ash-window MSRV (1.69.0)
name: Check ash and ash-window MSRV (1.76.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.69.0
- uses: dtolnay/rust-toolchain@nightly
- run: cargo check -p ash -p ash-rewrite -p ash-window -p ash-examples --all-features

# TODO: add a similar job for the rewrite once that generates code
Expand All @@ -29,6 +30,10 @@ jobs:
run: git submodule update --recursive --init --force --checkout
- name: Run generator
run: cargo run -p generator
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt
- name: Diff autogen result
run: test -z "$(git status --porcelain)" || (echo "::error::Generated files are different, please regenerate with cargo run -p generator!"; git diff; false)

Expand All @@ -39,6 +44,7 @@ jobs:
- name: Install Vulkan loader
run: sudo apt-get install libvulkan-dev
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Test all targets
run: cargo test --workspace --all-targets
- name: Test docs
Expand All @@ -49,6 +55,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
Expand All @@ -61,10 +70,13 @@ jobs:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-ios
- aarch64-linux-android
steps:
- uses: actions/checkout@v4
- name: Add Rust target ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
- uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
components: clippy
- name: Clippy lint without features
# Only test the core ash, ash-rewrite and ash-window crate, where features reside.
# The examples crate would otherwise enable all default features again,
Expand All @@ -84,6 +96,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Document all crates
env:
RUSTDOCFLAGS: -Dwarnings
Expand Down
2 changes: 1 addition & 1 deletion ash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ categories = [
"rendering::graphics-api"
]
edition = "2021"
rust-version = "1.69.0"
rust-version = "1.76.0"

[dependencies]
libloading = { version = "0.8", optional = true }
Expand Down
2 changes: 0 additions & 2 deletions ash/src/vk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
)]
#[macro_use]
mod macros;
pub use macros::*;
mod aliases;
pub use aliases::*;
mod bitflags;
Expand All @@ -21,7 +20,6 @@ pub use enums::*;
mod extensions;
pub use extensions::*;
mod feature_extensions;
pub use feature_extensions::*;
mod features;
pub use features::*;
mod prelude;
Expand Down
Loading

0 comments on commit f6949e5

Please sign in to comment.