Skip to content

Commit d4af1b0

Browse files
committed
Let rustfmt take care of wrapping comments
It turns out rustfmt can ensure a consistent comment length by applying automatic wrapping. Let's enable the functionality to get some more consistency into the code base and ensure that pull requests adhere to a basic standard in the process. Signed-off-by: Daniel Müller <[email protected]>
1 parent 18c0538 commit d4af1b0

19 files changed

+68
-57
lines changed

.rustfmt.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
blank_lines_upper_bound = 2
22
imports_granularity = "item"
33
trailing_semicolon = false
4+
wrap_comments = true
5+
comment_width = 80

capi/include/blazesym.h

-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ const struct blaze_sym_info *const *blaze_inspect_syms_elf(const blaze_inspector
485485
* # Safety
486486
*
487487
* The pointer must be returned by [`blaze_inspect_syms_elf`].
488-
*
489488
*/
490489
void blaze_inspect_syms_free(const struct blaze_sym_info *const *syms);
491490

capi/src/inspect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ pub unsafe extern "C" fn blaze_inspect_syms_elf(
275275
/// # Safety
276276
///
277277
/// The pointer must be returned by [`blaze_inspect_syms_elf`].
278-
///
279278
#[no_mangle]
280279
pub unsafe extern "C" fn blaze_inspect_syms_free(syms: *const *const blaze_sym_info) {
281280
if syms.is_null() {
@@ -476,7 +475,8 @@ mod tests {
476475
let () = unsafe { blaze_inspector_free(inspector) };
477476
}
478477

479-
/// Make sure that we can lookup a function's address using DWARF information.
478+
/// Make sure that we can lookup a function's address using DWARF
479+
/// information.
480480
#[test]
481481
fn lookup_dwarf() {
482482
let test_dwarf = Path::new(&env!("CARGO_MANIFEST_DIR"))

capi/src/symbolize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,8 @@ mod tests {
10251025
test(symbolize, true);
10261026
}
10271027

1028-
/// Symbolize an address inside a DWARF file, with and without auto-demangling
1029-
/// enabled.
1028+
/// Symbolize an address inside a DWARF file, with and without
1029+
/// auto-demangling enabled.
10301030
#[test]
10311031
fn symbolize_dwarf_demangle() {
10321032
fn test(path: &Path, addr: Addr) -> Result<(), ()> {

src/dwarf/lines.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ fn render_file<'dwarf>(
5757
Path::new("")
5858
};
5959

60-
// The directory index 0 is defined to correspond to the compilation unit directory.
60+
// The directory index 0 is defined to correspond to the compilation unit
61+
// directory.
6162
let dir = if file.directory_index() != 0 {
6263
if let Some(directory) = file.directory(header) {
6364
let d = sections.attr_string(dw_unit, directory)?;

src/dwarf/unit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ impl<'dwarf> Unit<'dwarf> {
9393
&self,
9494
sections: &gimli::Dwarf<R<'dwarf>>,
9595
) -> Result<Option<&Lines<'dwarf>>, gimli::Error> {
96-
// NB: line information is always stored in the main debug file so this does not need
97-
// to handle DWOs.
96+
// NB: line information is always stored in the main debug file so this does not
97+
// need to handle DWOs.
9898
let ilnp = match self.dw_unit.line_program {
9999
Some(ref ilnp) => ilnp,
100100
None => return Ok(None),

src/dwarf/units.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ impl<'dwarf> Units<'dwarf> {
8282
None => continue,
8383
};
8484
// We mainly want compile units, but we may need to follow references to entries
85-
// within other units for function names. We don't need anything from type units.
85+
// within other units for function names. We don't need anything from type
86+
// units.
8687
match header.type_() {
8788
gimli::UnitType::Type { .. } | gimli::UnitType::SplitType { .. } => continue,
8889
_ => {}
@@ -142,8 +143,8 @@ impl<'dwarf> Units<'dwarf> {
142143
// - DW_AT_low_pc/DW_AT_high_pc
143144
//
144145
// Using DW_AT_ranges before .debug_aranges is possibly an arbitrary choice,
145-
// but the feeling is that DW_AT_ranges is more likely to be reliable or complete
146-
// if it is present.
146+
// but the feeling is that DW_AT_ranges is more likely to be reliable or
147+
// complete if it is present.
147148
//
148149
// .debug_aranges must be used before DW_AT_low_pc/DW_AT_high_pc because
149150
// it has been observed on macOS that DW_AT_ranges was not emitted even for
@@ -245,8 +246,8 @@ impl<'dwarf> Units<'dwarf> {
245246

246247
/// Finds the CUs covering the range of addresses given.
247248
///
248-
/// The range is [low, high) (ie, the upper bound is exclusive). This can return multiple
249-
/// ranges for the same unit.
249+
/// The range is [low, high) (ie, the upper bound is exclusive). This can
250+
/// return multiple ranges for the same unit.
250251
#[inline]
251252
fn find_units_range(
252253
&self,
@@ -359,7 +360,8 @@ impl<'dwarf> Units<'dwarf> {
359360
Ok(None)
360361
}
361362

362-
/// Find the source file and line corresponding to the given virtual memory address.
363+
/// Find the source file and line corresponding to the given virtual memory
364+
/// address.
363365
pub fn find_location(&self, probe: u64) -> Result<Option<Location<'_>>, gimli::Error> {
364366
for unit in self.find_units(probe) {
365367
if let Some(location) = unit.find_location(probe, &self.dwarf)? {

src/elf/parser.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ struct Cache<'mmap> {
107107
symtab: OnceCell<Box<[&'mmap Elf64_Sym]>>, // in address order
108108
/// The cached ELF string table.
109109
strtab: OnceCell<&'mmap [u8]>,
110-
str2symtab: OnceCell<Box<[(&'mmap str, usize)]>>, // strtab offset to symtab in the dictionary order
110+
str2symtab: OnceCell<Box<[(&'mmap str, usize)]>>, /* strtab offset to symtab in the
111+
* dictionary order */
111112
}
112113

113114
impl<'mmap> Cache<'mmap> {

src/error.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,9 @@ pub enum ErrorKind {
370370
/// semantics, but in short:
371371
/// - If you want panics and errors to both have backtraces, set
372372
/// `RUST_BACKTRACE=1`
373-
/// - If you want only errors to have backtraces, set
374-
/// `RUST_LIB_BACKTRACE=1`
375-
/// - If you want only panics to have backtraces, set `RUST_BACKTRACE=1`
376-
/// and `RUST_LIB_BACKTRACE=0`
373+
/// - If you want only errors to have backtraces, set `RUST_LIB_BACKTRACE=1`
374+
/// - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and
375+
/// `RUST_LIB_BACKTRACE=0`
377376
// Representation is optimized for fast copying (a single machine word),
378377
// not so much for fast creation (as it is heap allocated). We generally
379378
// expect errors to be exceptional, though a lot of functionality is

src/gsym/linetab.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ pub struct LineTableHeader {
3838
impl LineTableHeader {
3939
/// Parse [`AddrData`] of type [`INFO_TYPE_LINE_TABLE_INFO`].
4040
///
41-
/// An `AddrData` of `INFO_TYPE_LINE_TABLE_INFO` type is a table of line numbers
42-
/// for a symbol. `AddrData` is the payload of `AddrInfo`. One `AddrInfo`
43-
/// may have several `AddrData` entries in its payload. Each `AddrData`
44-
/// entry stores a type of data related to the symbol the `AddrInfo`
45-
/// presents.
41+
/// An `AddrData` of `INFO_TYPE_LINE_TABLE_INFO` type is a table of line
42+
/// numbers for a symbol. `AddrData` is the payload of `AddrInfo`. One
43+
/// `AddrInfo` may have several `AddrData` entries in its payload. Each
44+
/// `AddrData` entry stores a type of data related to the symbol the
45+
/// `AddrInfo` presents.
4646
///
4747
/// # Arguments
4848
///
@@ -76,7 +76,8 @@ impl LineTableRow {
7676
///
7777
/// # Arguments
7878
///
79-
/// * `header` - is a [`LineTableHeader`] returned by [`parse_line_table_header()`].
79+
/// * `header` - is a [`LineTableHeader`] returned by
80+
/// [`parse_line_table_header()`].
8081
/// * `symaddr` - the address of the symbol that `header` belongs to.
8182
pub fn from_header(header: &LineTableHeader, symaddr: Addr) -> Self {
8283
Self {
@@ -93,11 +94,11 @@ impl LineTableRow {
9394
/// # Arguments
9495
///
9596
/// * `row` - a line table row to present the current states of the virtual
96-
/// machine. [`LineTableRow::from_header`] can create a `LineTableRow`
97-
/// to keep the states of a virtual machine.
97+
/// machine. [`LineTableRow::from_header`] can create a `LineTableRow` to keep
98+
/// the states of a virtual machine.
9899
/// * `header` - is a `LineTableHeader`.
99100
/// * `ops` - is the buffer of the operators following the `LineTableHeader` in
100-
/// a GSYM file.
101+
/// a GSYM file.
101102
pub fn run_op(
102103
row: &mut LineTableRow,
103104
header: &LineTableHeader,

src/gsym/parser.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ impl GsymContext<'_> {
8181
///
8282
/// * `data` - is the content of a standalone GSYM.
8383
///
84-
/// Returns a GsymContext, which includes the Header and other important tables.
84+
/// Returns a GsymContext, which includes the Header and other important
85+
/// tables.
8586
pub fn parse_header(data: &[u8]) -> Result<GsymContext> {
8687
fn parse_header_impl(mut data: &[u8]) -> Option<Result<GsymContext>> {
8788
let head = data;
@@ -140,8 +141,8 @@ impl GsymContext<'_> {
140141
.ok_or_invalid_data(|| "GSYM data does not contain sufficient bytes")?
141142
}
142143

143-
/// Find the index of an entry in the address table potentially containing the
144-
/// given address.
144+
/// Find the index of an entry in the address table potentially containing
145+
/// the given address.
145146
///
146147
/// Callers should check the `AddrInfo` object at the returned index to see
147148
/// whether the symbol actually covers the provided address.

src/gsym/resolver.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ mod tests {
364364
assert_eq!(resolver.file_name, None);
365365
}
366366

367-
/// Make sure that we can find file line information for a function, if available.
367+
/// Make sure that we can find file line information for a function, if
368+
/// available.
368369
#[test]
369370
fn find_line_info() {
370371
let test_gsym = Path::new(&env!("CARGO_MANIFEST_DIR"))

src/inspect/inspector.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ impl Inspector {
8484
///
8585
/// # Notes
8686
/// - no symbol name demangling is performed currently
87-
/// - currently only function symbols (as opposed to variables) are
88-
/// reported
89-
/// - undefined symbols (such as ones referencing a different shared
90-
/// object) are not reported
87+
/// - currently only function symbols (as opposed to variables) are reported
88+
/// - undefined symbols (such as ones referencing a different shared object)
89+
/// are not reported
9190
/// - for the [`Elf`](Source::Elf) source, at present DWARF symbols are
9291
/// ignored (irrespective of the [`debug_syms`][Elf::debug_syms]
9392
/// configuration)

src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! **blazesym** is a library that can be used to symbolize addresses. Address
2-
//! symbolization is a common problem in tracing contexts, for example, where users
3-
//! want to reason about functions by name, but low level components report only the
4-
//! "raw" addresses (e.g., in the form of stacktraces).
2+
//! symbolization is a common problem in tracing contexts, for example, where
3+
//! users want to reason about functions by name, but low level components
4+
//! report only the "raw" addresses (e.g., in the form of stacktraces).
55
//!
6-
//! In addition to symbolization, **blazesym** also provides APIs for the reverse
7-
//! operation: looking up addresses from symbol names. That can be useful, for
8-
//! example, for configuring breakpoints or tracepoints.
6+
//! In addition to symbolization, **blazesym** also provides APIs for the
7+
//! reverse operation: looking up addresses from symbol names. That can be
8+
//! useful, for example, for configuring breakpoints or tracepoints.
99
//!
1010
//! ## Overview
1111
//! The crate is organized via public modules that expose functionality

src/normalize/buildid.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn read_build_id_from_notes(parser: &ElfParser) -> Result<Option<Vec<u8>>> {
4242
Ok(None)
4343
}
4444

45-
/// Attempt to read an ELF binary's build ID from the .note.gnu.build-id section.
45+
/// Attempt to read an ELF binary's build ID from the .note.gnu.build-id
46+
/// section.
4647
fn read_build_id_from_section_name(parser: &ElfParser) -> Result<Option<Vec<u8>>> {
4748
let build_id_section = ".note.gnu.build-id";
4849
// The build ID is contained in the `.note.gnu.build-id` section. See
@@ -179,7 +180,8 @@ mod tests {
179180
use test_log::test;
180181

181182

182-
/// Check that we can read a binary's build ID based on the ELF section name as well as ELF section type.
183+
/// Check that we can read a binary's build ID based on the ELF section name
184+
/// as well as ELF section type.
183185
#[test]
184186
fn build_id_reading_from_name_and_notes() {
185187
fn test(f: fn(&ElfParser) -> Result<Option<Vec<u8>>>) {

src/normalize/normalizer.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub struct Output<M> {
2323
///
2424
/// A file offset is one as it would appear in a binary or debug symbol
2525
/// file, i.e., one excluding any relocations. The data reported here can be
26-
/// used with the [`symbolize::Input::FileOffset`][crate::symbolize::Input::FileOffset]
26+
/// used with the
27+
/// [`symbolize::Input::FileOffset`][crate::symbolize::Input::FileOffset]
2728
/// variant.
2829
pub outputs: Vec<(u64, usize)>,
2930
/// Meta information about the normalized outputs.

src/normalize/user.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ where
250250
/// normalized), could have a few reasons, including, but not limited
251251
/// to:
252252
/// - user error (if a bogus address was provided)
253-
/// - they belonged to an ELF object that has been unmapped since the
254-
/// address was captured
253+
/// - they belonged to an ELF object that has been unmapped since the address
254+
/// was captured
255255
///
256256
/// The process' ID should be provided in `pid`.
257257
///

src/once.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use std::hint::unreachable_unchecked;
99

1010
/// A cell which can be written to only once.
1111
///
12-
/// This allows obtaining a shared `&T` reference to its inner value without copying or replacing
13-
/// it (unlike [`Cell`]), and without runtime borrow checks (unlike [`RefCell`]). However,
14-
/// only immutable references can be obtained unless one has a mutable reference to the cell
15-
/// itself.
12+
/// This allows obtaining a shared `&T` reference to its inner value without
13+
/// copying or replacing it (unlike [`Cell`]), and without runtime borrow checks
14+
/// (unlike [`RefCell`]). However, only immutable references can be obtained
15+
/// unless one has a mutable reference to the cell itself.
1616
///
1717
/// For a thread-safe version of this struct, see [`std::sync::OnceLock`].
1818
///
@@ -117,8 +117,8 @@ impl<T> OnceCell<T> {
117117
if let Some(val) = self.get() {
118118
return Ok(val)
119119
}
120-
/// Avoid inlining the initialization closure into the common path that fetches
121-
/// the already initialized value
120+
/// Avoid inlining the initialization closure into the common path that
121+
/// fetches the already initialized value
122122
#[cold]
123123
fn outlined_call<F, T, E>(f: F) -> Result<T, E>
124124
where
@@ -190,5 +190,6 @@ impl<T> From<T> for OnceCell<T> {
190190
}
191191
}
192192

193-
// Just like for `Cell<T>` this isn't needed, but results in nicer error messages.
193+
// Just like for `Cell<T>` this isn't needed, but results in nicer error
194+
// messages.
194195
//impl<T> !Sync for OnceCell<T> {}

src/zip.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ struct CdFileHeader {
8484
disk: u16,
8585
internal_attributes: u16,
8686
external_attributes: u32,
87-
/// Offset from the start of the disk containing the local file header to the
88-
/// start of the local file header.
87+
/// Offset from the start of the disk containing the local file header to
88+
/// the start of the local file header.
8989
offset: u32,
9090
}
9191

@@ -118,7 +118,8 @@ unsafe impl Pod for LocalFileHeader {}
118118
/// Carries information on path, compression method, and data corresponding to a
119119
/// file in a zip archive.
120120
pub struct Entry<'archive> {
121-
/// Compression method as defined in pkzip spec. 0 means data is uncompressed.
121+
/// Compression method as defined in pkzip spec. 0 means data is
122+
/// uncompressed.
122123
pub compression: u16,
123124
/// The path to the file inside the archive.
124125
pub path: &'archive Path,

0 commit comments

Comments
 (0)