Skip to content

diagnostics: mismatched pattern field: suggest ".." instead of "_" #80010

Closed
@matthiaskrgr

Description

@matthiaskrgr
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 3 fields
   --> clippy_lints/src/needless_borrow.rs:50:20
    |
50  |             if let ty::Ref(_) = cx.typeck_results().expr_ty(inner).kind() {
    |                    ^^^^^^^^^^ expected 3 fields, found 1

trying to ignore the inner fields with ty::Ref(_) does not work because it has 3 fields.
The message could suggest Ref(..) if there are multiple fields and it thinks we don't want to bind any:

error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 3 fields
   --> clippy_lints/src/needless_borrow.rs:50:20
    |
50  |             if let ty::Ref(_) = cx.typeck_results().expr_ty(inner).kind() {
    |                    ^^^^^^^^^^ expected 3 fields, found 1
    = help: Use `ty::Ref(..)` to ignore any inner fields

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions