From 4050a689891c012c31175430349bb20cf3a739bc Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 4 Sep 2018 09:12:50 +1200 Subject: [PATCH] Make `Default` do what `default` used to do --- clippy_lints/src/utils/conf.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 8ec889a9f..16e39ff13 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -3,6 +3,7 @@ #![deny(clippy::missing_docs_in_private_items)] use lazy_static::lazy_static; +use std::default::Default; use std::{env, fmt, fs, io, path}; use std::io::Read; use syntax::{ast, source_map}; @@ -65,7 +66,7 @@ macro_rules! define_Conf { mod helpers { use serde_derive::Deserialize; /// Type used to store lint configuration. - #[derive(Default, Deserialize)] + #[derive(Deserialize)] #[serde(rename_all="kebab-case", deny_unknown_fields)] pub struct Conf { $(#[$doc] #[serde(default=$rust_name_str)] #[serde(with=$rust_name_str)] @@ -146,6 +147,12 @@ define_Conf! { (trivial_copy_size_limit, "trivial_copy_size_limit", None => Option), } +impl Default for Conf { + fn default() -> Conf { + toml::from_str("").expect("we never error on empty config files") + } +} + /// Search for the configuration file. pub fn lookup_conf_file() -> io::Result> { /// Possible filename to search for. @@ -180,7 +187,7 @@ pub fn lookup_conf_file() -> io::Result> { /// /// Used internally for convenience fn default(errors: Vec) -> (Conf, Vec) { - (toml::from_str("").expect("we never error on empty config files"), errors) + (Conf::default(), errors) } /// Read the `toml` configuration file.