mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 13:04:42 +00:00 
			
		
		
		
	 87c2f9a5be
			
		
	
	
		87c2f9a5be
		
	
	
	
	
		
			
			This reverts commit 1d35638dc38dbfbf1cc2a9823135dfcf3c650169, reversing changes made to f23a80a4c2fbca593b64e70f5970368824b4c5e9.
		
			
				
	
	
		
			38 lines
		
	
	
		
			778 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			778 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![feature(coverage_attribute)]
 | |
| //@ edition: 2021
 | |
| //@ compile-flags: -Zcoverage-options=branch
 | |
| //@ llvm-cov-flags: --show-branches=count
 | |
| 
 | |
| macro_rules! no_merge {
 | |
|     () => {
 | |
|         for _ in 0..1 {}
 | |
|     };
 | |
| }
 | |
| 
 | |
| fn branch_match_guard(x: Option<u32>) {
 | |
|     no_merge!();
 | |
| 
 | |
|     match x {
 | |
|         Some(0) => {
 | |
|             println!("zero");
 | |
|         }
 | |
|         Some(x) if x % 2 == 0 => {
 | |
|             println!("is nonzero and even");
 | |
|         }
 | |
|         Some(x) if x % 3 == 0 => {
 | |
|             println!("is nonzero and odd, but divisible by 3");
 | |
|         }
 | |
|         _ => {
 | |
|             println!("something else");
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| #[coverage(off)]
 | |
| fn main() {
 | |
|     branch_match_guard(Some(0));
 | |
|     branch_match_guard(Some(2));
 | |
|     branch_match_guard(Some(6));
 | |
|     branch_match_guard(Some(3));
 | |
| }
 |