Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pattern binding is named the same as one of the variants of the type <type>" warning is not generated when matching against a borrow #67776

Closed
yshui opened this issue Jan 1, 2020 · 2 comments · Fixed by #67783
Assignees
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@yshui
Copy link
Contributor

yshui commented Jan 1, 2020

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=6b951a2fc1cc70455730b35d42fcf483

This issue has been assigned to @LeSeulArtichaut via this comment.

@yshui yshui changed the title pattern binding is named the same as one of the variants of the type <type> warning is not generated when matching against self "pattern binding is named the same as one of the variants of the type <type>" warning is not generated when matching against self Jan 1, 2020
@jonas-schievink jonas-schievink added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 1, 2020
@yshui yshui changed the title "pattern binding is named the same as one of the variants of the type <type>" warning is not generated when matching against self "pattern binding is named the same as one of the variants of the type <type>" warning is not generated when matching against a borrow Jan 1, 2020
@csmoe
Copy link
Member

csmoe commented Jan 1, 2020

This lint was generated by check_for_bindings_named_same_as_variants:

let pat_ty = cx.tables.pat_ty(p);
if let ty::Adt(edef, _) = pat_ty.kind {
if edef.is_enum()

as we can see ty::Ref is just ignored, so the fix is pretty easy, just peel off all the refs in the type of pat_ty.

@csmoe csmoe added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jan 1, 2020
@LeSeulArtichaut
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants