@@ -68,13 +68,15 @@ pub enum DisallowedType {
6868pub struct TryConf {
6969 pub conf : Conf ,
7070 pub errors : Vec < Box < dyn Error > > ,
71+ pub warnings : Vec < Box < dyn Error > > ,
7172}
7273
7374impl TryConf {
7475 fn from_error ( error : impl Error + ' static ) -> Self {
7576 Self {
7677 conf : Conf :: default ( ) ,
7778 errors : vec ! [ Box :: new( error) ] ,
79+ warnings : vec ! [ ] ,
7880 }
7981 }
8082}
@@ -97,7 +99,7 @@ fn conf_error(s: String) -> Box<dyn Error> {
9799macro_rules! define_Conf {
98100 ( $(
99101 $( #[ doc = $doc: literal] ) +
100- $( #[ conf_deprecated( $dep: literal) ] ) ?
102+ $( #[ conf_deprecated( $dep: literal, $new_conf : ident ) ] ) ?
101103 ( $name: ident: $ty: ty = $default: expr) ,
102104 ) * ) => {
103105 /// Clippy lint configuration
@@ -137,17 +139,23 @@ macro_rules! define_Conf {
137139
138140 fn visit_map<V >( self , mut map: V ) -> Result <Self :: Value , V :: Error > where V : MapAccess <' de> {
139141 let mut errors = Vec :: new( ) ;
142+ let mut warnings = Vec :: new( ) ;
140143 $( let mut $name = None ; ) *
141144 // could get `Field` here directly, but get `str` first for diagnostics
142145 while let Some ( name) = map. next_key:: <& str >( ) ? {
143146 match Field :: deserialize( name. into_deserializer( ) ) ? {
144147 $( Field :: $name => {
145- $( errors . push( conf_error( format!( "deprecated field `{}`. {}" , name, $dep) ) ) ; ) ?
148+ $( warnings . push( conf_error( format!( "deprecated field `{}`. {}" , name, $dep) ) ) ; ) ?
146149 match map. next_value( ) {
147150 Err ( e) => errors. push( conf_error( e. to_string( ) ) ) ,
148151 Ok ( value) => match $name {
149152 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+ } ,
151159 }
152160 }
153161 } ) *
@@ -156,7 +164,7 @@ macro_rules! define_Conf {
156164 }
157165 }
158166 let conf = Conf { $( $name: $name. unwrap_or_else( defaults:: $name) , ) * } ;
159- Ok ( TryConf { conf, errors } )
167+ Ok ( TryConf { conf, errors, warnings } )
160168 }
161169 }
162170
@@ -216,8 +224,8 @@ define_Conf! {
216224 /// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
217225 ///
218226 /// 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 ) ,
221229 /// Lint: DOC_MARKDOWN.
222230 ///
223231 /// The list of words this lint should not consider as identifiers needing ticks. The value
0 commit comments