@@ -68,13 +68,15 @@ pub enum DisallowedType {
68
68
pub struct TryConf {
69
69
pub conf : Conf ,
70
70
pub errors : Vec < Box < dyn Error > > ,
71
+ pub warnings : Vec < Box < dyn Error > > ,
71
72
}
72
73
73
74
impl TryConf {
74
75
fn from_error ( error : impl Error + ' static ) -> Self {
75
76
Self {
76
77
conf : Conf :: default ( ) ,
77
78
errors : vec ! [ Box :: new( error) ] ,
79
+ warnings : vec ! [ ] ,
78
80
}
79
81
}
80
82
}
@@ -97,7 +99,7 @@ fn conf_error(s: String) -> Box<dyn Error> {
97
99
macro_rules! define_Conf {
98
100
( $(
99
101
$( #[ doc = $doc: literal] ) +
100
- $( #[ conf_deprecated( $dep: literal) ] ) ?
102
+ $( #[ conf_deprecated( $dep: literal, $new_conf : ident ) ] ) ?
101
103
( $name: ident: $ty: ty = $default: expr) ,
102
104
) * ) => {
103
105
/// Clippy lint configuration
@@ -137,17 +139,23 @@ macro_rules! define_Conf {
137
139
138
140
fn visit_map<V >( self , mut map: V ) -> Result <Self :: Value , V :: Error > where V : MapAccess <' de> {
139
141
let mut errors = Vec :: new( ) ;
142
+ let mut warnings = Vec :: new( ) ;
140
143
$( let mut $name = None ; ) *
141
144
// could get `Field` here directly, but get `str` first for diagnostics
142
145
while let Some ( name) = map. next_key:: <& str >( ) ? {
143
146
match Field :: deserialize( name. into_deserializer( ) ) ? {
144
147
$( Field :: $name => {
145
- $( errors . push( conf_error( format!( "deprecated field `{}`. {}" , name, $dep) ) ) ; ) ?
148
+ $( warnings . push( conf_error( format!( "deprecated field `{}`. {}" , name, $dep) ) ) ; ) ?
146
149
match map. next_value( ) {
147
150
Err ( e) => errors. push( conf_error( e. to_string( ) ) ) ,
148
151
Ok ( value) => match $name {
149
152
Some ( _) => errors. push( conf_error( format!( "duplicate field `{}`" , name) ) ) ,
150
- None => $name = Some ( value) ,
153
+ None => {
154
+ $name = Some ( value) ;
155
+ // $new_conf is the same as one of the defined `$name`s, so
156
+ // this variable is defined in line 2 of this function.
157
+ $( $new_conf = Some ( value) ; ) ?
158
+ } ,
151
159
}
152
160
}
153
161
} ) *
@@ -156,7 +164,7 @@ macro_rules! define_Conf {
156
164
}
157
165
}
158
166
let conf = Conf { $( $name: $name. unwrap_or_else( defaults:: $name) , ) * } ;
159
- Ok ( TryConf { conf, errors } )
167
+ Ok ( TryConf { conf, errors, warnings } )
160
168
}
161
169
}
162
170
@@ -216,8 +224,8 @@ define_Conf! {
216
224
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
217
225
///
218
226
/// Use the Cognitive Complexity lint instead.
219
- #[ conf_deprecated( "Please use `cognitive-complexity-threshold` instead" ) ]
220
- ( cyclomatic_complexity_threshold: Option < u64 > = None ) ,
227
+ #[ conf_deprecated( "Please use `cognitive-complexity-threshold` instead" , cognitive_complexity_threshold ) ]
228
+ ( cyclomatic_complexity_threshold: u64 = 25 ) ,
221
229
/// Lint: DOC_MARKDOWN.
222
230
///
223
231
/// The list of words this lint should not consider as identifiers needing ticks. The value
0 commit comments