influxdata / influxdata/pbjson
Generated code triggers clippy::useless_borrows_in_formatting
- Dominant language
- Rust
- Stars
- 116
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
### Description
`pbjson-build` 0.9.0 generates a redundant borrow when formatting the generated `FIELDS` constant.
`FIELDS` is already declared as a slice reference:
```rust
const FIELDS: &[&str] = &[...];
```
but the generated message and enumeration visitors format `&FIELDS`:
```rust
write!(formatter, "expected one of: {:?}", &FIELDS)
```
This creates an unnecessary double reference and triggers the warn-by-default `clippy::useless_borrows_in_formatting` lint.
### Reproduction
Using:
- `pbjson-build 0.9.0`
- `rustc 1.97.1 (8bab26f4f 2026-07-14)`
- `clippy 0.1.97 (8bab26f4f6 2026-07-14)`
run Clippy against code generated from a message or enumeration:
```console
cargo clippy -- -D warnings
```
The generated `write!` call fails with `clippy::useless_borrows_in_formatting`.
The affected templates are:
- `pbjson-build/src/generator/message.rs`
- `pbjson-build/src/generator/enumeration.rs`
The current `main` branch is also affected.
### Expected behavior
Generate:
```rust
write!(formatter, "expected one of: {:?}", FIELDS)
```
This preserves the formatted output without the redundant borrow.
I can submit a small PR with the template changes and regression tests.
Contributor guide
Research direction
Start with the templates in pbjson-build/src/generator/message.rs and pbjson-build/src/generator/enumeration.rs, then run cargo clippy -- -D warnings against generated code. Add regression coverage for message and enumeration visitors, and confirm generated formatting uses FIELDS without the redundant borrow and passes Clippy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100