Skip to content

Commit d71b6d7

Browse files
committed
style: Re-enable lints
1 parent 5fbf977 commit d71b6d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+335
-346
lines changed

Cargo.toml

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,71 +19,71 @@ include = [
1919

2020
[workspace.lints.rust]
2121
# rust_2018_idioms = { level = "warn", priority = -1 }
22-
# unreachable_pub = "warn"
22+
unreachable_pub = "warn"
2323
unsafe_op_in_unsafe_fn = "warn"
2424
unused_lifetimes = "warn"
2525
unused_macro_rules = "warn"
26-
# unused_qualifications = "warn"
26+
unused_qualifications = "warn"
2727

2828
[workspace.lints.clippy]
2929
bool_assert_comparison = "allow"
3030
branches_sharing_code = "allow"
31-
# checked_conversions = "warn"
31+
checked_conversions = "warn"
3232
collapsible_else_if = "allow"
33-
# create_dir = "warn"
34-
# dbg_macro = "warn"
35-
# debug_assert_with_mut_call = "warn"
36-
# doc_markdown = "warn"
37-
# empty_enum = "warn"
38-
# enum_glob_use = "warn"
39-
# expl_impl_clone_on_copy = "warn"
40-
# explicit_deref_methods = "warn"
41-
# explicit_into_iter_loop = "warn"
42-
# fallible_impl_from = "warn"
43-
# filter_map_next = "warn"
44-
# flat_map_option = "warn"
45-
# float_cmp_const = "warn"
46-
# fn_params_excessive_bools = "warn"
47-
# from_iter_instead_of_collect = "warn"
33+
create_dir = "warn"
34+
dbg_macro = "warn"
35+
debug_assert_with_mut_call = "warn"
36+
doc_markdown = "warn"
37+
empty_enum = "warn"
38+
enum_glob_use = "warn"
39+
expl_impl_clone_on_copy = "warn"
40+
explicit_deref_methods = "warn"
41+
explicit_into_iter_loop = "warn"
42+
fallible_impl_from = "warn"
43+
filter_map_next = "warn"
44+
flat_map_option = "warn"
45+
float_cmp_const = "warn"
46+
fn_params_excessive_bools = "warn"
47+
from_iter_instead_of_collect = "warn"
4848
if_same_then_else = "allow"
49-
# implicit_clone = "warn"
50-
# imprecise_flops = "warn"
51-
# inconsistent_struct_constructor = "warn"
52-
# inefficient_to_string = "warn"
53-
# infinite_loop = "warn"
54-
# invalid_upcast_comparisons = "warn"
55-
# large_digit_groups = "warn"
56-
# large_stack_arrays = "warn"
57-
# large_types_passed_by_value = "warn"
49+
implicit_clone = "warn"
50+
imprecise_flops = "warn"
51+
inconsistent_struct_constructor = "warn"
52+
inefficient_to_string = "warn"
53+
infinite_loop = "warn"
54+
invalid_upcast_comparisons = "warn"
55+
large_digit_groups = "warn"
56+
large_stack_arrays = "warn"
57+
large_types_passed_by_value = "warn"
5858
let_and_return = "allow" # sometimes good to name what you are returning
59-
# linkedlist = "warn"
60-
# lossy_float_literal = "warn"
61-
# macro_use_imports = "warn"
62-
# mem_forget = "warn"
63-
# mutex_integer = "warn"
64-
# needless_continue = "warn"
65-
# needless_for_each = "warn"
66-
# negative_feature_names = "warn"
67-
# path_buf_push_overwrite = "warn"
68-
# ptr_as_ptr = "warn"
69-
# rc_mutex = "warn"
70-
# redundant_feature_names = "warn"
71-
# ref_option_ref = "warn"
72-
# rest_pat_in_fully_bound_structs = "warn"
73-
# same_functions_in_if_condition = "warn"
74-
# self_named_module_files = "warn"
75-
# semicolon_if_nothing_returned = "warn"
76-
# str_to_string = "warn"
77-
# string_add = "warn"
78-
# string_add_assign = "warn"
79-
# string_lit_as_bytes = "warn"
80-
# string_to_string = "warn"
81-
# todo = "warn"
82-
# trait_duplication_in_bounds = "warn"
83-
# uninlined_format_args = "warn"
84-
# verbose_file_reads = "warn"
85-
# wildcard_imports = "warn"
86-
# zero_sized_map_values = "warn"
59+
linkedlist = "warn"
60+
lossy_float_literal = "warn"
61+
macro_use_imports = "warn"
62+
mem_forget = "warn"
63+
mutex_integer = "warn"
64+
needless_continue = "warn"
65+
needless_for_each = "warn"
66+
negative_feature_names = "warn"
67+
path_buf_push_overwrite = "warn"
68+
ptr_as_ptr = "warn"
69+
rc_mutex = "warn"
70+
redundant_feature_names = "warn"
71+
ref_option_ref = "warn"
72+
rest_pat_in_fully_bound_structs = "warn"
73+
same_functions_in_if_condition = "warn"
74+
self_named_module_files = "warn"
75+
semicolon_if_nothing_returned = "warn"
76+
str_to_string = "warn"
77+
string_add = "warn"
78+
string_add_assign = "warn"
79+
string_lit_as_bytes = "warn"
80+
string_to_string = "warn"
81+
todo = "warn"
82+
trait_duplication_in_bounds = "warn"
83+
uninlined_format_args = "warn"
84+
verbose_file_reads = "warn"
85+
wildcard_imports = "warn"
86+
zero_sized_map_values = "warn"
8787

8888
[package]
8989
name = "config"

examples/custom_file_format/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323

2424
// Deserialize the config object into your Settings struct:
2525
let settings: Settings = settings.try_deserialize().unwrap();
26-
println!("{:#?}", settings);
26+
println!("{settings:#?}");
2727
}
2828

2929
#[derive(Debug, Clone)]
@@ -34,7 +34,7 @@ impl Format for PemFile {
3434
&self,
3535
uri: Option<&String>,
3636
text: &str,
37-
) -> Result<Map<String, config::Value>, Box<dyn std::error::Error + Send + Sync>> {
37+
) -> Result<Map<String, Value>, Box<dyn std::error::Error + Send + Sync>> {
3838
// Store any valid keys into this map, they'll be merged with other sources into the final config map:
3939
let mut result = Map::new();
4040

examples/custom_str_format/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fn main() {
77
.build();
88

99
match config {
10-
Ok(cfg) => println!("A config: {:#?}", cfg),
11-
Err(e) => println!("An error: {}", e),
10+
Ok(cfg) => println!("A config: {cfg:#?}"),
11+
Err(e) => println!("An error: {e}"),
1212
}
1313
}
1414

@@ -20,7 +20,7 @@ impl Format for MyFormat {
2020
&self,
2121
uri: Option<&String>,
2222
text: &str,
23-
) -> Result<Map<String, config::Value>, Box<dyn std::error::Error + Send + Sync>> {
23+
) -> Result<Map<String, Value>, Box<dyn std::error::Error + Send + Sync>> {
2424
// Let's assume our format is somewhat malformed, but this is fine
2525
// In real life anything can be used here - nom, serde or other.
2626
//
@@ -29,11 +29,11 @@ impl Format for MyFormat {
2929

3030
if text == "good" {
3131
result.insert(
32-
"key".to_string(),
32+
"key".to_owned(),
3333
Value::new(uri, ValueKind::String(text.into())),
3434
);
3535
} else {
36-
println!("Something went wrong in {:?}", uri);
36+
println!("Something went wrong in {uri:?}");
3737
}
3838

3939
Ok(result)

examples/hierarchical-env/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() {
66
let settings = Settings::new();
77

88
// Print out our settings
9-
println!("{:?}", settings);
9+
println!("{settings:?}");
1010
}

examples/hierarchical-env/settings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Braintree {
3434

3535
#[derive(Debug, Deserialize)]
3636
#[allow(unused)]
37-
pub struct Settings {
37+
pub(crate) struct Settings {
3838
debug: bool,
3939
database: Database,
4040
sparkpost: Sparkpost,
@@ -43,7 +43,7 @@ pub struct Settings {
4343
}
4444

4545
impl Settings {
46-
pub fn new() -> Result<Self, ConfigError> {
46+
pub(crate) fn new() -> Result<Self, ConfigError> {
4747
let run_mode = env::var("RUN_MODE").unwrap_or_else(|_| "development".into());
4848

4949
let s = Config::builder()
@@ -53,7 +53,7 @@ impl Settings {
5353
// Default to 'development' env
5454
// Note that this file is _optional_
5555
.add_source(
56-
File::with_name(&format!("examples/hierarchical-env/config/{}", run_mode))
56+
File::with_name(&format!("examples/hierarchical-env/config/{run_mode}"))
5757
.required(false),
5858
)
5959
// Add in a local configuration file

examples/watch/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn show() {
2828
);
2929
}
3030

31-
fn watch() {
31+
fn watch() -> ! {
3232
// Create a channel to receive the events.
3333
let (tx, rx) = channel();
3434

@@ -62,7 +62,7 @@ fn watch() {
6262
show();
6363
}
6464

65-
Err(e) => println!("watch error: {:?}", e),
65+
Err(e) => println!("watch error: {e:?}"),
6666

6767
_ => {
6868
// Ignore event

src/env.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ pub struct Environment {
3434

3535
/// Optional directive to translate collected keys into a form that matches what serializers
3636
/// that the configuration would expect. For example if you have the `kebab-case` attribute
37-
/// for your serde config types, you may want to pass Case::Kebab here.
37+
/// for your serde config types, you may want to pass `Case::Kebab` here.
3838
#[cfg(feature = "convert-case")]
39-
convert_case: Option<convert_case::Case>,
39+
convert_case: Option<Case>,
4040

41-
/// Optional character sequence that separates each env value into a vector. only works when try_parsing is set to true
42-
/// Once set, you cannot have type String on the same environment, unless you set list_parse_keys.
41+
/// Optional character sequence that separates each env value into a vector. only works when `try_parsing` is set to true
42+
/// Once set, you cannot have type String on the same environment, unless you set `list_parse_keys`.
4343
list_separator: Option<String>,
4444
/// A list of keys which should always be parsed as a list. If not set you can have only `Vec<String>` or `String` (not both) in one environment.
4545
list_parse_keys: Option<Vec<String>>,
@@ -110,7 +110,7 @@ impl Environment {
110110
}
111111
}
112112

113-
/// See [Environment::with_prefix]
113+
/// See [`Environment::with_prefix`]
114114
pub fn prefix(mut self, s: &str) -> Self {
115115
self.prefix = Some(s.into());
116116
self
@@ -141,7 +141,7 @@ impl Environment {
141141
self
142142
}
143143

144-
/// When set and try_parsing is true, then all environment variables will be parsed as [`Vec<String>`] instead of [`String`].
144+
/// When set and `try_parsing` is true, then all environment variables will be parsed as [`Vec<String>`] instead of [`String`].
145145
/// See
146146
/// [`with_list_parse_key`](Self::with_list_parse_key)
147147
/// when you want to use [`Vec<String>`] in combination with [`String`].
@@ -151,11 +151,11 @@ impl Environment {
151151
}
152152

153153
/// Add a key which should be parsed as a list when collecting [`Value`]s from the environment.
154-
/// Once list_separator is set, the type for string is [`Vec<String>`].
154+
/// Once `list_separator` is set, the type for string is [`Vec<String>`].
155155
/// To switch the default type back to type Strings you need to provide the keys which should be [`Vec<String>`] using this function.
156156
pub fn with_list_parse_key(mut self, key: &str) -> Self {
157157
if self.list_parse_keys.is_none() {
158-
self.list_parse_keys = Some(vec![key.to_lowercase()])
158+
self.list_parse_keys = Some(vec![key.to_lowercase()]);
159159
} else {
160160
self.list_parse_keys = self.list_parse_keys.map(|mut keys| {
161161
keys.push(key.to_lowercase());
@@ -246,7 +246,7 @@ impl Source for Environment {
246246
let prefix_pattern = self
247247
.prefix
248248
.as_ref()
249-
.map(|prefix| format!("{}{}", prefix, prefix_separator).to_lowercase());
249+
.map(|prefix| format!("{prefix}{prefix_separator}").to_lowercase());
250250

251251
let collector = |(key, value): (String, String)| {
252252
// Treat empty environment variables as unset
@@ -295,7 +295,7 @@ impl Source for Environment {
295295
if keys.contains(&key) {
296296
let v: Vec<Value> = value
297297
.split(separator)
298-
.map(|s| Value::new(Some(&uri), ValueKind::String(s.to_string())))
298+
.map(|s| Value::new(Some(&uri), ValueKind::String(s.to_owned())))
299299
.collect();
300300
ValueKind::Array(v)
301301
} else {
@@ -304,7 +304,7 @@ impl Source for Environment {
304304
} else {
305305
let v: Vec<Value> = value
306306
.split(separator)
307-
.map(|s| Value::new(Some(&uri), ValueKind::String(s.to_string())))
307+
.map(|s| Value::new(Some(&uri), ValueKind::String(s.to_owned())))
308308
.collect();
309309
ValueKind::Array(v)
310310
}

src/error.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ pub enum Unexpected {
2222
impl fmt::Display for Unexpected {
2323
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
2424
match *self {
25-
Unexpected::Bool(b) => write!(f, "boolean `{}`", b),
26-
Unexpected::I64(i) => write!(f, "64-bit integer `{}`", i),
27-
Unexpected::I128(i) => write!(f, "128-bit integer `{}`", i),
28-
Unexpected::U64(i) => write!(f, "64-bit unsigned integer `{}`", i),
29-
Unexpected::U128(i) => write!(f, "128-bit unsigned integer `{}`", i),
30-
Unexpected::Float(v) => write!(f, "floating point `{}`", v),
31-
Unexpected::Str(ref s) => write!(f, "string {:?}", s),
25+
Unexpected::Bool(b) => write!(f, "boolean `{b}`"),
26+
Unexpected::I64(i) => write!(f, "64-bit integer `{i}`"),
27+
Unexpected::I128(i) => write!(f, "128-bit integer `{i}`"),
28+
Unexpected::U64(i) => write!(f, "64-bit unsigned integer `{i}`"),
29+
Unexpected::U128(i) => write!(f, "128-bit unsigned integer `{i}`"),
30+
Unexpected::Float(v) => write!(f, "floating point `{v}`"),
31+
Unexpected::Str(ref s) => write!(f, "string {s:?}"),
3232
Unexpected::Unit => write!(f, "unit value"),
3333
Unexpected::Seq => write!(f, "sequence"),
3434
Unexpected::Map => write!(f, "map"),
@@ -142,7 +142,7 @@ impl ConfigError {
142142
} else {
143143
""
144144
};
145-
format!("{}{}{}", segment, dot, key)
145+
format!("{segment}{dot}{key}")
146146
};
147147
match self {
148148
Self::Type {
@@ -168,12 +168,12 @@ impl ConfigError {
168168

169169
#[must_use]
170170
pub(crate) fn prepend_index(self, idx: usize) -> Self {
171-
self.prepend(&format!("[{}]", idx), false)
171+
self.prepend(&format!("[{idx}]"), false)
172172
}
173173
}
174174

175175
/// Alias for a `Result` with the error type set to `ConfigError`.
176-
pub type Result<T> = result::Result<T, ConfigError>;
176+
pub(crate) type Result<T> = result::Result<T, ConfigError>;
177177

178178
// Forward Debug to Display for readable panic! messages
179179
impl fmt::Debug for ConfigError {
@@ -189,12 +189,12 @@ impl fmt::Display for ConfigError {
189189

190190
ConfigError::PathParse(ref kind) => write!(f, "{}", kind.description()),
191191

192-
ConfigError::Message(ref s) => write!(f, "{}", s),
192+
ConfigError::Message(ref s) => write!(f, "{s}"),
193193

194-
ConfigError::Foreign(ref cause) => write!(f, "{}", cause),
194+
ConfigError::Foreign(ref cause) => write!(f, "{cause}"),
195195

196196
ConfigError::NotFound(ref key) => {
197-
write!(f, "configuration property {:?} not found", key)
197+
write!(f, "configuration property {key:?} not found")
198198
}
199199

200200
ConfigError::Type {
@@ -203,24 +203,24 @@ impl fmt::Display for ConfigError {
203203
expected,
204204
ref key,
205205
} => {
206-
write!(f, "invalid type: {}, expected {}", unexpected, expected)?;
206+
write!(f, "invalid type: {unexpected}, expected {expected}")?;
207207

208208
if let Some(ref key) = *key {
209-
write!(f, " for key `{}`", key)?;
209+
write!(f, " for key `{key}`")?;
210210
}
211211

212212
if let Some(ref origin) = *origin {
213-
write!(f, " in {}", origin)?;
213+
write!(f, " in {origin}")?;
214214
}
215215

216216
Ok(())
217217
}
218218

219219
ConfigError::FileParse { ref cause, ref uri } => {
220-
write!(f, "{}", cause)?;
220+
write!(f, "{cause}")?;
221221

222222
if let Some(ref uri) = *uri {
223-
write!(f, " in {}", uri)?;
223+
write!(f, " in {uri}")?;
224224
}
225225

226226
Ok(())

0 commit comments

Comments
 (0)