Skip to content

Commit 951d2ba

Browse files
committed
Add doc(cfg()) noting that some functions need nightly
Signed-off-by: Joe Richey <[email protected]>
1 parent 8d61248 commit 951d2ba

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ inline_asm = []
4242
abi_x86_interrupt = []
4343
const_fn = []
4444

45+
[package.metadata.docs.rs]
46+
rustdoc-args = ["--cfg", "docsrs"]
47+
4548
[package.metadata.release]
4649
no-dev-version = true
4750
pre-release-replacements = [

src/instructions/interrupts.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,14 @@ pub fn int3() {
152152
/// This currently needs to be a macro because the `int` argument needs to be an
153153
/// immediate. This macro will be replaced by a generic function when support for
154154
/// const generics is implemented in Rust.
155-
#[cfg(feature = "inline_asm")]
155+
#[cfg_attr(docsrs, doc(cfg(feature = "nightly")))]
156156
#[macro_export]
157157
macro_rules! software_interrupt {
158158
($x:expr) => {{
159+
#[cfg(feature = "inline_asm")]
159160
asm!("int {id}", id = const $x, options(nomem, nostack));
160-
}};
161-
}
162161

163-
/// Not implemented
164-
#[cfg(not(feature = "inline_asm"))]
165-
#[macro_export]
166-
macro_rules! software_interrupt {
167-
($x:expr) => {{
168-
compile_error!("software_interrupt not implemented for non-nightly");
162+
#[cfg(not(feature = "inline_asm"))]
163+
compile_error!("software_interrupt!() requires \"nightly\" feature");
169164
}};
170165
}

src/instructions/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ pub fn bochs_breakpoint() {
5353

5454
/// Gets the current instruction pointer. Note that this is only approximate as it requires a few
5555
/// instructions to execute.
56-
#[cfg(feature = "inline_asm")]
56+
#[cfg_attr(docsrs, doc(cfg(feature = "nightly")))]
5757
#[inline(always)]
5858
pub fn read_rip() -> crate::VirtAddr {
5959
let rip: u64;
60+
#[cfg(feature = "inline_asm")]
6061
unsafe {
61-
asm!(
62-
"lea {}, [rip]", out(reg) rip, options(nostack, nomem, preserves_flags)
63-
);
62+
asm!("lea {}, [rip]", out(reg) rip, options(nostack, nomem, preserves_flags));
6463
}
64+
65+
#[cfg(not(feature = "inline_asm"))]
66+
compile_error!("read_rip() requires \"nightly\" feature");
6567
crate::VirtAddr::new(rip)
6668
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![cfg_attr(feature = "const_fn", feature(const_fn_trait_bound))]
99
#![cfg_attr(feature = "inline_asm", feature(asm))]
1010
#![cfg_attr(feature = "abi_x86_interrupt", feature(abi_x86_interrupt))]
11+
#![cfg_attr(docsrs, feature(doc_cfg))]
1112
#![warn(missing_docs)]
1213
#![deny(missing_debug_implementations)]
1314

0 commit comments

Comments
 (0)