@@ -90,7 +90,7 @@ fn parse_cfg_entry_version<S: Stage>(
90
90
list : & MetaItemListParser < ' _ > ,
91
91
meta_span : Span ,
92
92
) -> 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 ( ) ) ;
94
94
let Some ( version) = list. single ( ) else {
95
95
cx. emit_err ( session_diagnostics:: ExpectedSingleVersionLiteral { span : list. span } ) ;
96
96
return None ;
@@ -119,7 +119,9 @@ fn parse_cfg_entry_target<S: Stage>(
119
119
list : & MetaItemListParser < ' _ > ,
120
120
meta_span : Span ,
121
121
) -> Option < CfgEntry > {
122
- if !cx. features ( ) . cfg_target_compact ( ) {
122
+ if let Some ( features) = cx. features_option ( )
123
+ && !features. cfg_target_compact ( )
124
+ {
123
125
feature_err (
124
126
cx. sess ( ) ,
125
127
sym:: cfg_target_compact,
@@ -186,12 +188,13 @@ pub fn eval_config_entry(
186
188
cfg_entry : & CfgEntry ,
187
189
id : NodeId ,
188
190
features : Option < & Features > ,
191
+ emit_lints : bool ,
189
192
) -> EvalConfigResult {
190
193
match cfg_entry {
191
194
CfgEntry :: All ( subs, ..) => {
192
195
let mut all = None ;
193
196
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 ) ;
195
198
// We cannot short-circuit because `eval_config_entry` emits some lints
196
199
if !res. as_bool ( ) {
197
200
all. get_or_insert ( res) ;
@@ -202,7 +205,7 @@ pub fn eval_config_entry(
202
205
CfgEntry :: Any ( subs, span) => {
203
206
let mut any = None ;
204
207
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 ) ;
206
209
// We cannot short-circuit because `eval_config_entry` emits some lints
207
210
if res. as_bool ( ) {
208
211
any. get_or_insert ( res) ;
@@ -214,7 +217,7 @@ pub fn eval_config_entry(
214
217
} )
215
218
}
216
219
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 ( ) {
218
221
EvalConfigResult :: False { reason : cfg_entry. clone ( ) , reason_span : * span }
219
222
} else {
220
223
EvalConfigResult :: True
@@ -228,24 +231,28 @@ pub fn eval_config_entry(
228
231
}
229
232
}
230
233
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 */ }
239
255
}
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 */ }
249
256
}
250
257
251
258
if sess. psess . config . contains ( & ( * name, value. map ( |( v, _) | v) ) ) {
0 commit comments