// Inference and the exhaustiveness checker each match a refined // constructor's index against the scrutinee's type, in a walk of their // own (issue #240). On a match's first arm they must agree: a constructor // inference refuses (E0202) is one the checker finds impossible (W0301), // and one inference accepts is one the checker keeps. If the checker // dropped a constructor inference accepts, a missing arm for it would go // unreported. Each case is one shape where the two walks differ. pub type Ix { OfInt(Int) -> Ix , OfBool(Bool) -> Ix , OfList(Int) -> Ix> , OfPair(Int) -> Ix<(Int, Bool)> , Any(Int) -> Ix } pub type Two { Same(Int) -> Two, Apart(Int) -> Two } pub fn concrete_refused :: x: Ix -> Int { match x { OfBool(_) -> 1, _ -> 0 } //~ ERROR E0202 cannot match //~^ WARN W0301 } pub fn concrete_kept :: x: Ix -> Int { match x { OfInt(_) -> 1, _ -> 0 } } pub fn rigid_kept :: x: Ix -> Int { match x { OfBool(_) -> 1, _ -> 0 } } pub fn nested_refused :: x: Ix> -> Int { match x { OfList(_) -> 1, _ -> 0 } //~ ERROR E0202 cannot match //~^ WARN W0301 } pub fn nested_rigid_kept :: x: Ix> -> Int { match x { OfList(_) -> 1, _ -> 0 } } pub fn tuple_refused :: x: Ix<(Int, Int)> -> Int { match x { OfPair(_) -> 1, _ -> 0 } //~ ERROR E0202 cannot match //~^ WARN W0301 } pub fn tuple_rigid_kept :: x: Ix<(a, b)> -> Int { match x { OfPair(_) -> 1, _ -> 0 } } pub fn unrefined_kept :: x: Ix -> Int { match x { Any(_) -> 1, _ -> 0 } } pub fn repeated_refused :: x: Two -> Int { match x { Same(_) -> 1, _ -> 0 } //~ ERROR E0202 cannot match //~^ WARN W0301 } // `Apart` is impossible here, so `Same` alone covers every value. pub fn repeated_concrete_kept :: x: Two -> Int { match x { Same(_) -> 1 } } pub fn repeated_rigid_kept :: x: Two -> Int { match x { Same(_) -> 1, _ -> 0 } }