clockworklabs / clockworklabs/SpacetimeDB
Conditional compilation for field attributes does not work
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
When I do:
#[table(name=test)]
struct Test {
#[cfg_attr(feature(x), unique)]
x: i32,
}
I get the same result both without and with the x feature enabled.
cargo expand seems to show only #[unique] come and go, while manually setting this attribute results in a bunch of expected code (UniqueColumn, IndexDesc and friends) generated.
I assume the issue is within the derive macro for SpacetimeType, but don't know where to look specifically.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SpacetimeType derive macro, as suggested in the issue, and compare cargo expand output with the x feature disabled and enabled. Verify that the cfg_attr-controlled unique attribute produces the expected UniqueColumn, IndexDesc, and related generated code when the feature is enabled, while remaining absent otherwise.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100