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

File tree

19 files changed

+68
-57
lines changed

19 files changed

+68
-57
lines changed

.rustfmt.toml

Lines changed: 2 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 6 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 10 additions & 9 deletions
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,

0 commit comments

Comments
 (0)