@@ -261,10 +261,16 @@ pub(super) fn unexpected_cfg_value(
261
261
lints:: unexpected_cfg_value:: CodeSuggestion :: RemoveCondition { suggestion, name }
262
262
} ;
263
263
264
- // We don't want to suggest adding values to well known names
265
- // since those are defined by rustc it-self. Users can still
266
- // do it if they want, but should not encourage them.
267
- let is_cfg_a_well_know_name = sess. psess . check_config . well_known_names . contains ( & name) ;
264
+ // We don't want to encourage people to add values to a well-known names, as these are
265
+ // defined by rustc/Rust itself. Users can still do this if they wish, but should not be
266
+ // encouraged to do so.
267
+ let can_suggest_adding_value = !sess. psess . check_config . well_known_names . contains ( & name)
268
+ // Except when working on rustc or the standard library itself, in which case we want to
269
+ // suggest adding these cfgs to the "normal" place because of bootstraping reasons. As a
270
+ // basic heuristic, we use the "cheat" unstable feature enable method and the
271
+ // non-ui-testing enabled option.
272
+ || ( matches ! ( sess. psess. unstable_features, rustc_feature:: UnstableFeatures :: Cheat )
273
+ && !sess. opts . unstable_opts . ui_testing ) ;
268
274
269
275
let inst = |escape_quotes| to_check_cfg_arg ( name, value. map ( |( v, _s) | v) , escape_quotes) ;
270
276
@@ -275,14 +281,14 @@ pub(super) fn unexpected_cfg_value(
275
281
} else {
276
282
Some ( lints:: unexpected_cfg_value:: CargoHelp :: DefineFeatures )
277
283
}
278
- } else if !is_cfg_a_well_know_name {
284
+ } else if can_suggest_adding_value {
279
285
Some ( lints:: unexpected_cfg_value:: CargoHelp :: Other ( cargo_help_sub ( sess, & inst) ) )
280
286
} else {
281
287
None
282
288
} ;
283
289
lints:: unexpected_cfg_value:: InvocationHelp :: Cargo ( help)
284
290
} else {
285
- let help = if !is_cfg_a_well_know_name {
291
+ let help = if can_suggest_adding_value {
286
292
Some ( lints:: UnexpectedCfgRustcHelp :: new ( & inst ( EscapeQuotes :: No ) ) )
287
293
} else {
288
294
None
0 commit comments