Skip to content
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

Split generated code into two types #282

Merged
merged 12 commits into from Aug 22, 2022
13 changes: 11 additions & 2 deletions .github/workflows/rust.yml
Expand Up @@ -46,8 +46,17 @@ jobs:
profile: minimal
toolchain: ${{ matrix.channel }}-${{ matrix.rust_target }}

- name: Tests
run: cargo test --features example_generated
- name: Install cargo-hack
run: cargo install cargo-hack

- name: Powerset
run: cargo hack test --feature-powerset --lib --optional-deps "serde" --depth 3 --skip rustc-dep-of-std

- name: Docs
run: cargo doc --features example_generated

- name: Smoke test
run: cargo run --manifest-path tests/smoke-test/Cargo.toml

embedded:
name: Build (embedded)
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Expand Up @@ -16,16 +16,16 @@ categories = ["no-std"]
description = """
A macro to generate structures which behave like bitflags.
"""
exclude = ["bors.toml"]
exclude = ["tests", ".github"]

[dependencies]
core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
compiler_builtins = { version = '0.1.2', optional = true }
serde = { version = "1.0", optional = true }
core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }
compiler_builtins = { version = "0.1.2", optional = true }

[dev-dependencies]
trybuild = "1.0"
rustversion = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

Expand Down
19 changes: 9 additions & 10 deletions src/bitflags_trait.rs
Expand Up @@ -25,16 +25,7 @@ pub trait BitFlags: ImplementedByBitFlagsMacro {
fn from_bits_truncate(bits: Self::Bits) -> Self;
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
unsafe fn from_bits_unchecked(bits: Self::Bits) -> Self;
fn from_bits_retain(bits: Self::Bits) -> Self;
/// Returns `true` if no flags are currently stored.
fn is_empty(&self) -> bool;
/// Returns `true` if all flags are currently set.
Expand Down Expand Up @@ -107,3 +98,11 @@ impl_bits! {
u64, i64,
u128, i128,
}

pub trait PublicFlags {
type InternalFlags;
}

pub trait InternalFlags {
type PublicFlags;
}