Skip to content

Commit

Permalink
Fix clippy and rustdoc lints (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem authored Mar 20, 2024
1 parent b052964 commit 28b1eb0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 21 deletions.
8 changes: 4 additions & 4 deletions examples/pdb2hpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use pdb::FallibleIterator;

type TypeSet = BTreeSet<pdb::TypeIndex>;

pub fn type_name<'p>(
type_finder: &pdb::TypeFinder<'p>,
pub fn type_name(
type_finder: &pdb::TypeFinder<'_>,
type_index: pdb::TypeIndex,
needed_types: &mut TypeSet,
) -> pdb::Result<String> {
Expand Down Expand Up @@ -357,8 +357,8 @@ impl<'p> Method<'p> {
}
}

fn argument_list<'p>(
type_finder: &pdb::TypeFinder<'p>,
fn argument_list(
type_finder: &pdb::TypeFinder<'_>,
type_index: pdb::TypeIndex,
needed_types: &mut TypeSet,
) -> pdb::Result<Vec<String>> {
Expand Down
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::result;
use std::slice;

use scroll::ctx::TryFromCtx;
use scroll::{self, Endian, Pread, LE};
use scroll::{Endian, Pread, LE};

use crate::tpi::constants;

Expand Down Expand Up @@ -581,7 +581,7 @@ pub trait ItemIndex:
/// [`ModuleInfo`](crate::ModuleInfo). Note that this comparison needs to be done
/// case-insensitively as the name in the DBI stream and name table are known to not
/// have matching cases.
/// 4. Resolve the [`Local`](crate::Local) index into a global one using
/// 4. Resolve the [`Local`] index into a global one using
/// [`CrossModuleExports`](crate::CrossModuleExports).
///
/// Cross module references are specially formatted indexes with the most significant bit set to
Expand Down
7 changes: 3 additions & 4 deletions src/modi/c13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use scroll::{ctx::TryFromCtx, Endian, Pread};

use crate::common::*;
use crate::modi::{
constants, CrossModuleExport, CrossModuleRef, FileChecksum, FileIndex, FileInfo, LineInfo,
LineInfoKind, ModuleRef,
constants, CrossModuleExport, CrossModuleRef, FileChecksum, FileInfo, LineInfo, LineInfoKind,
ModuleRef,
};
use crate::symbol::{BinaryAnnotation, BinaryAnnotationsIter, InlineSiteSymbol};
use crate::FallibleIterator;
Expand Down Expand Up @@ -345,6 +345,7 @@ enum LineEntry {
/// Declares a source line number.
Number(LineNumberEntry),
/// Declares a debugging marker.
#[allow(dead_code)] // reason = "the inner `LineMarkerEntry` is not (yet) accessed"
Marker(LineMarkerEntry),
}

Expand Down Expand Up @@ -1418,8 +1419,6 @@ impl<'a> LineProgram<'a> {
mod tests {
use super::*;

use std::mem;

use crate::symbol::BinaryAnnotations;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/modi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'s> ModuleInfo<'s> {
}

fn lines_data(&self, size: usize) -> &[u8] {
let start = self.symbols_size as usize;
let start = self.symbols_size;
&self.stream[start..start + size]
}

Expand Down
2 changes: 1 addition & 1 deletion src/msf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ mod big {
let _ = stream_table.take((stream_count - stream_number - 1) as usize * 4)?;

// skip the preceding streams' page numbers
let _ = stream_table.take((page_numbers_to_skip as usize) * 4)?;
let _ = stream_table.take(page_numbers_to_skip * 4)?;

// we're now at the list of pages for our stream
// accumulate them into a PageList
Expand Down
1 change: 0 additions & 1 deletion src/msf/page_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ impl PageList {
#[cfg(test)]
mod tests {
use crate::msf::page_list::*;
use crate::source::SourceSlice;

#[test]
fn test_push() {
Expand Down
4 changes: 1 addition & 3 deletions src/omap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl fmt::Debug for OMAPRecord {
impl PartialOrd for OMAPRecord {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.source_address().partial_cmp(&other.source_address())
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -577,8 +577,6 @@ impl PdbInternalSectionOffset {
mod tests {
use super::*;

use std::mem;

#[test]
fn test_omap_record() {
assert_eq!(mem::size_of::<OMAPRecord>(), 8);
Expand Down
2 changes: 1 addition & 1 deletion src/tpi/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub(crate) fn parse_type_data<'t>(buf: &mut ParseBuffer<'t>) -> Result<TypeData<
attributes: attr,
method_type: buf.parse()?,
vtable_offset: if attr.is_intro_virtual() {
Some(buf.parse_u32()? as u32)
Some(buf.parse_u32()?)
} else {
// yes, this is variable length
None
Expand Down
7 changes: 3 additions & 4 deletions src/tpi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ where
/// populated by calling [`ItemFinder::update`] while iterating. There are two typedefs for easier
/// use:
///
/// - [`TypeFinder`] for finding [`Type`]s in a [`TypeInformation`](crate::TypeInformation) (TPI stream).
/// - [`IdFinder`] for finding [`Id`]s in a [`IdInformation`](crate::IdInformation) (IPI stream).
/// - [`TypeFinder`] for finding [`Type`]s in a [`TypeInformation`] (TPI stream).
/// - [`IdFinder`] for finding [`Id`]s in a [`IdInformation`] (IPI stream).
///
/// `ItemFinder` allocates all the memory it needs when it is first created. The footprint is
/// directly proportional to the total number of types; see [`ItemInformation::len`].
Expand Down Expand Up @@ -434,8 +434,7 @@ where
}
}

/// An iterator over items in [`TypeInformation`](crate::TypeInformation) or
/// [`IdInformation`](crate::IdInformation).
/// An iterator over items in [`TypeInformation`] or [`IdInformation`].
///
/// The TPI and IPI streams are represented internally as a series of records, each of which have a
/// length, a kind, and a type-specific field layout. Iteration performance is therefore similar to
Expand Down

0 comments on commit 28b1eb0

Please sign in to comment.