Skip to content

Commit e59a6f8

Browse files
Run eval_config_entry on all branches so we always emit lints
1 parent 7b9905e commit e59a6f8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_builtin_macros/src/cfg_select.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ use crate::errors::{CfgSelectNoMatches, CfgSelectUnreachable};
1010

1111
/// Selects the first arm whose predicate evaluates to true.
1212
fn select_arm(ecx: &ExtCtxt<'_>, branches: CfgSelectBranches) -> Option<(TokenStream, Span)> {
13+
let mut result = None;
1314
for (cfg, tt, arm_span) in branches.reachable {
1415
if let EvalConfigResult::True = attr::eval_config_entry(
1516
&ecx.sess,
1617
&cfg,
1718
ecx.current_expansion.lint_node_id,
1819
ShouldEmit::ErrorsAndLints,
1920
) {
20-
return Some((tt, arm_span));
21+
// FIXME(#149215) Ideally we should short-circuit here, but `eval_config_entry` currently emits lints so we cannot do this yet.
22+
result.get_or_insert((tt, arm_span));
2123
}
2224
}
2325

24-
branches.wildcard.map(|(_, tt, span)| (tt, span))
26+
let wildcard = branches.wildcard.map(|(_, tt, span)| (tt, span));
27+
result.or(wildcard)
2528
}
2629

2730
pub(super) fn expand_cfg_select<'cx>(

0 commit comments

Comments
 (0)