Skip to content

Accept parenthesised trait objects in dynptr! - #152

Open
mike-oi wants to merge 1 commit into
ZettaScaleLabs:mainfrom
mike-oi:dynptr-paren-trait-objects
Open

mike-oi wants to merge 1 commit into
ZettaScaleLabs:mainfrom
mike-oi:dynptr-paren-trait-objects

Conversation

@mike-oi

@mike-oi mike-oi commented Oct 12, 2026

Copy link
Copy Markdown

dynptr!(&'a (dyn Trait + Send + Sync)) panicked with "expected dyn not found" because syn parses the referent as Type::Paren rather than Type::TraitObject. Since &'a dyn Trait + Send isn't valid type syntax, there was no way to name a Send/Sync DynRef with the macro.

Strip Type::Paren and Type::Group (produced by $t:ty in macro_rules!) from both the outer type and the pointee before matching.

Written by Claude (sorry), but it makes a lot of sense to me.

I state that I was not able to sign ECA with my GitHub private email,
since I wouldn't want to disclose my public email for this particular commit,
and that therefore I grant the permission to copy/merge my PR if accepted

`dynptr!(&'a (dyn Trait + Send + Sync))` panicked with "expected `dyn`
not found" because syn parses the referent as Type::Paren rather than
Type::TraitObject. Since `&'a dyn Trait + Send` isn't valid type syntax,
there was no way to name a Send/Sync DynRef with the macro.

Strip Type::Paren and Type::Group (produced by `$t:ty` in macro_rules!)
from both the outer type and the pointee before matching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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