|
3 | 3 | #![deny(clippy::missing_docs_in_private_items)]
|
4 | 4 |
|
5 | 5 | use lazy_static::lazy_static;
|
| 6 | +use std::default::Default; |
6 | 7 | use std::{env, fmt, fs, io, path};
|
7 | 8 | use std::io::Read;
|
8 | 9 | use syntax::{ast, source_map};
|
@@ -65,7 +66,7 @@ macro_rules! define_Conf {
|
65 | 66 | mod helpers {
|
66 | 67 | use serde_derive::Deserialize;
|
67 | 68 | /// Type used to store lint configuration.
|
68 |
| - #[derive(Default, Deserialize)] |
| 69 | + #[derive(Deserialize)] |
69 | 70 | #[serde(rename_all="kebab-case", deny_unknown_fields)]
|
70 | 71 | pub struct Conf {
|
71 | 72 | $(#[$doc] #[serde(default=$rust_name_str)] #[serde(with=$rust_name_str)]
|
@@ -146,6 +147,12 @@ define_Conf! {
|
146 | 147 | (trivial_copy_size_limit, "trivial_copy_size_limit", None => Option<u64>),
|
147 | 148 | }
|
148 | 149 |
|
| 150 | +impl Default for Conf { |
| 151 | + fn default() -> Conf { |
| 152 | + toml::from_str("").expect("we never error on empty config files") |
| 153 | + } |
| 154 | +} |
| 155 | + |
149 | 156 | /// Search for the configuration file.
|
150 | 157 | pub fn lookup_conf_file() -> io::Result<Option<path::PathBuf>> {
|
151 | 158 | /// Possible filename to search for.
|
@@ -180,7 +187,7 @@ pub fn lookup_conf_file() -> io::Result<Option<path::PathBuf>> {
|
180 | 187 | ///
|
181 | 188 | /// Used internally for convenience
|
182 | 189 | 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) |
184 | 191 | }
|
185 | 192 |
|
186 | 193 | /// Read the `toml` configuration file.
|
|
0 commit comments