Skip to content

fix: prevent qualifying parameter names in add_missing_impl_members#21665

Merged
A4-Tacks merged 3 commits intorust-lang:masterfrom
raushan728:fix-param-name-bug
Feb 19, 2026
Merged

fix: prevent qualifying parameter names in add_missing_impl_members#21665
A4-Tacks merged 3 commits intorust-lang:masterfrom
raushan728:fix-param-name-bug

Conversation

@raushan728
Copy link
Contributor

@raushan728 raushan728 commented Feb 18, 2026

Fixes #21663

What changed:
The path transformation logic was incorrectly qualifying parameter names that matched definitions in scope (e.g., ptr becoming std::ptr).

I updated transform_ident_pat in path_transform.rs to skip the transformation for non-value definitions (like modules, functions, traits, non-unit structs, and non-unit variants) since they act as bindings in patterns. Valid pattern values (unit structs/variants, constants, and statics) are still transformed correctly.

Added a comprehensive test to verify all these edge cases.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 18, 2026
@raushan728
Copy link
Contributor Author

hi @ChayimFriedman2 it's done. plz take a look when u free

}

// Similarly, modules cannot be used in pattern position.
if matches!(def, hir::ModuleDef::Module(_)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this filter other definitions? For example, structures or functions?

Copy link
Member

Choose a reason for hiding this comment

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

BTW, I am filtering identifier patterns in #21411

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@A4-Tacks got it adding filters for structs, fns, etc. updating the PR shortly.

Copy link
Member

Choose a reason for hiding this comment

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

Note that in fn foo(Foo: i32) {},

  • struct Foo {}: Foo is the identify pattern
  • struct Foo;: Foo required the transform (like const Foo = ...)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

that makes perfect sense! unit structs/constants can act as values in patterns, while braced structs act as bindings. I'll make sure the filter handles this distinction. thanks for catching that edge case

@raushan728
Copy link
Contributor Author

raushan728 commented Feb 19, 2026

@A4-Tacks updated with new filters and tests

@raushan728 raushan728 requested a review from A4-Tacks February 19, 2026 05:13
@A4-Tacks A4-Tacks added this pull request to the merge queue Feb 19, 2026
Merged via the queue into rust-lang:master with commit 52de6fa Feb 19, 2026
16 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 19, 2026
@raushan728 raushan728 deleted the fix-param-name-bug branch February 21, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants