about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorLuuk Wester <luuk.wester@gmail.com>2025-01-21 10:33:28 +0100
committerLuuk Wester <luuk.wester@gmail.com>2025-01-21 10:33:28 +0100
commit398cd2dbf63d67a0f58e1fa730883a7420f8ef70 (patch)
treee6c9ad2fb9d4f4d33e30c2d55fb349e1eb7d34c4 /src/tools
parent4a7ec72961662ebfef0d315d66b0e9006219cea2 (diff)
downloadrust-398cd2dbf63d67a0f58e1fa730883a7420f8ef70.tar.gz
rust-398cd2dbf63d67a0f58e1fa730883a7420f8ef70.zip
make large niche description more terse, switch to using u128::is_power_of_two
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/rust-analyzer/crates/ide/src/hover/render.rs8
-rw-r--r--src/tools/rust-analyzer/crates/ide/src/hover/tests.rs2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/tools/rust-analyzer/crates/ide/src/hover/render.rs b/src/tools/rust-analyzer/crates/ide/src/hover/render.rs
index 7fe344cfa42..95be7c5618e 100644
--- a/src/tools/rust-analyzer/crates/ide/src/hover/render.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/hover/render.rs
@@ -1090,7 +1090,7 @@ fn render_memory_layout(
                 } else if is_pwr2minus1(niches) {
                     format_to!(label, "niches = 2{} - 1, ", pwr2_to_exponent(niches + 1));
                 } else {
-                    format_to!(label, "niches = really rather quite large, ");
+                    format_to!(label, "niches = a lot, ");
                 }
             } else {
                 format_to!(label, "niches = {niches}, ");
@@ -1224,15 +1224,15 @@ fn render_dyn_compatibility(
 }
 
 fn is_pwr2(val: u128) -> bool {
-    val.count_ones() == 1
+    val.is_power_of_two()
 }
 
 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 {
-    val != 0 && (val - 1).count_ones() == 1
+    val != 0 && is_pwr2(val - 1)
 }
 
 fn pwr2_to_exponent(num: u128) -> String {
diff --git a/src/tools/rust-analyzer/crates/ide/src/hover/tests.rs b/src/tools/rust-analyzer/crates/ide/src/hover/tests.rs
index 63eb772fde2..064a845dc57 100644
--- a/src/tools/rust-analyzer/crates/ide/src/hover/tests.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/hover/tests.rs
@@ -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
         "#]],
     );
 }