File tree 5 files changed +24
-4
lines changed
5 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ impl fmt::Display for ConfError {
92
92
93
93
impl Error for ConfError { }
94
94
95
- fn conf_error ( s : String ) -> Box < dyn Error > {
96
- Box :: new ( ConfError ( s) )
95
+ fn conf_error ( s : impl Into < String > ) -> Box < dyn Error > {
96
+ Box :: new ( ConfError ( s. into ( ) ) )
97
97
}
98
98
99
99
macro_rules! define_Conf {
@@ -154,7 +154,13 @@ macro_rules! define_Conf {
154
154
$name = Some ( value) ;
155
155
// $new_conf is the same as one of the defined `$name`s, so
156
156
// this variable is defined in line 2 of this function.
157
- $( $new_conf = Some ( value) ; ) ?
157
+ $( match $new_conf {
158
+ Some ( _) => errors. push( conf_error( concat!(
159
+ "duplicate field `" , stringify!( $new_conf) ,
160
+ "` (provided as `" , stringify!( $name) , "`)"
161
+ ) ) ) ,
162
+ None => $new_conf = Some ( value) ,
163
+ } ) ?
158
164
} ,
159
165
}
160
166
}
Original file line number Diff line number Diff line change 1
- # that one is an error
1
+ # that one is a warning
2
2
cyclomatic-complexity-threshold = 2
3
3
4
4
# that one is white-listed
Original file line number Diff line number Diff line change
1
+ cognitive-complexity-threshold = 2
2
+ # This is the deprecated name for the same key
3
+ cyclomatic-complexity-threshold = 3
4
+ # Check we get duplication warning regardless of order
5
+ cognitive-complexity-threshold = 4
Original file line number Diff line number Diff line change
1
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: error reading Clippy's configuration file `$DIR/clippy.toml`: duplicate field `cognitive_complexity_threshold` (provided as `cyclomatic_complexity_threshold`)
2
+
3
+ error: error reading Clippy's configuration file `$DIR/clippy.toml`: duplicate field `cognitive-complexity-threshold`
4
+
5
+ warning: error reading Clippy's configuration file `$DIR/clippy.toml`: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead
6
+
7
+ error: aborting due to 2 previous errors; 1 warning emitted
8
+
You can’t perform that action at this time.
0 commit comments