Skip to content

Commit b7587d8

Browse files
authored
Merge pull request #3125 from nrc/pub-conf
Make `Default` do what `default` used to do
2 parents f5804dd + 4050a68 commit b7587d8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

clippy_lints/src/utils/conf.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![deny(clippy::missing_docs_in_private_items)]
44

55
use lazy_static::lazy_static;
6+
use std::default::Default;
67
use std::{env, fmt, fs, io, path};
78
use std::io::Read;
89
use syntax::{ast, source_map};
@@ -65,7 +66,7 @@ macro_rules! define_Conf {
6566
mod helpers {
6667
use serde_derive::Deserialize;
6768
/// Type used to store lint configuration.
68-
#[derive(Default, Deserialize)]
69+
#[derive(Deserialize)]
6970
#[serde(rename_all="kebab-case", deny_unknown_fields)]
7071
pub struct Conf {
7172
$(#[$doc] #[serde(default=$rust_name_str)] #[serde(with=$rust_name_str)]
@@ -146,6 +147,12 @@ define_Conf! {
146147
(trivial_copy_size_limit, "trivial_copy_size_limit", None => Option<u64>),
147148
}
148149

150+
impl Default for Conf {
151+
fn default() -> Conf {
152+
toml::from_str("").expect("we never error on empty config files")
153+
}
154+
}
155+
149156
/// Search for the configuration file.
150157
pub fn lookup_conf_file() -> io::Result<Option<path::PathBuf>> {
151158
/// Possible filename to search for.
@@ -180,7 +187,7 @@ pub fn lookup_conf_file() -> io::Result<Option<path::PathBuf>> {
180187
///
181188
/// Used internally for convenience
182189
fn default(errors: Vec<Error>) -> (Conf, Vec<Error>) {
183-
(toml::from_str("").expect("we never error on empty config files"), errors)
190+
(Conf::default(), errors)
184191
}
185192

186193
/// Read the `toml` configuration file.

0 commit comments

Comments
 (0)