@@ -639,9 +639,9 @@ macro_rules! with_exts_frame {
639639// When we enter a module, record it, for the sake of `module!`
640640pub fn expand_item ( it : P < ast:: Item > , fld : & mut MacroExpander )
641641 -> SmallVector < P < ast:: Item > > {
642- let it = expand_item_modifiers ( it , fld) ;
642+ let it = expand_item_multi_modifier ( Annotatable :: Item ( it ) , fld) ;
643643
644- expand_annotatable ( Annotatable :: Item ( it ) , fld)
644+ expand_annotatable ( it , fld)
645645 . into_iter ( ) . map ( |i| i. expect_item ( ) ) . collect ( )
646646}
647647
@@ -1278,11 +1278,9 @@ macro_rules! partition {
12781278 }
12791279}
12801280
1281- partition ! ( modifiers, Modifier ) ;
12821281partition ! ( multi_modifiers, MultiModifier ) ;
12831282
12841283
1285- #[ allow( deprecated) ] // The `allow` is needed because the `Decorator` variant is used.
12861284fn expand_decorators ( a : Annotatable ,
12871285 fld : & mut MacroExpander ,
12881286 decorator_items : & mut SmallVector < Annotatable > ,
@@ -1292,33 +1290,6 @@ fn expand_decorators(a: Annotatable,
12921290 let mname = intern ( & attr. name ( ) ) ;
12931291 match fld. cx . syntax_env . find ( & mname) {
12941292 Some ( rc) => match * rc {
1295- Decorator ( ref dec) => {
1296- attr:: mark_used ( & attr) ;
1297-
1298- fld. cx . bt_push ( ExpnInfo {
1299- call_site : attr. span ,
1300- callee : NameAndSpan {
1301- format : MacroAttribute ( mname) ,
1302- span : Some ( attr. span ) ,
1303- // attributes can do whatever they like,
1304- // for now.
1305- allow_internal_unstable : true ,
1306- }
1307- } ) ;
1308-
1309- // we'd ideally decorator_items.push_all(expand_item(item, fld)),
1310- // but that double-mut-borrows fld
1311- let mut items: SmallVector < Annotatable > = SmallVector :: zero ( ) ;
1312- dec. expand ( fld. cx ,
1313- attr. span ,
1314- & attr. node . value ,
1315- & a. clone ( ) . expect_item ( ) ,
1316- & mut |item| items. push ( Annotatable :: Item ( item) ) ) ;
1317- decorator_items. extend ( items. into_iter ( )
1318- . flat_map ( |ann| expand_annotatable ( ann, fld) . into_iter ( ) ) ) ;
1319-
1320- fld. cx . bt_pop ( ) ;
1321- }
13221293 MultiDecorator ( ref dec) => {
13231294 attr:: mark_used ( & attr) ;
13241295
@@ -1395,58 +1366,6 @@ fn expand_item_multi_modifier(mut it: Annotatable,
13951366 expand_item_multi_modifier ( it, fld)
13961367}
13971368
1398- #[ allow( deprecated) ] // This is needed because the `ItemModifier` trait is used
1399- fn expand_item_modifiers ( mut it : P < ast:: Item > ,
1400- fld : & mut MacroExpander )
1401- -> P < ast:: Item > {
1402- // partition the attributes into ItemModifiers and others
1403- let ( modifiers, other_attrs) = modifiers ( & it. attrs , fld) ;
1404-
1405- // update the attrs, leave everything else alone. Is this mutation really a good idea?
1406- it = P ( ast:: Item {
1407- attrs : other_attrs,
1408- ..( * it) . clone ( )
1409- } ) ;
1410-
1411- if modifiers. is_empty ( ) {
1412- let it = expand_item_multi_modifier ( Annotatable :: Item ( it) , fld) ;
1413- return it. expect_item ( ) ;
1414- }
1415-
1416- for attr in & modifiers {
1417- let mname = intern ( & attr. name ( ) ) ;
1418-
1419- match fld. cx . syntax_env . find ( & mname) {
1420- Some ( rc) => match * rc {
1421- Modifier ( ref mac) => {
1422- attr:: mark_used ( attr) ;
1423- fld. cx . bt_push ( ExpnInfo {
1424- call_site : attr. span ,
1425- callee : NameAndSpan {
1426- format : MacroAttribute ( mname) ,
1427- span : Some ( attr. span ) ,
1428- // attributes can do whatever they like,
1429- // for now
1430- allow_internal_unstable : true ,
1431- }
1432- } ) ;
1433- it = mac. expand ( fld. cx , attr. span , & * attr. node . value , it) ;
1434- fld. cx . bt_pop ( ) ;
1435- }
1436- _ => unreachable ! ( )
1437- } ,
1438- _ => unreachable ! ( )
1439- }
1440- }
1441-
1442- // Expansion may have added new ItemModifiers.
1443- // It is possible, that an item modifier could expand to a multi-modifier or
1444- // vice versa. In this case we will expand all modifiers before multi-modifiers,
1445- // which might give an odd ordering. However, I think it is unlikely that the
1446- // two kinds will be mixed, and old-style multi-modifiers are deprecated.
1447- expand_item_modifiers ( it, fld)
1448- }
1449-
14501369fn expand_impl_item ( ii : P < ast:: ImplItem > , fld : & mut MacroExpander )
14511370 -> SmallVector < P < ast:: ImplItem > > {
14521371 match ii. node {
0 commit comments