@@ -90,7 +90,7 @@ fn parse_cfg_entry_version<S: Stage>(
9090 list : & MetaItemListParser < ' _ > ,
9191 meta_span : Span ,
9292) -> Option < CfgEntry > {
93- try_gate_cfg ( sym:: version, meta_span, cx. sess ( ) , Some ( cx. features ( ) ) ) ;
93+ try_gate_cfg ( sym:: version, meta_span, cx. sess ( ) , cx. features_option ( ) ) ;
9494 let Some ( version) = list. single ( ) else {
9595 cx. emit_err ( session_diagnostics:: ExpectedSingleVersionLiteral { span : list. span } ) ;
9696 return None ;
@@ -119,7 +119,9 @@ fn parse_cfg_entry_target<S: Stage>(
119119 list : & MetaItemListParser < ' _ > ,
120120 meta_span : Span ,
121121) -> Option < CfgEntry > {
122- if !cx. features ( ) . cfg_target_compact ( ) {
122+ if let Some ( features) = cx. features_option ( )
123+ && !features. cfg_target_compact ( )
124+ {
123125 feature_err (
124126 cx. sess ( ) ,
125127 sym:: cfg_target_compact,
@@ -186,12 +188,13 @@ pub fn eval_config_entry(
186188 cfg_entry : & CfgEntry ,
187189 id : NodeId ,
188190 features : Option < & Features > ,
191+ emit_lints : bool ,
189192) -> EvalConfigResult {
190193 match cfg_entry {
191194 CfgEntry :: All ( subs, ..) => {
192195 let mut all = None ;
193196 for sub in subs {
194- let res = eval_config_entry ( sess, sub, id, features) ;
197+ let res = eval_config_entry ( sess, sub, id, features, emit_lints ) ;
195198 // We cannot short-circuit because `eval_config_entry` emits some lints
196199 if !res. as_bool ( ) {
197200 all. get_or_insert ( res) ;
@@ -202,7 +205,7 @@ pub fn eval_config_entry(
202205 CfgEntry :: Any ( subs, span) => {
203206 let mut any = None ;
204207 for sub in subs {
205- let res = eval_config_entry ( sess, sub, id, features) ;
208+ let res = eval_config_entry ( sess, sub, id, features, emit_lints ) ;
206209 // We cannot short-circuit because `eval_config_entry` emits some lints
207210 if res. as_bool ( ) {
208211 any. get_or_insert ( res) ;
@@ -214,7 +217,7 @@ pub fn eval_config_entry(
214217 } )
215218 }
216219 CfgEntry :: Not ( sub, span) => {
217- if eval_config_entry ( sess, sub, id, features) . as_bool ( ) {
220+ if eval_config_entry ( sess, sub, id, features, emit_lints ) . as_bool ( ) {
218221 EvalConfigResult :: False { reason : cfg_entry. clone ( ) , reason_span : * span }
219222 } else {
220223 EvalConfigResult :: True
@@ -228,24 +231,28 @@ pub fn eval_config_entry(
228231 }
229232 }
230233 CfgEntry :: NameValue { name, name_span, value, span } => {
231- match sess. psess . check_config . expecteds . get ( name) {
232- Some ( ExpectedValues :: Some ( values) ) if !values. contains ( & value. map ( |( v, _) | v) ) => {
233- id. emit_span_lint (
234- sess,
235- UNEXPECTED_CFGS ,
236- * span,
237- BuiltinLintDiag :: UnexpectedCfgValue ( ( * name, * name_span) , * value) ,
238- ) ;
234+ if emit_lints {
235+ match sess. psess . check_config . expecteds . get ( name) {
236+ Some ( ExpectedValues :: Some ( values) )
237+ if !values. contains ( & value. map ( |( v, _) | v) ) =>
238+ {
239+ id. emit_span_lint (
240+ sess,
241+ UNEXPECTED_CFGS ,
242+ * span,
243+ BuiltinLintDiag :: UnexpectedCfgValue ( ( * name, * name_span) , * value) ,
244+ ) ;
245+ }
246+ None if sess. psess . check_config . exhaustive_names => {
247+ id. emit_span_lint (
248+ sess,
249+ UNEXPECTED_CFGS ,
250+ * span,
251+ BuiltinLintDiag :: UnexpectedCfgName ( ( * name, * name_span) , * value) ,
252+ ) ;
253+ }
254+ _ => { /* not unexpected */ }
239255 }
240- None if sess. psess . check_config . exhaustive_names => {
241- id. emit_span_lint (
242- sess,
243- UNEXPECTED_CFGS ,
244- * span,
245- BuiltinLintDiag :: UnexpectedCfgName ( ( * name, * name_span) , * value) ,
246- ) ;
247- }
248- _ => { /* not unexpected */ }
249256 }
250257
251258 if sess. psess . config . contains ( & ( * name, value. map ( |( v, _) | v) ) ) {
0 commit comments