Skip to content

Commit

Permalink
Merge #690
Browse files Browse the repository at this point in the history
690: Satisfy clippy r=Urhengulas a=Urhengulas

There are a couple of new clippy lints, most noticeable [warning: you are deriving `PartialEq` and can implement `Eq`](https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq).

Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
  • Loading branch information
bors[bot] and Urhengulas authored Aug 12, 2022
2 parents 0209947 + bcb2999 commit 86e9546
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion decoder/src/elf2table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub fn get_locations(elf: &[u8], table: &Table) -> Result<Locations, anyhow::Err
let borrow_section: &dyn for<'a> Fn(
&'a Cow<[u8]>,
) -> gimli::EndianSlice<'a, gimli::RunTimeEndian> =
&|section| gimli::EndianSlice::new(&*section, endian);
&|section| gimli::EndianSlice::new(section, endian);

let dwarf = dwarf_cow.borrow(&borrow_section);

Expand Down
8 changes: 4 additions & 4 deletions decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Tag {
}

/// Entry in [`Table`] combining a format string with its raw symbol
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub struct TableEntry {
string: StringEntry,
raw_symbol: String,
Expand All @@ -97,7 +97,7 @@ impl TableEntry {
}

/// A format string and it's [`Tag`]
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub struct StringEntry {
tag: Tag,
string: String,
Expand All @@ -118,7 +118,7 @@ struct BitflagsKey {
disambig: String,
}

#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum Encoding {
Raw,
Expand Down Expand Up @@ -147,7 +147,7 @@ impl Encoding {
}

/// Internal table that holds log levels and maps format strings to indices
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub struct Table {
timestamp: Option<TableEntry>,
entries: BTreeMap<usize, TableEntry>,
Expand Down
2 changes: 1 addition & 1 deletion decoder/src/log/pretty_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ fn print_location<W: io::Write>(
let mod_path = module_path.unwrap();
let mut loc = file.to_string();
if let Some(line) = line {
loc.push_str(&format!(":{}", line));
let _ = write!(loc, ":{}", line);
}
writeln!(sink, "{}", format!("└─ {} @ {}", mod_path, loc).dimmed())?;
}
Expand Down
2 changes: 1 addition & 1 deletion decoder/src/stream/rzcobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> StreamDecoder for Rzcobs<'a> {
fn received(&mut self, mut data: &[u8]) {
// Trim zeros from the left, start storing at first non-zero byte.
if self.raw.is_empty() {
while data.get(0) == Some(&0) {
while data.first() == Some(&0) {
data = &data[1..]
}
}
Expand Down
18 changes: 10 additions & 8 deletions parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{borrow::Cow, ops::Range, str::FromStr};
pub use crate::types::Type;

/// A parameter of the form `{{0=Type:hint}}` in a format string.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Parameter {
/// The argument index to display at this position.
pub index: usize,
Expand All @@ -28,14 +28,14 @@ pub struct Parameter {
}

/// Precision of ISO8601 datetime
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum TimePrecision {
Millis,
Seconds,
}

/// All display hints
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum DisplayHint {
NoHint {
zero_pad: usize,
Expand Down Expand Up @@ -133,7 +133,7 @@ fn parse_display_hint(mut s: &str) -> Option<DisplayHint> {
}

/// A part of a format string.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Fragment<'f> {
/// A literal string (eg. `"literal "` in `"literal {:?}"`).
Literal(Cow<'f, str>),
Expand Down Expand Up @@ -170,7 +170,7 @@ struct Param {
}

/// The log level
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd)]
pub enum Level {
Trace,
Debug,
Expand Down Expand Up @@ -246,7 +246,7 @@ fn parse_array(mut s: &str) -> Result<usize, Cow<'static, str>> {

// consume length
let after_len = s
.find(|c: char| !c.is_digit(10))
.find(|c: char| !c.is_ascii_digit())
.ok_or("invalid array specifier (missing `]`)")?;
let len = s[..after_len].parse::<usize>().map_err(|e| e.to_string())?;
s = &s[after_len..];
Expand All @@ -260,7 +260,7 @@ fn parse_array(mut s: &str) -> Result<usize, Cow<'static, str>> {
}

/// Parser mode
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ParserMode {
/// Rejects unknown display hints
Strict,
Expand All @@ -277,7 +277,9 @@ fn parse_param(mut input: &str, mode: ParserMode) -> Result<Param, Cow<'static,

// First, optional argument index.
let mut index = None;
let index_end = input.find(|c: char| !c.is_digit(10)).unwrap_or(input.len());
let index_end = input
.find(|c: char| !c.is_ascii_digit())
.unwrap_or(input.len());

if index_end != 0 {
index = Some(
Expand Down
2 changes: 1 addition & 1 deletion parser/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{ops::Range, str::FromStr};

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Type {
BitField(Range<u8>),
Bool,
Expand Down

0 comments on commit 86e9546

Please sign in to comment.