11use rustc_ast:: tokenstream:: TokenStream ;
22use rustc_attr_parsing as attr;
33use rustc_expand:: base:: { DummyResult , ExpandResult , ExtCtxt , MacroExpanderResult } ;
4- use rustc_parse:: parser:: cfg_select:: { CfgSelectBranches , CfgSelectRule , parse_cfg_select} ;
4+ use rustc_parse:: parser:: cfg_select:: { CfgSelectBranches , CfgSelectPredicate , parse_cfg_select} ;
55use rustc_span:: { Ident , Span , sym} ;
66
77use crate :: errors:: { CfgSelectNoMatches , CfgSelectUnreachable } ;
88
9- /// Selects the first arm whose rule evaluates to true.
9+ /// Selects the first arm whose predicate evaluates to true.
1010fn select_arm ( ecx : & ExtCtxt < ' _ > , branches : CfgSelectBranches ) -> Option < ( TokenStream , Span ) > {
1111 for ( cfg, tt, arm_span) in branches. reachable {
1212 if attr:: cfg_matches (
@@ -30,11 +30,11 @@ pub(super) fn expand_cfg_select<'cx>(
3030 ExpandResult :: Ready ( match parse_cfg_select ( & mut ecx. new_parser_from_tts ( tts) ) {
3131 Ok ( branches) => {
3232 if let Some ( ( underscore, _, _) ) = branches. wildcard {
33- // Warn for every unreachable rule . We store the fully parsed branch for rustfmt.
34- for ( rule , _, _) in & branches. unreachable {
35- let span = match rule {
36- CfgSelectRule :: Wildcard ( underscore) => underscore. span ,
37- CfgSelectRule :: Cfg ( cfg) => cfg. span ( ) ,
33+ // Warn for every unreachable predicate . We store the fully parsed branch for rustfmt.
34+ for ( predicate , _, _) in & branches. unreachable {
35+ let span = match predicate {
36+ CfgSelectPredicate :: Wildcard ( underscore) => underscore. span ,
37+ CfgSelectPredicate :: Cfg ( cfg) => cfg. span ( ) ,
3838 } ;
3939 let err = CfgSelectUnreachable { span, wildcard_span : underscore. span } ;
4040 ecx. dcx ( ) . emit_warn ( err) ;
@@ -50,7 +50,7 @@ pub(super) fn expand_cfg_select<'cx>(
5050 Ident :: with_dummy_span ( sym:: cfg_select) ,
5151 ) ;
5252 } else {
53- // Emit a compiler error when none of the rules matched.
53+ // Emit a compiler error when none of the predicates matched.
5454 let guar = ecx. dcx ( ) . emit_err ( CfgSelectNoMatches { span : sp } ) ;
5555 DummyResult :: any ( sp, guar)
5656 }
0 commit comments