Skip to content

Commit b1c76e4

Browse files
committed
Document required features for APIs
1 parent 62aa185 commit b1c76e4

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

src/capture.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ use {resolve, resolve_frame, trace, Symbol, SymbolName};
1212
///
1313
/// `Backtrace` supports pretty-printing of backtraces through its `Debug`
1414
/// implementation.
15+
///
16+
/// # Required features
17+
///
18+
/// This function requires the `std` feature of the `backtrace` crate to be
19+
/// enabled, and the `std` feature is enabled by default.
1520
#[derive(Clone)]
1621
#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))]
1722
#[cfg_attr(feature = "serialize-serde", derive(Deserialize, Serialize))]
@@ -32,6 +37,11 @@ fn _assert_send_sync() {
3237
///
3338
/// This type is returned as a list from `Backtrace::frames` and represents one
3439
/// stack frame in a captured backtrace.
40+
///
41+
/// # Required features
42+
///
43+
/// This function requires the `std` feature of the `backtrace` crate to be
44+
/// enabled, and the `std` feature is enabled by default.
3545
#[derive(Clone)]
3646
pub struct BacktraceFrame {
3747
frame: Frame,
@@ -65,6 +75,11 @@ impl Frame {
6575
///
6676
/// This type is returned as a list from `BacktraceFrame::symbols` and
6777
/// represents the metadata for a symbol in a backtrace.
78+
///
79+
/// # Required features
80+
///
81+
/// This function requires the `std` feature of the `backtrace` crate to be
82+
/// enabled, and the `std` feature is enabled by default.
6883
#[derive(Clone)]
6984
#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))]
7085
#[cfg_attr(feature = "serialize-serde", derive(Deserialize, Serialize))]
@@ -91,6 +106,11 @@ impl Backtrace {
91106
///
92107
/// let current_backtrace = Backtrace::new();
93108
/// ```
109+
///
110+
/// # Required features
111+
///
112+
/// This function requires the `std` feature of the `backtrace` crate to be
113+
/// enabled, and the `std` feature is enabled by default.
94114
#[inline(never)] // want to make sure there's a frame here to remove
95115
pub fn new() -> Backtrace {
96116
let _guard = lock_and_platform_init();
@@ -117,6 +137,11 @@ impl Backtrace {
117137
/// current_backtrace.resolve();
118138
/// println!("{:?}", current_backtrace); // symbol names now present
119139
/// ```
140+
///
141+
/// # Required features
142+
///
143+
/// This function requires the `std` feature of the `backtrace` crate to be
144+
/// enabled, and the `std` feature is enabled by default.
120145
#[inline(never)] // want to make sure there's a frame here to remove
121146
pub fn new_unresolved() -> Backtrace {
122147
let _guard = lock_and_platform_init();
@@ -157,6 +182,11 @@ impl Backtrace {
157182
/// The first entry of this slice is likely the function `Backtrace::new`,
158183
/// and the last frame is likely something about how this thread or the main
159184
/// function started.
185+
///
186+
/// # Required features
187+
///
188+
/// This function requires the `std` feature of the `backtrace` crate to be
189+
/// enabled, and the `std` feature is enabled by default.
160190
pub fn frames(&self) -> &[BacktraceFrame] {
161191
&self.frames[self.actual_start_index..]
162192
}
@@ -166,6 +196,11 @@ impl Backtrace {
166196
///
167197
/// If this backtrace has been previously resolved or was created through
168198
/// `new`, this function does nothing.
199+
///
200+
/// # Required features
201+
///
202+
/// This function requires the `std` feature of the `backtrace` crate to be
203+
/// enabled, and the `std` feature is enabled by default.
169204
pub fn resolve(&mut self) {
170205
let _guard = lock_and_platform_init();
171206
for frame in self.frames.iter_mut().filter(|f| f.symbols.is_none()) {
@@ -208,11 +243,21 @@ impl Into<Vec<BacktraceFrame>> for Backtrace {
208243

209244
impl BacktraceFrame {
210245
/// Same as `Frame::ip`
246+
///
247+
/// # Required features
248+
///
249+
/// This function requires the `std` feature of the `backtrace` crate to be
250+
/// enabled, and the `std` feature is enabled by default.
211251
pub fn ip(&self) -> *mut c_void {
212252
self.frame.ip() as *mut c_void
213253
}
214254

215255
/// Same as `Frame::symbol_address`
256+
///
257+
/// # Required features
258+
///
259+
/// This function requires the `std` feature of the `backtrace` crate to be
260+
/// enabled, and the `std` feature is enabled by default.
216261
pub fn symbol_address(&self) -> *mut c_void {
217262
self.frame.symbol_address() as *mut c_void
218263
}
@@ -226,28 +271,53 @@ impl BacktraceFrame {
226271
///
227272
/// Note that if this frame came from an unresolved backtrace then this will
228273
/// return an empty list.
274+
///
275+
/// # Required features
276+
///
277+
/// This function requires the `std` feature of the `backtrace` crate to be
278+
/// enabled, and the `std` feature is enabled by default.
229279
pub fn symbols(&self) -> &[BacktraceSymbol] {
230280
self.symbols.as_ref().map(|s| &s[..]).unwrap_or(&[])
231281
}
232282
}
233283

234284
impl BacktraceSymbol {
235285
/// Same as `Symbol::name`
286+
///
287+
/// # Required features
288+
///
289+
/// This function requires the `std` feature of the `backtrace` crate to be
290+
/// enabled, and the `std` feature is enabled by default.
236291
pub fn name(&self) -> Option<SymbolName> {
237292
self.name.as_ref().map(|s| SymbolName::new(s))
238293
}
239294

240295
/// Same as `Symbol::addr`
296+
///
297+
/// # Required features
298+
///
299+
/// This function requires the `std` feature of the `backtrace` crate to be
300+
/// enabled, and the `std` feature is enabled by default.
241301
pub fn addr(&self) -> Option<*mut c_void> {
242302
self.addr.map(|s| s as *mut c_void)
243303
}
244304

245305
/// Same as `Symbol::filename`
306+
///
307+
/// # Required features
308+
///
309+
/// This function requires the `std` feature of the `backtrace` crate to be
310+
/// enabled, and the `std` feature is enabled by default.
246311
pub fn filename(&self) -> Option<&Path> {
247312
self.filename.as_ref().map(|p| &**p)
248313
}
249314

250315
/// Same as `Symbol::lineno`
316+
///
317+
/// # Required features
318+
///
319+
/// This function requires the `std` feature of the `backtrace` crate to be
320+
/// enabled, and the `std` feature is enabled by default.
251321
pub fn lineno(&self) -> Option<u32> {
252322
self.lineno
253323
}

src/symbolize/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ impl Symbol {
183183
/// debuginfo. If neither of these conditions is met then this will likely
184184
/// return `None`.
185185
///
186-
/// This function requires the `std` feature to be enabled for this crate.
186+
/// # Required features
187+
///
188+
/// This function requires the `std` feature of the `backtrace` crate to be
189+
/// enabled, and the `std` feature is enabled by default.
187190
#[cfg(feature = "std")]
188191
#[allow(unreachable_code)]
189192
pub fn filename(&self) -> Option<&Path> {

src/types.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ pub enum BytesOrWideString<'a> {
2929
impl<'a> BytesOrWideString<'a> {
3030
/// Lossy converts to a `Cow<str>`, will allocate if `Bytes` is not valid
3131
/// UTF-8 or if `BytesOrWideString` is `Wide`.
32+
///
33+
/// # Required features
34+
///
35+
/// This function requires the `std` feature of the `backtrace` crate to be
36+
/// enabled, and the `std` feature is enabled by default.
3237
pub fn to_str_lossy(&self) -> Cow<'a, str> {
3338
use self::BytesOrWideString::*;
3439

@@ -39,6 +44,11 @@ impl<'a> BytesOrWideString<'a> {
3944
}
4045

4146
/// Provides a `Path` representation of `BytesOrWideString`.
47+
///
48+
/// # Required features
49+
///
50+
/// This function requires the `std` feature of the `backtrace` crate to be
51+
/// enabled, and the `std` feature is enabled by default.
4252
pub fn into_path_buf(self) -> PathBuf {
4353
#[cfg(unix)]
4454
{

0 commit comments

Comments
 (0)