Skip to content

Commit d228e99

Browse files
committed
ensure clippy runs on all targets
1 parent 66a7fa9 commit d228e99

23 files changed

+43
-30
lines changed

.github/workflows/msrv.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
uses: actions-rs/cargo@v1
137137
with:
138138
command: clippy
139-
args: -- -D warnings
139+
args: --all-targets --all-features -- -D warnings
140140

141141
check-examples:
142142
name: Check examples

src/builder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ use crate::{config::Config, path::Expression, source::Source, value::Value};
8787
/// let mut builder = ConfigBuilder::<DefaultState>::default();
8888
/// ```
8989
#[derive(Debug, Clone, Default)]
90+
#[must_use]
9091
pub struct ConfigBuilder<St: BuilderState> {
9192
defaults: Map<Expression, Value>,
9293
overrides: Map<Expression, Value>,
@@ -270,7 +271,7 @@ impl ConfigBuilder<AsyncState> {
270271
/// Registers new [`Source`] in this builder.
271272
///
272273
/// Calling this method does not invoke any I/O. [`Source`] is only saved in internal register for later use.
273-
pub fn add_source<T>(mut self, source: T) -> ConfigBuilder<AsyncState>
274+
pub fn add_source<T>(mut self, source: T) -> Self
274275
where
275276
T: Source + Send + Sync + 'static,
276277
{
@@ -281,7 +282,7 @@ impl ConfigBuilder<AsyncState> {
281282
/// Registers new [`AsyncSource`] in this builder.
282283
///
283284
/// Calling this method does not invoke any I/O. [`AsyncSource`] is only saved in internal register for later use.
284-
pub fn add_async_source<T>(mut self, source: T) -> ConfigBuilder<AsyncState>
285+
pub fn add_async_source<T>(mut self, source: T) -> Self
285286
where
286287
T: AsyncSource + Send + Sync + 'static,
287288
{

src/env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::source::Source;
66
use crate::value::{Value, ValueKind};
77

88
#[derive(Clone, Debug, Default)]
9+
#[must_use]
910
pub struct Environment {
1011
/// Optional prefix that will limit access to the environment to only keys that
1112
/// begin with the defined prefix.

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl ConfigError {
114114

115115
// FIXME: pub(crate)
116116
#[doc(hidden)]
117+
#[must_use]
117118
pub fn extend_with_key(self, key: &str) -> Self {
118119
match self {
119120
ConfigError::Type {

src/file/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub use self::source::string::FileSourceString;
2020
///
2121
/// It supports optional automatic file format discovery.
2222
#[derive(Clone, Debug)]
23+
#[must_use]
2324
pub struct File<T, F> {
2425
source: T,
2526

src/file/source/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl FileSourceFile {
7373
}
7474

7575
None => {
76-
for (format, extensions) in ALL_EXTENSIONS.iter() {
76+
for format in ALL_EXTENSIONS.keys() {
7777
for ext in format.extensions() {
7878
filename.set_extension(ext);
7979

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
//!
1818
//! See the [examples](https://github.com/mehcode/config-rs/tree/master/examples) for
1919
//! general usage information.
20-
#![allow(unused_variables)]
2120
#![allow(unknown_lints)]
2221
// #![warn(missing_docs)]
2322

src/ser.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a> ser::Serializer for &'a mut ConfigSerializer {
231231

232232
fn serialize_tuple_variant(
233233
self,
234-
name: &'static str,
234+
_name: &'static str,
235235
_variant_index: u32,
236236
variant: &'static str,
237237
_len: usize,
@@ -253,7 +253,7 @@ impl<'a> ser::Serializer for &'a mut ConfigSerializer {
253253
_name: &'static str,
254254
_variant_index: u32,
255255
variant: &'static str,
256-
len: usize,
256+
_len: usize,
257257
) -> Result<Self::SerializeStructVariant> {
258258
self.push_key(variant);
259259
Ok(self)
@@ -580,7 +580,7 @@ impl ser::SerializeSeq for StringKeySerializer {
580580
type Ok = String;
581581
type Error = ConfigError;
582582

583-
fn serialize_element<T>(&mut self, value: &T) -> Result<()>
583+
fn serialize_element<T>(&mut self, _value: &T) -> Result<()>
584584
where
585585
T: ?Sized + ser::Serialize,
586586
{
@@ -596,7 +596,7 @@ impl ser::SerializeTuple for StringKeySerializer {
596596
type Ok = String;
597597
type Error = ConfigError;
598598

599-
fn serialize_element<T>(&mut self, value: &T) -> Result<()>
599+
fn serialize_element<T>(&mut self, _value: &T) -> Result<()>
600600
where
601601
T: ?Sized + ser::Serialize,
602602
{
@@ -612,7 +612,7 @@ impl ser::SerializeTupleStruct for StringKeySerializer {
612612
type Ok = String;
613613
type Error = ConfigError;
614614

615-
fn serialize_field<T>(&mut self, value: &T) -> Result<()>
615+
fn serialize_field<T>(&mut self, _value: &T) -> Result<()>
616616
where
617617
T: ?Sized + ser::Serialize,
618618
{
@@ -628,7 +628,7 @@ impl ser::SerializeTupleVariant for StringKeySerializer {
628628
type Ok = String;
629629
type Error = ConfigError;
630630

631-
fn serialize_field<T>(&mut self, value: &T) -> Result<()>
631+
fn serialize_field<T>(&mut self, _value: &T) -> Result<()>
632632
where
633633
T: ?Sized + ser::Serialize,
634634
{
@@ -644,14 +644,14 @@ impl ser::SerializeMap for StringKeySerializer {
644644
type Ok = String;
645645
type Error = ConfigError;
646646

647-
fn serialize_key<T>(&mut self, key: &T) -> Result<()>
647+
fn serialize_key<T>(&mut self, _key: &T) -> Result<()>
648648
where
649649
T: ?Sized + ser::Serialize,
650650
{
651651
unreachable!()
652652
}
653653

654-
fn serialize_value<T>(&mut self, value: &T) -> Result<()>
654+
fn serialize_value<T>(&mut self, _value: &T) -> Result<()>
655655
where
656656
T: ?Sized + ser::Serialize,
657657
{
@@ -667,7 +667,7 @@ impl ser::SerializeStruct for StringKeySerializer {
667667
type Ok = String;
668668
type Error = ConfigError;
669669

670-
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
670+
fn serialize_field<T>(&mut self, _key: &'static str, _value: &T) -> Result<()>
671671
where
672672
T: ?Sized + ser::Serialize,
673673
{
@@ -683,7 +683,7 @@ impl ser::SerializeStructVariant for StringKeySerializer {
683683
type Ok = String;
684684
type Error = ConfigError;
685685

686-
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
686+
fn serialize_field<T>(&mut self, _key: &'static str, _value: &T) -> Result<()>
687687
where
688688
T: ?Sized + ser::Serialize,
689689
{

tests/async_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async fn test_single_async_file_source() {
4646
.await
4747
.unwrap();
4848

49-
assert_eq!(true, config.get::<bool>("debug").unwrap());
49+
assert!(config.get::<bool>("debug").unwrap());
5050
}
5151

5252
#[tokio::test]
@@ -65,7 +65,7 @@ async fn test_two_async_file_sources() {
6565
.unwrap();
6666

6767
assert_eq!("Torre di Pisa", config.get::<String>("place.name").unwrap());
68-
assert_eq!(true, config.get::<bool>("debug_json").unwrap());
68+
assert!(config.get::<bool>("debug_json").unwrap());
6969
assert_eq!(1, config.get::<i32>("place.number").unwrap());
7070
}
7171

tests/env.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ fn test_parse_off_int() {
202202

203203
#[derive(Deserialize, Debug)]
204204
struct TestInt {
205+
#[allow(dead_code)]
205206
int_val_1: i32,
206207
}
207208

@@ -233,6 +234,7 @@ fn test_parse_off_float() {
233234

234235
#[derive(Deserialize, Debug)]
235236
struct TestFloat {
237+
#[allow(dead_code)]
236238
float_val_1: f64,
237239
}
238240

@@ -264,6 +266,7 @@ fn test_parse_off_bool() {
264266

265267
#[derive(Deserialize, Debug)]
266268
struct TestBool {
269+
#[allow(dead_code)]
267270
bool_val_1: bool,
268271
}
269272

@@ -295,6 +298,7 @@ fn test_parse_int_fail() {
295298

296299
#[derive(Deserialize, Debug)]
297300
struct TestInt {
301+
#[allow(dead_code)]
298302
int_val_2: i32,
299303
}
300304

@@ -326,6 +330,7 @@ fn test_parse_float_fail() {
326330

327331
#[derive(Deserialize, Debug)]
328332
struct TestFloat {
333+
#[allow(dead_code)]
329334
float_val_2: f64,
330335
}
331336

@@ -357,6 +362,7 @@ fn test_parse_bool_fail() {
357362

358363
#[derive(Deserialize, Debug)]
359364
struct TestBool {
365+
#[allow(dead_code)]
360366
bool_val_2: bool,
361367
}
362368

tests/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ fn test_error_enum_de() {
109109
fn error_with_path() {
110110
#[derive(Debug, Deserialize)]
111111
struct Inner {
112+
#[allow(dead_code)]
112113
test: i32,
113114
}
114115

115116
#[derive(Debug, Deserialize)]
116117
struct Outer {
118+
#[allow(dead_code)]
117119
inner: Inner,
118120
}
119121
const CFG: &str = r#"

tests/file_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn test_file() {
5252
assert_eq!(s.place.name, "Torre di Pisa");
5353
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5454
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
55-
assert_eq!(s.place.favorite, false);
55+
assert!(!s.place.favorite);
5656
assert_eq!(s.place.reviews, 3866);
5757
assert_eq!(s.place.rating, Some(4.5));
5858
assert_eq!(s.place.telephone, None);

tests/file_json5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test_file() {
5151
assert_eq!(s.place.name, "Torre di Pisa");
5252
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5353
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
54-
assert_eq!(s.place.favorite, false);
54+
assert!(!s.place.favorite);
5555
assert_eq!(s.place.reviews, 3866);
5656
assert_eq!(s.place.rating, Some(4.5));
5757
assert_eq!(s.place.telephone, None);

tests/file_ron.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn test_file() {
5454
assert_eq!(s.place.name, "Torre di Pisa");
5555
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5656
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
57-
assert_eq!(s.place.favorite, false);
57+
assert!(!s.place.favorite);
5858
assert_eq!(s.place.reviews, 3866);
5959
assert_eq!(s.place.rating, Some(4.5));
6060
assert_eq!(s.place.telephone, None);

tests/file_toml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn test_file() {
6363
assert_eq!(s.place.name, "Torre di Pisa");
6464
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
6565
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
66-
assert_eq!(s.place.favorite, false);
66+
assert!(!s.place.favorite);
6767
assert_eq!(s.place.reviews, 3866);
6868
assert_eq!(s.place.rating, Some(4.5));
6969
assert_eq!(s.place.telephone, None);

tests/file_yaml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn test_file() {
5252
assert_eq!(s.place.name, "Torre di Pisa");
5353
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5454
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
55-
assert_eq!(s.place.favorite, false);
55+
assert!(!s.place.favorite);
5656
assert_eq!(s.place.reviews, 3866);
5757
assert_eq!(s.place.rating, Some(4.5));
5858
assert_eq!(s.place.telephone, None);

tests/get.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn test_file_struct() {
167167
assert_eq!(s.place.name, "Torre di Pisa");
168168
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
169169
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
170-
assert_eq!(s.place.favorite, false);
170+
assert!(!s.place.favorite);
171171
assert_eq!(s.place.reviews, 3866);
172172
assert_eq!(s.place.rating, Some(4.5));
173173
assert_eq!(s.place.telephone, None);
@@ -184,7 +184,7 @@ fn test_scalar_struct() {
184184
assert_eq!(p.name, "Torre di Pisa");
185185
assert!(p.longitude.approx_eq_ulps(&43.7224985, 2));
186186
assert!(p.latitude.approx_eq_ulps(&10.3970522, 2));
187-
assert_eq!(p.favorite, false);
187+
assert!(!p.favorite);
188188
assert_eq!(p.reviews, 3866);
189189
assert_eq!(p.rating, Some(4.5));
190190
assert_eq!(p.telephone, None);

tests/legacy/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ fn test_error_enum_de() {
106106
fn error_with_path() {
107107
#[derive(Debug, Deserialize)]
108108
struct Inner {
109+
#[allow(dead_code)]
109110
test: i32,
110111
}
111112

112113
#[derive(Debug, Deserialize)]
113114
struct Outer {
115+
#[allow(dead_code)]
114116
inner: Inner,
115117
}
116118
const CFG: &str = r#"

tests/legacy/file_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn test_file() {
5050
assert_eq!(s.place.name, "Torre di Pisa");
5151
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5252
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
53-
assert_eq!(s.place.favorite, false);
53+
assert!(!s.place.favorite);
5454
assert_eq!(s.place.reviews, 3866);
5555
assert_eq!(s.place.rating, Some(4.5));
5656
assert_eq!(s.place.telephone, None);

tests/legacy/file_ron.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn test_file() {
5252
assert_eq!(s.place.name, "Torre di Pisa");
5353
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5454
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
55-
assert_eq!(s.place.favorite, false);
55+
assert!(!s.place.favorite);
5656
assert_eq!(s.place.reviews, 3866);
5757
assert_eq!(s.place.rating, Some(4.5));
5858
assert_eq!(s.place.telephone, None);

tests/legacy/file_toml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn test_file() {
6161
assert_eq!(s.place.name, "Torre di Pisa");
6262
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
6363
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
64-
assert_eq!(s.place.favorite, false);
64+
assert!(!s.place.favorite);
6565
assert_eq!(s.place.reviews, 3866);
6666
assert_eq!(s.place.rating, Some(4.5));
6767
assert_eq!(s.place.telephone, None);

tests/legacy/file_yaml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn test_file() {
5050
assert_eq!(s.place.name, "Torre di Pisa");
5151
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
5252
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
53-
assert_eq!(s.place.favorite, false);
53+
assert!(!s.place.favorite);
5454
assert_eq!(s.place.reviews, 3866);
5555
assert_eq!(s.place.rating, Some(4.5));
5656
assert_eq!(s.place.telephone, None);

tests/legacy/get.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn test_file_struct() {
165165
assert_eq!(s.place.name, "Torre di Pisa");
166166
assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
167167
assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
168-
assert_eq!(s.place.favorite, false);
168+
assert!(!s.place.favorite);
169169
assert_eq!(s.place.reviews, 3866);
170170
assert_eq!(s.place.rating, Some(4.5));
171171
assert_eq!(s.place.telephone, None);
@@ -182,7 +182,7 @@ fn test_scalar_struct() {
182182
assert_eq!(p.name, "Torre di Pisa");
183183
assert!(p.longitude.approx_eq_ulps(&43.7224985, 2));
184184
assert!(p.latitude.approx_eq_ulps(&10.3970522, 2));
185-
assert_eq!(p.favorite, false);
185+
assert!(!p.favorite);
186186
assert_eq!(p.reviews, 3866);
187187
assert_eq!(p.rating, Some(4.5));
188188
assert_eq!(p.telephone, None);

0 commit comments

Comments
 (0)