mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 03:54:42 +00:00 
			
		
		
		
	make large niche description more terse, switch to using u128::is_power_of_two
This commit is contained in:
		
							parent
							
								
									57bd824b5a
								
							
						
					
					
						commit
						6b6e019593
					
				
					 2 changed files with 5 additions and 5 deletions
				
			
		|  | @ -1090,7 +1090,7 @@ fn render_memory_layout( | ||||||
|                 } else if is_pwr2minus1(niches) { |                 } else if is_pwr2minus1(niches) { | ||||||
|                     format_to!(label, "niches = 2{} - 1, ", pwr2_to_exponent(niches + 1)); |                     format_to!(label, "niches = 2{} - 1, ", pwr2_to_exponent(niches + 1)); | ||||||
|                 } else { |                 } else { | ||||||
|                     format_to!(label, "niches = really rather quite large, "); |                     format_to!(label, "niches = a lot, "); | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 format_to!(label, "niches = {niches}, "); |                 format_to!(label, "niches = {niches}, "); | ||||||
|  | @ -1224,15 +1224,15 @@ fn render_dyn_compatibility( | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn is_pwr2(val: u128) -> bool { | fn is_pwr2(val: u128) -> bool { | ||||||
|     val.count_ones() == 1 |     val.is_power_of_two() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn is_pwr2minus1(val: u128) -> bool { | fn is_pwr2minus1(val: u128) -> bool { | ||||||
|     val == u128::MAX || (val + 1).count_ones() == 1 |     val == u128::MAX || is_pwr2(val + 1) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn is_pwr2plus1(val: u128) -> bool { | fn is_pwr2plus1(val: u128) -> bool { | ||||||
|     val != 0 && (val - 1).count_ones() == 1 |     val != 0 && is_pwr2(val - 1) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn pwr2_to_exponent(num: u128) -> String { | fn pwr2_to_exponent(num: u128) -> String { | ||||||
|  |  | ||||||
|  | @ -1357,7 +1357,7 @@ fn hover_enum_limit() { | ||||||
| 
 | 
 | ||||||
|             --- |             --- | ||||||
| 
 | 
 | ||||||
|             size = 12 (0xC), align = 4, niches = really rather quite large |             size = 12 (0xC), align = 4, niches = a lot | ||||||
|         "#]],
 |         "#]],
 | ||||||
|     ); |     ); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Luuk Wester
						Luuk Wester