Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Apr 5, 2019
1 parent 8537fac commit 4379109
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/read/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,13 @@ impl<R: Reader> Dwarf<R> {
///
/// This uses information from the DWARF sections to provide more information in some cases.
pub fn format_error(&self, err: Error) -> String {
#[allow(clippy::single_match)]
match err {
Error::UnexpectedEof(id) => match self.lookup_offset_id(id) {
Some((sup, section, offset)) => {
return format!(
"{} at {}{}+0x{:x}",
err.description(),
err,
section.name(),
if sup { "(sup)" } else { "" },
offset.into_u64(),
Expand All @@ -410,7 +411,7 @@ impl<R: Reader> Dwarf<R> {
},
_ => {}
}
format!("{}", err.description())
format!("{}", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/read/endian_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ where
self.bytes()
.iter()
.position(|x| *x == byte)
.ok_or(Error::UnexpectedEof(self.offset_id()))
.ok_or_else(|| Error::UnexpectedEof(self.offset_id()))
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/read/endian_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ where
#[inline]
fn find(&self, byte: u8) -> Result<usize> {
self.find(byte)
.ok_or(Error::UnexpectedEof(self.offset_id()))
.ok_or_else(|| Error::UnexpectedEof(self.offset_id()))
}

#[inline]
Expand Down
14 changes: 7 additions & 7 deletions src/write/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl LineProgram {
line_encoding,
directories: IndexSet::new(),
files: IndexMap::new(),
comp_file: (comp_file, comp_file_info.unwrap_or(FileInfo::default())),
comp_file: (comp_file, comp_file_info.unwrap_or_default()),
prev_row: LineRow::initial_state(line_encoding),
row: LineRow::initial_state(line_encoding),
instructions: Vec::new(),
Expand Down Expand Up @@ -570,7 +570,7 @@ impl LineProgram {
w.write_u8(1)?;
w.write_uleb128(u64::from(constants::DW_LNCT_path.0))?;
let dir_form = self.directories.get_index(0).unwrap().form();
w.write_uleb128(u64::from(dir_form.0))?;
w.write_uleb128(dir_form.0)?;

// Directory entries.
w.write_uleb128(self.directories.len() as u64)?;
Expand All @@ -592,20 +592,20 @@ impl LineProgram {
w.write_u8(count)?;
w.write_uleb128(u64::from(constants::DW_LNCT_path.0))?;
let file_form = self.comp_file.0.form();
w.write_uleb128(u64::from(file_form.0))?;
w.write_uleb128(file_form.0)?;
w.write_uleb128(u64::from(constants::DW_LNCT_directory_index.0))?;
w.write_uleb128(u64::from(constants::DW_FORM_udata.0))?;
w.write_uleb128(constants::DW_FORM_udata.0)?;
if self.file_has_timestamp {
w.write_uleb128(u64::from(constants::DW_LNCT_timestamp.0))?;
w.write_uleb128(u64::from(constants::DW_FORM_udata.0))?;
w.write_uleb128(constants::DW_FORM_udata.0)?;
}
if self.file_has_size {
w.write_uleb128(u64::from(constants::DW_LNCT_size.0))?;
w.write_uleb128(u64::from(constants::DW_FORM_udata.0))?;
w.write_uleb128(constants::DW_FORM_udata.0)?;
}
if self.file_has_md5 {
w.write_uleb128(u64::from(constants::DW_LNCT_MD5.0))?;
w.write_uleb128(u64::from(constants::DW_FORM_data16.0))?;
w.write_uleb128(constants::DW_FORM_data16.0)?;
}

// File name entries.
Expand Down
3 changes: 2 additions & 1 deletion src/write/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ impl Attribute {

/// Write the attribute to the given sections.
#[inline]
#[allow(clippy::too_many_arguments)]
fn write<W: Writer>(
&self,
w: &mut DebugInfo<W>,
Expand Down Expand Up @@ -891,7 +892,7 @@ impl AttributeValue {
}

/// Write the attribute value to the given sections.
#[allow(clippy::cyclomatic_complexity)]
#[allow(clippy::cyclomatic_complexity, clippy::too_many_arguments)]
fn write<W: Writer>(
&self,
w: &mut DebugInfo<W>,
Expand Down

0 comments on commit 4379109

Please sign in to comment.