Skip to content

Add note explaining that the same variant of the same enum with different type params are different types #95284

Open
@estebank

Description

@estebank

As brought up in #51479, Result<A, i32>::Err(0) and Result<B, i32>::Err(0) are not of the same type. We should add a note (or ideally a structured suggestion on what to write) explaining this.

error[E0308]: `match` arms have incompatible types
 --> src/lib.rs:8:16
  |
6 | /     match f2() {
7 | |         Ok(value) => Ok(value as i64),
  | |                      ---------------- this is found to be of type `Result<i64, String>`
8 | |         err => err,
  | |                ^^^ expected `i64`, found `i32`
9 | |     }
  | |_____- `match` arms have incompatible types
  |
  = note: expected enum `Result<i64, _>`
             found enum `Result<i32, _>`

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.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