Skip to content

Fix unused lifetime in ArchDetail (#199) and add CI feature combination tests (#200)#201

Merged
jiegec merged 3 commits into
masterfrom
fix-issue-199
Jun 27, 2026
Merged

Fix unused lifetime in ArchDetail (#199) and add CI feature combination tests (#200)#201
jiegec merged 3 commits into
masterfrom
fix-issue-199

Conversation

@jiegec

@jiegec jiegec commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Fix #199: Add _Lifetime(PhantomData<&'a ()>) variant to ArchDetail enum to ensure the 'a lifetime parameter is always used, even when no arch features are enabled. Also add #[non_exhaustive] to ArchDetail and ArchOperand since their variants depend on feature flags.

Fix #200: Add feature-checks CI job using a Python script that dynamically discovers arch_* features from Cargo.toml and tests:

  • all features disabled
  • all features enabled
  • each arch feature individually
  • random subsets (2-5 arch features, shuffled per trial)

tmfink and others added 2 commits June 26, 2026 23:06
#199)

Add _Lifetime(PhantomData<&'a ()>) variant to ArchDetail enum and
corresponding unreachable arm in operands() match to ensure the 'a
lifetime parameter is always used.
Add feature-checks job to test:
- all features disabled
- all features enabled
- each arch feature individually
- random subsets of varying sizes

Uses a Python script that dynamically discovers arch_* features from
Cargo.toml instead of hardcoding feature names.

@tmfink tmfink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks really good--just some comments on the python script

Comment thread scripts/feature-checks.py Outdated
MANIFEST = REPO_ROOT / "capstone-rs" / "Cargo.toml"
CARGO = os.environ.get("CARGO", "cargo")

failed = []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a global (especially one you modify), then make it ALL CAPS so that it's clearly a global.

However, I suggest you avoid the mutable global and instead have cargo_check() return an error (or append to a failed argument) so it's more clear how everything is tracked. Sometimes we need a global, but I don't think we do here.

Comment thread scripts/feature-checks.py Outdated
failed = []


def cargo_check(label, *args):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of requiring cargo args, I think we should instead exposing "pythonic" args:

  • default_features=False
  • all_features=False
  • features=None: list of features

Comment thread scripts/feature-checks.py
@@ -0,0 +1,95 @@
#!/usr/bin/env python3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For convenience, you can make this file executable (chmod +x)--git tracks these file permissions.

Comment thread scripts/feature-checks.py Outdated
failed = []


def cargo_check(label, *args):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding python type hints to make the script easier to understand. If you use an LSP like basedpyright, it helps catch warnings/errors. Linters like ruff can also help.

https://docs.python.org/3/library/typing.html

Comment thread scripts/feature-checks.py Outdated
cargo_check("all-features", "--all-features")

# 3. Each arch feature individually
base = "std,full"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also have tests for different combinations of std/full being enabled/disabled.

- Remove mutable global by having cargo_check return an error string or None
- Switch from raw cargo args to Pythonic keyword arguments:
  default_features, all_features, features
- Add Python type hints throughout
- Make file executable (chmod +x)
- Test all four std/full on/off combinations
@jiegec
jiegec requested a review from tmfink June 27, 2026 01:30

@tmfink tmfink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@jiegec
jiegec merged commit f2fc543 into master Jun 27, 2026
28 checks passed
@jiegec
jiegec deleted the fix-issue-199 branch June 27, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI should test more feature combinations Build fails with all features diabled

2 participants