Skip to content

macros: avoid trivial cast in #[quickcheck] expansion - #352

Open
rome-xi wants to merge 1 commit into
BurntSushi:masterfrom
rome-xi:contrib/quickcheck-261
Open

macros: avoid trivial cast in #[quickcheck] expansion#352
rome-xi wants to merge 1 commit into
BurntSushi:masterfrom
rome-xi:contrib/quickcheck-261

Conversation

@rome-xi

@rome-xi rome-xi commented Aug 24, 2026

Copy link
Copy Markdown

Closes #261.

#[quickcheck] expanded fn_item as fn(..) which trips trivial_casts when the attribute is applied inside macro_rules that substitutes a type. Coerce through a let binding instead of as, and add a regression test that denies trivial_casts.

Signed-off-by: rome-xi <rome-xi@users.noreply.github.com>
@hlop3z

hlop3z commented Aug 29, 2026

Copy link
Copy Markdown

Verified the regression test gates the bug: with lib.rs reverted to the pre-fix #name as #fn_type expansion (keeping this PR's test and [[test]] entry), cargo test -p quickcheck_macros fails with the same trivial cast error as #261; with the PR applied it passes. (rustc 1.97.0)

One note for reviewers: the Cargo.toml addition isn't incidental — this crate sets autotests = false, so without the explicit [[test]] block, tests/macro_type_subst.rs compiles but silently never runs. Confirmed by removing it.

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.

Trivial cast error when using #[quickcheck] inside macro

2 participants