Skip to content

Commit 398cd2d

Browse files
committed
make large niche description more terse, switch to using u128::is_power_of_two
1 parent 4a7ec72 commit 398cd2d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/tools/rust-analyzer/crates/ide/src/hover/render.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ fn render_memory_layout(
10901090
} else if is_pwr2minus1(niches) {
10911091
format_to!(label, "niches = 2{} - 1, ", pwr2_to_exponent(niches + 1));
10921092
} else {
1093-
format_to!(label, "niches = really rather quite large, ");
1093+
format_to!(label, "niches = a lot, ");
10941094
}
10951095
} else {
10961096
format_to!(label, "niches = {niches}, ");
@@ -1224,15 +1224,15 @@ fn render_dyn_compatibility(
12241224
}
12251225

12261226
fn is_pwr2(val: u128) -> bool {
1227-
val.count_ones() == 1
1227+
val.is_power_of_two()
12281228
}
12291229

12301230
fn is_pwr2minus1(val: u128) -> bool {
1231-
val == u128::MAX || (val + 1).count_ones() == 1
1231+
val == u128::MAX || is_pwr2(val + 1)
12321232
}
12331233

12341234
fn is_pwr2plus1(val: u128) -> bool {
1235-
val != 0 && (val - 1).count_ones() == 1
1235+
val != 0 && is_pwr2(val - 1)
12361236
}
12371237

12381238
fn pwr2_to_exponent(num: u128) -> String {

src/tools/rust-analyzer/crates/ide/src/hover/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ fn hover_enum_limit() {
13571357
13581358
---
13591359
1360-
size = 12 (0xC), align = 4, niches = really rather quite large
1360+
size = 12 (0xC), align = 4, niches = a lot
13611361
"#]],
13621362
);
13631363
}

0 commit comments

Comments
 (0)