Skip to content

Commit

Permalink
Add regression test for rust-lang#73431
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Jun 17, 2020
1 parent c9dc73d commit 38e921b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/test/ui/consts/const_in_pattern/issue-73431.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run-pass

// Regression test for https://github.com/rust-lang/rust/issues/73431.

pub trait Zero {
const ZERO: Self;
}

impl Zero for usize {
const ZERO: Self = 0;
}

impl<T: Zero> Zero for Wrapper<T> {
const ZERO: Self = Wrapper(T::ZERO);
}

#[derive(Debug, PartialEq, Eq)]
pub struct Wrapper<T>(T);

fn is_zero(x: Wrapper<usize>) -> bool {
match x {
Zero::ZERO => true,
_ => false,
}
}

fn main() {
let _ = is_zero(Wrapper(42));
}

0 comments on commit 38e921b

Please sign in to comment.