jfecher / jfecher/inc-complete

Derive macro doesn't support type aliases for the database

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Rust
Stars
17
Forks
3
PR merge metrics
No merged PRs in 30d

Description

We should support the code below:
```rs
struct MyStorage { ... foo: SingletonStorage ... }
struct Foo;
type MyDb = inc_complete::DbHandle;

#[intermediate(id = 1)]
fn foo(ctx: &incremental::Parse, db: &MyDb) -> i32 {
0
}
```
But we get an error when doing so:
```
error: DbHandle must have a generic type parameter for the storage type
--> src/foo/mod.rs:84:45
|
84 | fn foo(ctx: &incremental::Parse, db: &incremental::DbHandle) -> Arc {
| ^^^^^^^^^^^^^^^^^^^^^
```
If we name the alias something else we get an error making it look like the macro is looking for an exact name:
```
error: second parameter must be &DbHandle
--> src/foo/mod.rs:86:45
|
86 | fn foo(ctx: &incremental::Parse, db: &Foo) -> Arc {
| ^^^
```
This is overly restrictive and prevents users from using the derive macros in more situations

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the derive macro's handling of the second parameter and how it validates DbHandle's storage type. Reproduce the issue with the MyDb alias and with the differently named alias, then add coverage showing both forms are accepted while preserving the intended storage type check.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.