@@ -3,8 +3,8 @@ use std::ops::Range;
33use rustc_errors:: E0232 ;
44use rustc_hir:: AttrPath ;
55use rustc_hir:: attrs:: diagnostic:: {
6- Directive , FilterFormatString , Flag , FormatArg , FormatString , LitOrArg , Name , NameValue ,
7- OnUnimplementedCondition , Piece , Predicate ,
6+ Directive , Filter , FilterFormatString , Flag , FormatArg , FormatString , LitOrArg , Name ,
7+ NameValue , Piece , Predicate ,
88} ;
99use rustc_macros:: Diagnostic ;
1010use rustc_parse_format:: {
@@ -201,12 +201,11 @@ fn parse_directive_items<'p>(
201201 items : impl Iterator < Item = & ' p MetaItemOrLitParser > ,
202202 is_root : bool ,
203203) -> Option < Directive > {
204- let condition = None ;
205204 let mut message: Option < ( Span , _ ) > = None ;
206205 let mut label: Option < ( Span , _ ) > = None ;
207206 let mut notes = ThinVec :: new ( ) ;
208207 let mut parent_label = None ;
209- let mut subcommands = ThinVec :: new ( ) ;
208+ let mut filters = ThinVec :: new ( ) ;
210209
211210 for item in items {
212211 let span = item. span ( ) ;
@@ -330,29 +329,27 @@ fn parse_directive_items<'p>(
330329 if is_root {
331330 let items = or_malformed ! ( item. args( ) . as_list( ) ?) ;
332331 let mut iter = items. mixed ( ) ;
333- let condition : & MetaItemOrLitParser = match iter. next ( ) {
332+ let filter : & MetaItemOrLitParser = match iter. next ( ) {
334333 Some ( c) => c,
335334 None => {
336335 cx. emit_err ( InvalidOnClause :: Empty { span } ) ;
337336 continue ;
338337 }
339338 } ;
340339
341- let condition = parse_condition ( condition ) ;
340+ let filter = parse_filter ( filter ) ;
342341
343342 if items. len ( ) < 2 {
344343 // Something like `#[rustc_on_unimplemented(on(.., /* nothing */))]`
345- // There's a condition but no directive behind it, this is a mistake.
344+ // There's a filter but no directive behind it, this is a mistake.
346345 malformed ! ( ) ;
347346 }
348347
349- let mut directive =
350- or_malformed ! ( parse_directive_items( cx, mode, iter, false ) ?) ;
351-
352- match condition {
353- Ok ( c) => {
354- directive. condition = Some ( c) ;
355- subcommands. push ( directive) ;
348+ match filter {
349+ Ok ( filter) => {
350+ let directive =
351+ or_malformed ! ( parse_directive_items( cx, mode, iter, false ) ?) ;
352+ filters. push ( ( filter, directive) ) ;
356353 }
357354 Err ( e) => {
358355 cx. emit_err ( e) ;
@@ -371,8 +368,7 @@ fn parse_directive_items<'p>(
371368
372369 Some ( Directive {
373370 is_rustc_attr : matches ! ( mode, Mode :: RustcOnUnimplemented ) ,
374- condition,
375- subcommands,
371+ filters,
376372 message,
377373 label,
378374 notes,
@@ -513,12 +509,10 @@ fn slice_span(input: Span, Range { start, end }: Range<usize>, is_source_literal
513509 if is_source_literal { input. from_inner ( InnerSpan { start, end } ) } else { input }
514510}
515511
516- pub ( crate ) fn parse_condition (
517- input : & MetaItemOrLitParser ,
518- ) -> Result < OnUnimplementedCondition , InvalidOnClause > {
512+ pub ( crate ) fn parse_filter ( input : & MetaItemOrLitParser ) -> Result < Filter , InvalidOnClause > {
519513 let span = input. span ( ) ;
520514 let pred = parse_predicate ( input) ?;
521- Ok ( OnUnimplementedCondition { span, pred } )
515+ Ok ( Filter { span, pred } )
522516}
523517
524518fn parse_predicate ( input : & MetaItemOrLitParser ) -> Result < Predicate , InvalidOnClause > {
@@ -553,7 +547,7 @@ fn parse_predicate(input: &MetaItemOrLitParser) -> Result<Predicate, InvalidOnCl
553547 return Err ( InvalidOnClause :: UnsupportedLiteral { span : p. args_span ( ) } ) ;
554548 } ;
555549 let name = parse_name ( predicate. name ) ;
556- let value = parse_filter ( value. name ) ;
550+ let value = parse_filter_format ( value. name ) ;
557551 let kv = NameValue { name, value } ;
558552 Ok ( Predicate :: Match ( kv) )
559553 }
@@ -588,7 +582,7 @@ fn parse_name(name: Symbol) -> Name {
588582 }
589583}
590584
591- fn parse_filter ( input : Symbol ) -> FilterFormatString {
585+ fn parse_filter_format ( input : Symbol ) -> FilterFormatString {
592586 let pieces = Parser :: new ( input. as_str ( ) , None , None , false , ParseMode :: Diagnostic )
593587 . map ( |p| match p {
594588 RpfPiece :: Lit ( s) => LitOrArg :: Lit ( Symbol :: intern ( s) ) ,
0 commit comments