]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const_in_pattern/issue-73431.rs
Merge commit '7b73b60faca71d01d900e49831fcb84553e93019' into sync-rustfmt
[rust.git] / src / test / ui / consts / const_in_pattern / issue-73431.rs
1 // run-pass
2
3 // Regression test for https://github.com/rust-lang/rust/issues/73431.
4
5 pub trait Zero {
6     const ZERO: Self;
7 }
8
9 impl Zero for usize {
10     const ZERO: Self = 0;
11 }
12
13 impl<T: Zero> Zero for Wrapper<T> {
14     const ZERO: Self = Wrapper(T::ZERO);
15 }
16
17 #[derive(Debug, PartialEq, Eq)]
18 pub struct Wrapper<T>(T);
19
20 fn is_zero(x: Wrapper<usize>) -> bool {
21     match x {
22         Zero::ZERO => true,
23         _ => false,
24     }
25 }
26
27 fn main() {
28     let _ = is_zero(Wrapper(42));
29 }