Apply #[derive(Default)] fixes suggested by Clippy (#2000)

These were bugging me every time I ran `clippy` 😁
This commit is contained in:
Aarni Koskela 2023-01-19 18:04:43 +02:00 committed by GitHub
parent 3c3da8a88c
commit a0ea8fe22f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 28 deletions

View File

@ -44,13 +44,14 @@ macro_rules! notify_user {
}
}
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Default, PartialOrd, Ord, PartialEq, Eq)]
pub enum LogLevel {
// No output (+ `log::LevelFilter::Off`).
Silent,
// Only show lint violations, with no decorative output (+ `log::LevelFilter::Off`).
Quiet,
// All user-facing output (+ `log::LevelFilter::Info`).
#[default]
Default,
// All user-facing output (+ `log::LevelFilter::Debug`).
Verbose,
@ -67,12 +68,6 @@ impl LogLevel {
}
}
impl Default for LogLevel {
fn default() -> Self {
LogLevel::Default
}
}
pub fn set_up_logging(level: &LogLevel) -> Result<()> {
fern::Dispatch::new()
.format(|out, message, record| {

View File

@ -4,18 +4,13 @@ use rustc_hash::FxHashMap;
use crate::ast;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum TrailingComma {
Present,
#[default]
Absent,
}
impl Default for TrailingComma {
fn default() -> Self {
TrailingComma::Absent
}
}
#[derive(Debug, Hash, Ord, PartialOrd, Eq, PartialEq, Clone)]
pub struct ImportFromData<'a> {
pub module: Option<&'a str>,

View File

@ -49,18 +49,13 @@ impl<'a> Stylist<'a> {
}
/// The quotation style used in Python source code.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, Default, PartialEq, Eq)]
pub enum Quote {
Single,
#[default]
Double,
}
impl Default for Quote {
fn default() -> Self {
Quote::Double
}
}
impl From<Quote> for char {
fn from(val: Quote) -> Self {
match val {
@ -123,19 +118,14 @@ impl Deref for Indentation {
/// The line ending style used in Python source code.
/// See <https://docs.python.org/3/reference/lexical_analysis.html#physical-lines>
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, Default, PartialEq, Eq)]
pub enum LineEnding {
#[default]
Lf,
Cr,
CrLf,
}
impl Default for LineEnding {
fn default() -> Self {
LineEnding::Lf
}
}
impl Deref for LineEnding {
type Target = str;