Skip to content

Detect different borrowing in different sub-expressions the same expression and suggest borrowing when applicable #134219

Open
@estebank

Description

error[E0308]: mismatched types
    --> compiler/rustc_middle/src/ty/context.rs:3212:73
     |
3210 |         match expr.kind {
     |               --------- this expression has type `rustc_hir::ExprKind<'_>`
3211 |             hir::ExprKind::Path(qpath)
     |                                 ----- first introduced with type `rustc_hir::QPath<'_>` here
3212 |             | hir::ExprKind::Call(hir::Expr { kind: hir::ExprKind::Path(qpath), .. }, []) => {
     |                                                                         ^^^^^ expected `QPath<'_>`, found `&QPath<'_>`
     |
     = note: in the same arm, a binding must have the same type in all alternatives

The above should suggest match &expr.kind.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.P-lowLow priorityT-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