Skip to content

Implement core::fmt::Display for ParseError - #477

Merged
Peternator7 merged 2 commits into
masterfrom
peternator7/parse-error-core
Feb 22, 2026
Merged

Implement core::fmt::Display for ParseError#477
Peternator7 merged 2 commits into
masterfrom
peternator7/parse-error-core

Conversation

@Peternator7

Copy link
Copy Markdown
Owner

strum::ParseError can implement core::fmt::Display.

core::error::Error wasn't added to core until 1.81

Fixes #453

@Peternator7 Peternator7 changed the title Display exists in core Implement core::fmt::Display for ParseError Feb 22, 2026
@Peternator7
Peternator7 merged commit 26e63cd into master Feb 22, 2026
6 checks passed
philippemnoel added a commit to paradedb/paradedb that referenced this pull request Aug 4, 2026
# Ticket(s) Closed

- Closes #

## What

Bumps `strum` and `strum_macros` from `0.27.2` to `0.28.0` in
`pg_search`, `tests` and `tokenizers`. No source changes were needed.

Fifth of the major-version dependency upgrades, done one at a time
(after #5843 sysinfo, #5844 syn, #5849 rstest, #5853 proptest-derive).

## Why

Broadest remaining upgrade — it's the only one touching three crates.

## How

### The documented breaking changes don't apply

`0.28.0`'s one behavioral break is that **`EnumString` now implements
`From<&str>` instead of `TryFrom<&str>`** for enums with a
`#[strum(default)]` variant
([#476](Peternator7/strum#476)).

Nothing here derives `EnumString`, and there are zero uses of
`#[strum(default)]` or `EnumDiscriminants`. The `strum::ParseError` →
`core::fmt::Display` change
([#477](Peternator7/strum#477)) is also unused —
the `ParseError` matches in this workspace are
`std::net::AddrParseError` and tantivy's `QueryParserError`, not
strum's. MSRV moves to 1.71, well under our pinned 1.97.1.

The derive surface actually in use is narrow: `VariantNames` (3),
`AsRefStr` (3), `EnumIter` (2), `Display` (2), `IntoEnumIterator` (1),
with only `serialize_all = "snake_case"` and two `serialize = "..."`
overrides.

### What actually needed checking: the derived strings are public API

`SearchTokenizer` derives `VariantNames` + `AsRefStr` under
`serialize_all = "snake_case"`, and `SearchTokenizer::VARIANTS` is
returned **directly by the `paradedb.tokenizers()` SQL function**:

```rust
pub fn tokenizers() -> TableIterator<'static, (name!(tokenizer, String),)> {
    TableIterator::new(SearchTokenizer::VARIANTS.iter().map(|t| (t.to_string(),)).collect::<Vec<_>>())
}
```

So a change in how strum renders variants like `ICUTokenizer`,
`EdgeNgram`, `WhiteSpace` or `ChineseLinderaDeprecated` would be a
**user-visible break**, silently changing accepted tokenizer names.

A replica of both derived enums — same attributes, same 23 variants, in
their real tuple/struct/unit shapes — was compiled under 0.27.2 and
0.28.0. Identical output:

```
VARIANTS = ["default", "keyword", "keyword_deprecated", "raw", "literal_normalized",
            "white_space", "regex_tokenizer", "chinese_compatible", "source_code",
            "ngram", "edge_ngram", "chinese_lindera_deprecated", "chinese_lindera",
            "japanese_lindera_deprecated", "japanese_lindera", "korean_lindera_deprecated",
            "korean_lindera", "icu", "jieba", "lindera_deprecated", "lindera",
            "unicode_words_deprecated", "unicode_words"]
```

`as_ref()` for every variant shape (including both `serialize = "..."`
overrides), `LinderaLanguage::VARIANTS`, and `EnumIter` ordering all
matched too.

## ⚠️ This temporarily duplicates strum in the graph

`lindera 1.5.1` pins `strum = "^0.27.2"`, so its subtree keeps 0.27.2
while our crates move to 0.28.0:

```
strum v0.28.0          strum v0.27.2
├── pg_search          ├── lindera v1.5.1
└── tokenizers         └── lindera-dictionary v1.5.1
```

Cost is one extra `strum` + `strum_macros` compile. No `phf` pull-in,
since that feature stays off.

**This resolves itself with the lindera upgrade** — `lindera 4.0.1`
requires `strum 0.28.0`, so landing that collapses the duplicate. The
two upgrades are complementary; if you'd rather not carry the
duplication at all, this one could wait until after lindera.

## Tests

All three crates reach lindera, whose build script downloads
dictionaries from `lindera.dev` — a host blocked by egress policy in my
environment — so none can be compiled locally. The matrix jobs on this
PR are what compile them.

- equivalence harness above — identical derived names under 0.27.2 and
0.28.0
- `cargo fmt --all -- --check` — clean

## Remaining

| crate | current → latest | note |
|---|---|---|
| `lindera` | 1.5.1 → 4.0.1 | also collapses the strum duplication
above; but 4.0 dropped the `compress` feature, so embedded dictionaries
become raw `include_bytes!` — a `.so` size vs. startup trade-off worth
measuring, plus segmentation output needs checking |
| `bincode` | 2.0.1 → 3.0.0 | touches an on-disk encoding |
| `cmd_lib` | 1.9.6 → 2.0.0 | |
| `emojis` | 0.8.2 → 0.9.0 | |

---
_Generated by [Claude
Code](https://claude.ai/code/session_01XEm6G1qKw694BQQqb9HBiU)_
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.

Remove std dependency for Error and Display trait implementations

1 participant