Commit d03800c
Add
Summary:
The `define_stats!` macro generates a `pub(crate) mod STATS { ... }`
block. Type parameters in dynamic stat definitions (e.g. `region: String`)
are forwarded as `tt` token trees and only parsed as types inside this
generated module. This means custom types from the caller's scope were not
resolvable — only primitive types and `&'static str` worked.
Adding `use super::*;` to the generated module makes all of the caller's
imports visible, so types like `dba_common_types::Region` can be used
directly in stat definitions:
```rust
use dba_common_types::Region;
define_stats! {
prefix = "my.prefix";
my_stat: dynamic_timeseries("{}", (region: Region); Count),
}
```
All three resolution paths now work:
- Direct name: `region: Region` (via `use super::*`)
- Explicit super: `region: super::Region`
- Fully qualified: `region: ::dba_common_types::Region`
This is backward-compatible — existing code using `String`, `u64`,
`&'static str` etc. continues to work unchanged.
Reviewed By: dtolnay
Differential Revision: D99868296
fbshipit-source-id: 30a75bb943d86751c6a28a79a85d50885921abaause super::* to define_stats! generated module for type hygiene1 parent 33062b7 commit d03800c
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
| |||
0 commit comments