@@ -1207,16 +1207,14 @@ impl<'a> Parser<'a> {
1207
1207
// eat a matched-delimiter token tree:
1208
1208
let delim = self . expect_open_delim ( ) ?;
1209
1209
let tts = self . parse_seq_to_end ( & token:: CloseDelim ( delim) ,
1210
- SeqSep :: none ( ) ,
1211
- |pp| pp. parse_token_tree ( ) ) ?;
1212
- let m_ = Mac_ { path : pth, tts : tts } ;
1213
- let m: ast:: Mac = codemap:: Spanned { node : m_,
1214
- span : mk_sp ( lo,
1215
- self . last_span . hi ) } ;
1210
+ SeqSep :: none ( ) ,
1211
+ |pp| pp. parse_token_tree ( ) ) ?;
1216
1212
if delim != token:: Brace {
1217
1213
self . expect ( & token:: Semi ) ?
1218
1214
}
1219
- ( keywords:: Invalid . ident ( ) , ast:: TraitItemKind :: Macro ( m) )
1215
+
1216
+ let mac = spanned ( lo, self . last_span . hi , Mac_ { path : pth, tts : tts } ) ;
1217
+ ( keywords:: Invalid . ident ( ) , ast:: TraitItemKind :: Macro ( mac) )
1220
1218
} else {
1221
1219
let ( constness, unsafety, abi) = match self . parse_fn_front_matter ( ) {
1222
1220
Ok ( cua) => cua,
@@ -1422,9 +1420,8 @@ impl<'a> Parser<'a> {
1422
1420
TyKind :: Path ( Some ( qself) , path)
1423
1421
} else if self . token . is_path_start ( ) {
1424
1422
let path = self . parse_path ( PathStyle :: Type ) ?;
1425
- if self . check ( & token:: Not ) {
1423
+ if self . eat ( & token:: Not ) {
1426
1424
// MACRO INVOCATION
1427
- self . bump ( ) ;
1428
1425
let delim = self . expect_open_delim ( ) ?;
1429
1426
let tts = self . parse_seq_to_end ( & token:: CloseDelim ( delim) ,
1430
1427
SeqSep :: none ( ) ,
@@ -2302,21 +2299,14 @@ impl<'a> Parser<'a> {
2302
2299
let pth = self . parse_path ( PathStyle :: Expr ) ?;
2303
2300
2304
2301
// `!`, as an operator, is prefix, so we know this isn't that
2305
- if self . check ( & token:: Not ) {
2302
+ if self . eat ( & token:: Not ) {
2306
2303
// MACRO INVOCATION expression
2307
- self . bump ( ) ;
2308
-
2309
2304
let delim = self . expect_open_delim ( ) ?;
2310
- let tts = self . parse_seq_to_end (
2311
- & token:: CloseDelim ( delim) ,
2312
- SeqSep :: none ( ) ,
2313
- |p| p. parse_token_tree ( ) ) ?;
2305
+ let tts = self . parse_seq_to_end ( & token:: CloseDelim ( delim) ,
2306
+ SeqSep :: none ( ) ,
2307
+ |p| p. parse_token_tree ( ) ) ?;
2314
2308
let hi = self . last_span . hi ;
2315
-
2316
- return Ok ( self . mk_mac_expr ( lo,
2317
- hi,
2318
- Mac_ { path : pth, tts : tts } ,
2319
- attrs) ) ;
2309
+ return Ok ( self . mk_mac_expr ( lo, hi, Mac_ { path : pth, tts : tts } , attrs) ) ;
2320
2310
}
2321
2311
if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
2322
2312
// This is a struct literal, unless we're prohibited
@@ -4880,14 +4870,12 @@ impl<'a> Parser<'a> {
4880
4870
let tts = self . parse_seq_to_end ( & token:: CloseDelim ( delim) ,
4881
4871
SeqSep :: none ( ) ,
4882
4872
|p| p. parse_token_tree ( ) ) ?;
4883
- let m_ = Mac_ { path : pth, tts : tts } ;
4884
- let m: ast:: Mac = codemap:: Spanned { node : m_,
4885
- span : mk_sp ( lo,
4886
- self . last_span . hi ) } ;
4887
4873
if delim != token:: Brace {
4888
4874
self . expect ( & token:: Semi ) ?
4889
4875
}
4890
- Ok ( ( keywords:: Invalid . ident ( ) , vec ! [ ] , ast:: ImplItemKind :: Macro ( m) ) )
4876
+
4877
+ let mac = spanned ( lo, self . last_span . hi , Mac_ { path : pth, tts : tts } ) ;
4878
+ Ok ( ( keywords:: Invalid . ident ( ) , vec ! [ ] , ast:: ImplItemKind :: Macro ( mac) ) )
4891
4879
} else {
4892
4880
let ( constness, unsafety, abi) = self . parse_fn_front_matter ( ) ?;
4893
4881
let ident = self . parse_ident ( ) ?;
@@ -6009,12 +5997,6 @@ impl<'a> Parser<'a> {
6009
5997
let tts = self . parse_seq_to_end ( & token:: CloseDelim ( delim) ,
6010
5998
SeqSep :: none ( ) ,
6011
5999
|p| p. parse_token_tree ( ) ) ?;
6012
- // single-variant-enum... :
6013
- let m = Mac_ { path : pth, tts : tts } ;
6014
- let m: ast:: Mac = codemap:: Spanned { node : m,
6015
- span : mk_sp ( mac_lo,
6016
- self . last_span . hi ) } ;
6017
-
6018
6000
if delim != token:: Brace {
6019
6001
if !self . eat ( & token:: Semi ) {
6020
6002
let last_span = self . last_span ;
@@ -6025,14 +6007,9 @@ impl<'a> Parser<'a> {
6025
6007
}
6026
6008
}
6027
6009
6028
- let item_ = ItemKind :: Mac ( m) ;
6029
- let last_span = self . last_span ;
6030
- let item = self . mk_item ( lo,
6031
- last_span. hi ,
6032
- id,
6033
- item_,
6034
- visibility,
6035
- attrs) ;
6010
+ let hi = self . last_span . hi ;
6011
+ let mac = spanned ( mac_lo, hi, Mac_ { path : pth, tts : tts } ) ;
6012
+ let item = self . mk_item ( lo, hi, id, ItemKind :: Mac ( mac) , visibility, attrs) ;
6036
6013
return Ok ( Some ( item) ) ;
6037
6014
}
6038
6015
0 commit comments