@@ -11,9 +11,9 @@ use rustc_ast::ptr::P;
11
11
use rustc_ast:: token;
12
12
use rustc_ast:: tokenstream:: TokenStream ;
13
13
use rustc_ast:: visit:: { self , AssocCtxt , Visitor } ;
14
- use rustc_ast:: { AstLike , AstLikeWrapper , Block , Inline , ItemKind , MacArgs , MacCall } ;
15
- use rustc_ast:: { MacCallStmt , MacStmtStyle , MetaItemKind , ModKind , NestedMetaItem } ;
16
- use rustc_ast:: { NodeId , Path , StmtKind } ;
14
+ use rustc_ast:: { AssocItemKind , AstLike , AstLikeWrapper , AttrStyle , ExprKind , ForeignItemKind } ;
15
+ use rustc_ast:: { Inline , ItemKind , MacArgs , MacStmtStyle , MetaItemKind , ModKind , NestedMetaItem } ;
16
+ use rustc_ast:: { NodeId , PatKind , StmtKind , TyKind } ;
17
17
use rustc_ast_pretty:: pprust;
18
18
use rustc_attr:: is_builtin_attr;
19
19
use rustc_data_structures:: map_in_place:: MapInPlace ;
@@ -317,10 +317,10 @@ pub enum InvocationKind {
317
317
pos : usize ,
318
318
item : Annotatable ,
319
319
// Required for resolving derive helper attributes.
320
- derives : Vec < Path > ,
320
+ derives : Vec < ast :: Path > ,
321
321
} ,
322
322
Derive {
323
- path : Path ,
323
+ path : ast :: Path ,
324
324
item : Annotatable ,
325
325
} ,
326
326
}
@@ -678,7 +678,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
678
678
krate,
679
679
) ,
680
680
Annotatable :: Item ( item_inner)
681
- if matches ! ( attr. style, ast :: AttrStyle :: Inner )
681
+ if matches ! ( attr. style, AttrStyle :: Inner )
682
682
&& matches ! (
683
683
item_inner. kind,
684
684
ItemKind :: Mod (
@@ -746,7 +746,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
746
746
if let SyntaxExtensionKind :: Derive ( ..) = ext {
747
747
self . gate_proc_macro_input ( & item) ;
748
748
}
749
- let meta = ast:: MetaItem { kind : ast :: MetaItemKind :: Word , span, path } ;
749
+ let meta = ast:: MetaItem { kind : MetaItemKind :: Word , span, path } ;
750
750
let items = match expander. expand ( self . cx , span, & meta, item) {
751
751
ExpandResult :: Ready ( items) => items,
752
752
ExpandResult :: Retry ( item) => {
@@ -808,7 +808,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
808
808
impl < ' ast , ' a > Visitor < ' ast > for GateProcMacroInput < ' a > {
809
809
fn visit_item ( & mut self , item : & ' ast ast:: Item ) {
810
810
match & item. kind {
811
- ast :: ItemKind :: Mod ( _, mod_kind)
811
+ ItemKind :: Mod ( _, mod_kind)
812
812
if !matches ! ( mod_kind, ModKind :: Loaded ( _, Inline :: Yes , _) ) =>
813
813
{
814
814
feature_err (
@@ -836,7 +836,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
836
836
& mut self ,
837
837
toks : TokenStream ,
838
838
kind : AstFragmentKind ,
839
- path : & Path ,
839
+ path : & ast :: Path ,
840
840
span : Span ,
841
841
) -> AstFragment {
842
842
let mut parser = self . cx . new_parser_from_tts ( toks) ;
@@ -928,7 +928,7 @@ pub fn parse_ast_fragment<'a>(
928
928
929
929
pub fn ensure_complete_parse < ' a > (
930
930
this : & mut Parser < ' a > ,
931
- macro_path : & Path ,
931
+ macro_path : & ast :: Path ,
932
932
kind_name : & str ,
933
933
span : Span ,
934
934
) {
@@ -1053,12 +1053,12 @@ impl InvocationCollectorNode for P<ast::Item> {
1053
1053
noop_flat_map_item ( self , visitor)
1054
1054
}
1055
1055
fn is_mac_call ( & self ) -> bool {
1056
- matches ! ( self . kind, ast :: ItemKind :: MacCall ( ..) )
1056
+ matches ! ( self . kind, ItemKind :: MacCall ( ..) )
1057
1057
}
1058
1058
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1059
1059
let node = self . into_inner ( ) ;
1060
1060
match node. kind {
1061
- ast :: ItemKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1061
+ ItemKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1062
1062
_ => unreachable ! ( ) ,
1063
1063
}
1064
1064
}
@@ -1067,13 +1067,13 @@ impl InvocationCollectorNode for P<ast::Item> {
1067
1067
collector : & mut InvocationCollector < ' _ , ' _ > ,
1068
1068
noop_flat_map : impl FnOnce ( Self , & mut InvocationCollector < ' _ , ' _ > ) -> Self :: OutputTy ,
1069
1069
) -> Result < Self :: OutputTy , Self > {
1070
- if !matches ! ( node. kind, ast :: ItemKind :: Mod ( ..) ) {
1070
+ if !matches ! ( node. kind, ItemKind :: Mod ( ..) ) {
1071
1071
return Ok ( noop_flat_map ( node, collector) ) ;
1072
1072
}
1073
1073
1074
1074
// Work around borrow checker not seeing through `P`'s deref.
1075
1075
let ( ident, span, mut attrs) = ( node. ident , node. span , mem:: take ( & mut node. attrs ) ) ;
1076
- let ast :: ItemKind :: Mod ( _, mod_kind) = & mut node. kind else {
1076
+ let ItemKind :: Mod ( _, mod_kind) = & mut node. kind else {
1077
1077
unreachable ! ( )
1078
1078
} ;
1079
1079
@@ -1157,12 +1157,12 @@ impl InvocationCollectorNode for AstLikeWrapper<P<ast::AssocItem>, TraitItemTag>
1157
1157
noop_flat_map_assoc_item ( self . wrapped , visitor)
1158
1158
}
1159
1159
fn is_mac_call ( & self ) -> bool {
1160
- matches ! ( self . wrapped. kind, ast :: AssocItemKind :: MacCall ( ..) )
1160
+ matches ! ( self . wrapped. kind, AssocItemKind :: MacCall ( ..) )
1161
1161
}
1162
1162
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1163
1163
let item = self . wrapped . into_inner ( ) ;
1164
1164
match item. kind {
1165
- ast :: AssocItemKind :: MacCall ( mac) => ( mac, item. attrs , AddSemicolon :: No ) ,
1165
+ AssocItemKind :: MacCall ( mac) => ( mac, item. attrs , AddSemicolon :: No ) ,
1166
1166
_ => unreachable ! ( ) ,
1167
1167
}
1168
1168
}
@@ -1185,12 +1185,12 @@ impl InvocationCollectorNode for AstLikeWrapper<P<ast::AssocItem>, ImplItemTag>
1185
1185
noop_flat_map_assoc_item ( self . wrapped , visitor)
1186
1186
}
1187
1187
fn is_mac_call ( & self ) -> bool {
1188
- matches ! ( self . wrapped. kind, ast :: AssocItemKind :: MacCall ( ..) )
1188
+ matches ! ( self . wrapped. kind, AssocItemKind :: MacCall ( ..) )
1189
1189
}
1190
1190
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1191
1191
let item = self . wrapped . into_inner ( ) ;
1192
1192
match item. kind {
1193
- ast :: AssocItemKind :: MacCall ( mac) => ( mac, item. attrs , AddSemicolon :: No ) ,
1193
+ AssocItemKind :: MacCall ( mac) => ( mac, item. attrs , AddSemicolon :: No ) ,
1194
1194
_ => unreachable ! ( ) ,
1195
1195
}
1196
1196
}
@@ -1211,12 +1211,12 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
1211
1211
noop_flat_map_foreign_item ( self , visitor)
1212
1212
}
1213
1213
fn is_mac_call ( & self ) -> bool {
1214
- matches ! ( self . kind, ast :: ForeignItemKind :: MacCall ( ..) )
1214
+ matches ! ( self . kind, ForeignItemKind :: MacCall ( ..) )
1215
1215
}
1216
1216
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1217
1217
let node = self . into_inner ( ) ;
1218
1218
match node. kind {
1219
- ast :: ForeignItemKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1219
+ ForeignItemKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1220
1220
_ => unreachable ! ( ) ,
1221
1221
}
1222
1222
}
@@ -1353,7 +1353,7 @@ impl InvocationCollectorNode for ast::Stmt {
1353
1353
match & self . kind {
1354
1354
StmtKind :: MacCall ( ..) => true ,
1355
1355
StmtKind :: Item ( item) => matches ! ( item. kind, ItemKind :: MacCall ( ..) ) ,
1356
- StmtKind :: Semi ( expr) => matches ! ( expr. kind, ast :: ExprKind :: MacCall ( ..) ) ,
1356
+ StmtKind :: Semi ( expr) => matches ! ( expr. kind, ExprKind :: MacCall ( ..) ) ,
1357
1357
StmtKind :: Expr ( ..) => unreachable ! ( ) ,
1358
1358
StmtKind :: Local ( ..) | StmtKind :: Empty => false ,
1359
1359
}
@@ -1363,7 +1363,7 @@ impl InvocationCollectorNode for ast::Stmt {
1363
1363
// `StmtKind`s and treat them as statement macro invocations, not as items or expressions.
1364
1364
let ( add_semicolon, mac, attrs) = match self . kind {
1365
1365
StmtKind :: MacCall ( mac) => {
1366
- let MacCallStmt { mac, style, attrs, .. } = mac. into_inner ( ) ;
1366
+ let ast :: MacCallStmt { mac, style, attrs, .. } = mac. into_inner ( ) ;
1367
1367
( style == MacStmtStyle :: Semicolon , mac, attrs)
1368
1368
}
1369
1369
StmtKind :: Item ( item) => match item. into_inner ( ) {
@@ -1373,7 +1373,7 @@ impl InvocationCollectorNode for ast::Stmt {
1373
1373
_ => unreachable ! ( ) ,
1374
1374
} ,
1375
1375
StmtKind :: Semi ( expr) => match expr. into_inner ( ) {
1376
- ast:: Expr { kind : ast :: ExprKind :: MacCall ( mac) , attrs, .. } => {
1376
+ ast:: Expr { kind : ExprKind :: MacCall ( mac) , attrs, .. } => {
1377
1377
( mac. args . need_semicolon ( ) , mac, attrs)
1378
1378
}
1379
1379
_ => unreachable ! ( ) ,
@@ -1431,7 +1431,7 @@ impl InvocationCollectorNode for P<ast::Ty> {
1431
1431
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1432
1432
let node = self . into_inner ( ) ;
1433
1433
match node. kind {
1434
- ast :: TyKind :: MacCall ( mac) => ( mac, Vec :: new ( ) , AddSemicolon :: No ) ,
1434
+ TyKind :: MacCall ( mac) => ( mac, Vec :: new ( ) , AddSemicolon :: No ) ,
1435
1435
_ => unreachable ! ( ) ,
1436
1436
}
1437
1437
}
@@ -1453,12 +1453,12 @@ impl InvocationCollectorNode for P<ast::Pat> {
1453
1453
noop_visit_pat ( self , visitor)
1454
1454
}
1455
1455
fn is_mac_call ( & self ) -> bool {
1456
- matches ! ( self . kind, ast :: PatKind :: MacCall ( ..) )
1456
+ matches ! ( self . kind, PatKind :: MacCall ( ..) )
1457
1457
}
1458
1458
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1459
1459
let node = self . into_inner ( ) ;
1460
1460
match node. kind {
1461
- ast :: PatKind :: MacCall ( mac) => ( mac, Vec :: new ( ) , AddSemicolon :: No ) ,
1461
+ PatKind :: MacCall ( mac) => ( mac, Vec :: new ( ) , AddSemicolon :: No ) ,
1462
1462
_ => unreachable ! ( ) ,
1463
1463
}
1464
1464
}
@@ -1481,12 +1481,12 @@ impl InvocationCollectorNode for P<ast::Expr> {
1481
1481
noop_visit_expr ( self , visitor)
1482
1482
}
1483
1483
fn is_mac_call ( & self ) -> bool {
1484
- matches ! ( self . kind, ast :: ExprKind :: MacCall ( ..) )
1484
+ matches ! ( self . kind, ExprKind :: MacCall ( ..) )
1485
1485
}
1486
1486
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1487
1487
let node = self . into_inner ( ) ;
1488
1488
match node. kind {
1489
- ast :: ExprKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1489
+ ExprKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1490
1490
_ => unreachable ! ( ) ,
1491
1491
}
1492
1492
}
@@ -1516,7 +1516,7 @@ impl InvocationCollectorNode for AstLikeWrapper<P<ast::Expr>, OptExprTag> {
1516
1516
fn take_mac_call ( self ) -> ( ast:: MacCall , Self :: AttrsTy , AddSemicolon ) {
1517
1517
let node = self . wrapped . into_inner ( ) ;
1518
1518
match node. kind {
1519
- ast :: ExprKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1519
+ ExprKind :: MacCall ( mac) => ( mac, node. attrs , AddSemicolon :: No ) ,
1520
1520
_ => unreachable ! ( ) ,
1521
1521
}
1522
1522
}
@@ -1560,7 +1560,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1560
1560
1561
1561
fn collect_attr (
1562
1562
& mut self ,
1563
- ( attr, pos, derives) : ( ast:: Attribute , usize , Vec < Path > ) ,
1563
+ ( attr, pos, derives) : ( ast:: Attribute , usize , Vec < ast :: Path > ) ,
1564
1564
item : Annotatable ,
1565
1565
kind : AstFragmentKind ,
1566
1566
) -> AstFragment {
@@ -1573,7 +1573,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1573
1573
fn take_first_attr (
1574
1574
& self ,
1575
1575
item : & mut impl AstLike ,
1576
- ) -> Option < ( ast:: Attribute , usize , Vec < Path > ) > {
1576
+ ) -> Option < ( ast:: Attribute , usize , Vec < ast :: Path > ) > {
1577
1577
let mut attr = None ;
1578
1578
1579
1579
item. visit_attrs ( |attrs| {
@@ -1609,7 +1609,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1609
1609
1610
1610
// Detect use of feature-gated or invalid attributes on macro invocations
1611
1611
// since they will not be detected after macro expansion.
1612
- fn check_attributes ( & self , attrs : & [ ast:: Attribute ] , call : & MacCall ) {
1612
+ fn check_attributes ( & self , attrs : & [ ast:: Attribute ] , call : & ast :: MacCall ) {
1613
1613
let features = self . cx . ecfg . features . unwrap ( ) ;
1614
1614
let mut attrs = attrs. iter ( ) . peekable ( ) ;
1615
1615
let mut span: Option < Span > = None ;
@@ -1764,7 +1764,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1764
1764
let mut node = configure ! ( self , node) ;
1765
1765
return match & node. kind {
1766
1766
StmtKind :: Expr ( expr)
1767
- if matches ! ( * * expr, ast:: Expr { kind: ast :: ExprKind :: MacCall ( ..) , .. } ) =>
1767
+ if matches ! ( * * expr, ast:: Expr { kind: ExprKind :: MacCall ( ..) , .. } ) =>
1768
1768
{
1769
1769
self . cx . current_expansion . is_trailing_mac = true ;
1770
1770
// Don't use `assign_id` for this statement - it may get removed
@@ -1801,7 +1801,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1801
1801
self . flat_map_node ( AstLikeWrapper :: new ( node, OptExprTag ) )
1802
1802
}
1803
1803
1804
- fn visit_block ( & mut self , node : & mut P < Block > ) {
1804
+ fn visit_block ( & mut self , node : & mut P < ast :: Block > ) {
1805
1805
let orig_dir_ownership = mem:: replace (
1806
1806
& mut self . cx . current_expansion . dir_ownership ,
1807
1807
DirOwnership :: UnownedViaBlock ,
@@ -1810,7 +1810,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1810
1810
self . cx . current_expansion . dir_ownership = orig_dir_ownership;
1811
1811
}
1812
1812
1813
- fn visit_id ( & mut self , id : & mut ast :: NodeId ) {
1813
+ fn visit_id ( & mut self , id : & mut NodeId ) {
1814
1814
// We may have already assigned a `NodeId`
1815
1815
// by calling `assign_id`
1816
1816
if self . monotonic && * id == ast:: DUMMY_NODE_ID {
0 commit comments