Skip to content

Commit 9985bd6

Browse files
authored
cmov: add doc(cfg(true)) to backend trait impls (#1371)
This ensures that they show up as always available in the rustdoc rendered on docs.rs, as opposed to appearing with target/feature gates that don't actually exist
1 parent eabe934 commit 9985bd6

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

cmov/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ instructions on x86/x86_64 and CSEL on AArch64, along with a portable "best-effo
1818

1919
[dev-dependencies]
2020
proptest = "1.9"
21+
22+
[package.metadata.docs.rs]
23+
all-features = true

cmov/src/backends/aarch64.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ macro_rules! cseleq64 {
8686
};
8787
}
8888

89+
#[cfg_attr(docsrs, doc(cfg(true)))]
8990
impl Cmov for u16 {
9091
#[inline]
9192
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -98,6 +99,7 @@ impl Cmov for u16 {
9899
}
99100
}
100101

102+
#[cfg_attr(docsrs, doc(cfg(true)))]
101103
impl Cmov for u32 {
102104
#[inline]
103105
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -110,6 +112,7 @@ impl Cmov for u32 {
110112
}
111113
}
112114

115+
#[cfg_attr(docsrs, doc(cfg(true)))]
113116
impl Cmov for u64 {
114117
#[inline]
115118
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -122,6 +125,7 @@ impl Cmov for u64 {
122125
}
123126
}
124127

128+
#[cfg_attr(docsrs, doc(cfg(true)))]
125129
impl CmovEq for u16 {
126130
#[inline]
127131
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -134,6 +138,7 @@ impl CmovEq for u16 {
134138
}
135139
}
136140

141+
#[cfg_attr(docsrs, doc(cfg(true)))]
137142
impl CmovEq for u32 {
138143
#[inline]
139144
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -146,6 +151,7 @@ impl CmovEq for u32 {
146151
}
147152
}
148153

154+
#[cfg_attr(docsrs, doc(cfg(true)))]
149155
impl CmovEq for u64 {
150156
#[inline]
151157
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {

cmov/src/backends/soft.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use crate::{Cmov, CmovEq, Condition};
1212
use core::ops::{BitAnd, BitOr, Not};
1313

14+
#[cfg_attr(docsrs, doc(cfg(true)))]
1415
impl Cmov for u16 {
1516
#[inline]
1617
fn cmovnz(&mut self, value: &u16, condition: Condition) {
@@ -23,6 +24,7 @@ impl Cmov for u16 {
2324
}
2425
}
2526

27+
#[cfg_attr(docsrs, doc(cfg(true)))]
2628
impl Cmov for u32 {
2729
#[inline]
2830
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -35,6 +37,7 @@ impl Cmov for u32 {
3537
}
3638
}
3739

40+
#[cfg_attr(docsrs, doc(cfg(true)))]
3841
impl Cmov for u64 {
3942
#[inline]
4043
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -47,6 +50,7 @@ impl Cmov for u64 {
4750
}
4851
}
4952

53+
#[cfg_attr(docsrs, doc(cfg(true)))]
5054
impl CmovEq for u16 {
5155
#[inline]
5256
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -67,6 +71,7 @@ impl CmovEq for u16 {
6771
}
6872
}
6973

74+
#[cfg_attr(docsrs, doc(cfg(true)))]
7075
impl CmovEq for u32 {
7176
#[inline]
7277
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -79,6 +84,7 @@ impl CmovEq for u32 {
7984
}
8085
}
8186

87+
#[cfg_attr(docsrs, doc(cfg(true)))]
8288
impl CmovEq for u64 {
8389
#[inline]
8490
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -97,31 +103,31 @@ fn maskeq32(x: u32, y: u32) -> u32 {
97103
!maskne32(x, y)
98104
}
99105

100-
/// Returns `u32::MAX` if `x` is equal to `y`, otherwise returns `0` (64-bit version)
106+
/// Returns `u64::MAX` if `x` is equal to `y`, otherwise returns `0` (64-bit version)
101107
#[inline]
102108
fn maskeq64(x: u64, y: u64) -> u64 {
103109
!maskne64(x, y)
104110
}
105111

106-
/// Returns `0` if `x` is equal to `y`, otherwise returns `1` (32-bit version)
112+
/// Returns `0` if `x` is equal to `y`, otherwise returns `u32::MAX` (32-bit version)
107113
#[inline]
108114
fn maskne32(x: u32, y: u32) -> u32 {
109115
masknz32(x ^ y)
110116
}
111117

112-
/// Returns `0` if `x` is equal to `y`, otherwise returns `1` (64-bit version)
118+
/// Returns `0` if `x` is equal to `y`, otherwise returns `u64::MAX` (64-bit version)
113119
#[inline]
114120
fn maskne64(x: u64, y: u64) -> u64 {
115121
masknz64(x ^ y)
116122
}
117123

118-
/// Return a [`u32::MAX`] mask if `condition` is non-zero, otherwise return zero for a zero input.
124+
/// Return a `u32::MAX` mask if `condition` is non-zero, otherwise return zero for a zero input.
119125
#[cfg(not(target_arch = "arm"))]
120126
fn masknz32(condition: u32) -> u32 {
121127
masknz!(condition: u32)
122128
}
123129

124-
/// Return a [`u64::MAX`] mask if `condition` is non-zero, otherwise return zero for a zero input.
130+
/// Return a `u64::MAX` mask if `condition` is non-zero, otherwise return zero for a zero input.
125131
#[cfg(not(target_arch = "arm"))]
126132
fn masknz64(condition: u64) -> u64 {
127133
masknz!(condition: u64)

cmov/src/backends/x86.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ macro_rules! cmov_eq {
4545
};
4646
}
4747

48+
#[cfg_attr(docsrs, doc(cfg(true)))]
4849
impl Cmov for u16 {
4950
#[inline]
5051
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -57,6 +58,7 @@ impl Cmov for u16 {
5758
}
5859
}
5960

61+
#[cfg_attr(docsrs, doc(cfg(true)))]
6062
impl Cmov for u32 {
6163
#[inline]
6264
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -70,6 +72,7 @@ impl Cmov for u32 {
7072
}
7173

7274
#[cfg(target_arch = "x86")]
75+
#[cfg_attr(docsrs, doc(cfg(true)))]
7376
impl Cmov for u64 {
7477
#[inline]
7578
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -95,6 +98,7 @@ impl Cmov for u64 {
9598
}
9699

97100
#[cfg(target_arch = "x86_64")]
101+
#[cfg_attr(docsrs, doc(cfg(true)))]
98102
impl Cmov for u64 {
99103
#[inline]
100104
fn cmovnz(&mut self, value: &Self, condition: Condition) {
@@ -107,6 +111,7 @@ impl Cmov for u64 {
107111
}
108112
}
109113

114+
#[cfg_attr(docsrs, doc(cfg(true)))]
110115
impl CmovEq for u16 {
111116
#[inline]
112117
fn cmoveq(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -133,6 +138,7 @@ impl CmovEq for u16 {
133138
}
134139
}
135140

141+
#[cfg_attr(docsrs, doc(cfg(true)))]
136142
impl CmovEq for u32 {
137143
#[inline]
138144
fn cmoveq(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -160,6 +166,7 @@ impl CmovEq for u32 {
160166
}
161167

162168
#[cfg(target_arch = "x86")]
169+
#[cfg_attr(docsrs, doc(cfg(true)))]
163170
impl CmovEq for u64 {
164171
#[inline]
165172
fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
@@ -185,6 +192,7 @@ impl CmovEq for u64 {
185192
}
186193

187194
#[cfg(target_arch = "x86_64")]
195+
#[cfg_attr(docsrs, doc(cfg(true)))]
188196
impl CmovEq for u64 {
189197
#[inline]
190198
fn cmoveq(&self, rhs: &Self, input: Condition, output: &mut Condition) {

0 commit comments

Comments
 (0)