File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ compile-flags: -O -Zmerge-functions=disabled
2
+ //! Test for <https://github.com/rust-lang/rust/issues/108395>. Check that
3
+ //! matching on two bools with wildcards does not produce branches.
4
+ #![ crate_type = "lib" ]
5
+
6
+ // CHECK-LABEL: @wildcard(
7
+ #[ no_mangle]
8
+ pub fn wildcard ( a : u16 , b : u16 , v : u16 ) -> u16 {
9
+ // CHECK-NOT: br
10
+ match ( a == v, b == v) {
11
+ ( true , false ) => 0 ,
12
+ ( false , true ) => u16:: MAX ,
13
+ _ => 1 << 15 , // half
14
+ }
15
+ }
16
+
17
+ // CHECK-LABEL: @exhaustive(
18
+ #[ no_mangle]
19
+ pub fn exhaustive ( a : u16 , b : u16 , v : u16 ) -> u16 {
20
+ // CHECK-NOT: br
21
+ match ( a == v, b == v) {
22
+ ( true , false ) => 0 ,
23
+ ( false , true ) => u16:: MAX ,
24
+ ( true , true ) => 1 << 15 ,
25
+ ( false , false ) => 1 << 15 ,
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments