Skip to content

test: cover serde attributes forwarded through another attribute#546

Merged
Boshen merged 1 commit into
mainfrom
test-serde-forwarded-attribute
Jul 16, 2026
Merged

test: cover serde attributes forwarded through another attribute#546
Boshen merged 1 commit into
mainfrom
test-serde-forwarded-attribute

Conversation

@Boshen

@Boshen Boshen commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Adds a regression test for a serde attribute forwarded through another attribute, as confik does:

struct Foo {
    #[confik(forward(serde(with = "humantime_serde")))]
    timeout: Duration,
}

This is the shape reported in #542. It is not a macro body — confik is a derive macro, so the attribute is a plain Attr node. It failed because collect_meta_imports only calls collect_serde_attribute when the attribute's own path is literally serde, and here it is confik.

#543 already fixes it: the token scan added in collect_token_tree runs on every attribute's token tree and matches on a serde ident anywhere in the stream, so the nested serde(...) is picked up regardless of the outer path. The existing serde_attributes_inside_macro test does not cover this path — it would keep passing if the scan were ever narrowed to the attribute path or scoped to macro bodies, silently regressing confik. This test pins that behaviour: it fails with the #543 hunk reverted (left: {}, right: {"foo"}).

@Boshen
Boshen merged commit 24abe5e into main Jul 16, 2026
3 checks passed
@Boshen
Boshen deleted the test-serde-forwarded-attribute branch July 16, 2026 12:37
@Boshen Boshen mentioned this pull request Jul 16, 2026
Boshen added a commit that referenced this pull request Jul 16, 2026
## 🤖 New release

* `cargo-shear`: 1.13.1 -> 1.13.2 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[1.13.2](v1.13.1...v1.13.2)
- 2026-07-16

### <!-- 1 -->🐛 Bug Fixes
- detect serde attributes inside macros
([#543](#543)) (by @Boshen)

### <!-- 3 -->📚 Documentation
- add security policy
([#537](#537)) (by @Boshen)

### <!-- 6 -->🧪 Testing
- cover serde attributes forwarded through another attribute
([#546](#546)) (by @Boshen)

### Contributors

* @renovate[bot]
* @Boshen
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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.

1 participant