-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.E-needs-mcveCall for participation: This issue needs a Minimal Complete and Verifiable ExampleCall for participation: This issue needs a Minimal Complete and Verifiable ExampleI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveL-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint groupT-middleType: Probably requires verifiying typesType: Probably requires verifiying types
Description
If the two arms do not have the same actual type, pulling them together with |
will fail. The lint should not trigger if the actual types of the match arms differ.
E.g.
enum Foo<'a> {
Bar(&'a FooBar),
Baz(&'a Buzz),
}
let x: &Any = match foo {
Bar(ref bar) => bar,
Baz(ref bar) => bar,
}
Changing it to
let x: &Any = match foo {
Bar(ref bar) |
Baz(ref bar) => bar,
}
will fail with a type error.
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.E-needs-mcveCall for participation: This issue needs a Minimal Complete and Verifiable ExampleCall for participation: This issue needs a Minimal Complete and Verifiable ExampleI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveL-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint groupT-middleType: Probably requires verifiying typesType: Probably requires verifiying types