Skip to content

Restrict newtype constant wrapping to actual type aliases#3390

Merged
emilio merged 2 commits into
rust-lang:mainfrom
armoha:strict-newtype-alias
Jul 7, 2026
Merged

Restrict newtype constant wrapping to actual type aliases#3390
emilio merged 2 commits into
rust-lang:mainfrom
armoha:strict-newtype-alias

Conversation

@armoha

@armoha armoha commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #3303

alias_style helper method fall backs to ctx.options().default_alias_style without checking if the item is actually a typedef/alias, resulting in matching built-in primitives to new type variant. The fix uses ItemResolver and .through_type_refs() to unwrap C type qualifiers (e.g. const, volatile) and verifies that the type kind is alias.

@armoha armoha force-pushed the strict-newtype-alias branch from a47de8e to 594fe6f Compare July 7, 2026 02:06
@armoha armoha force-pushed the strict-newtype-alias branch from 594fe6f to 8edd7a3 Compare July 7, 2026 02:07

@emilio emilio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emilio emilio added this pull request to the merge queue Jul 7, 2026
Merged via the queue into rust-lang:main with commit 100717c Jul 7, 2026
51 checks passed
@armoha armoha deleted the strict-newtype-alias branch July 7, 2026 15:13
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.

Constant generation for my project broken by PR #3288

2 participants