@@ -1379,10 +1379,15 @@ pub enum Movability {
1379
1379
pub struct Mac {
1380
1380
pub path : Path ,
1381
1381
pub args : P < MacArgs > ,
1382
- pub span : Span ,
1383
1382
pub prior_type_ascription : Option < ( Span , bool ) > ,
1384
1383
}
1385
1384
1385
+ impl Mac {
1386
+ pub fn span ( & self ) -> Span {
1387
+ self . path . span . to ( self . args . span ( ) . unwrap_or ( self . path . span ) )
1388
+ }
1389
+ }
1390
+
1386
1391
/// Arguments passed to an attribute or a function-like macro.
1387
1392
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1388
1393
pub enum MacArgs {
@@ -1403,6 +1408,14 @@ impl MacArgs {
1403
1408
}
1404
1409
}
1405
1410
1411
+ pub fn span ( & self ) -> Option < Span > {
1412
+ match * self {
1413
+ MacArgs :: Empty => None ,
1414
+ MacArgs :: Delimited ( dspan, ..) => Some ( dspan. entire ( ) ) ,
1415
+ MacArgs :: Eq ( eq_span, ref tokens) => Some ( eq_span. to ( tokens. span ( ) . unwrap_or ( eq_span) ) ) ,
1416
+ }
1417
+ }
1418
+
1406
1419
/// Tokens inside the delimiters or after `=`.
1407
1420
/// Proc macros see these tokens, for example.
1408
1421
pub fn inner_tokens ( & self ) -> TokenStream {
@@ -1432,12 +1445,6 @@ impl MacArgs {
1432
1445
}
1433
1446
}
1434
1447
1435
- impl Mac {
1436
- pub fn stream ( & self ) -> TokenStream {
1437
- self . args . inner_tokens ( )
1438
- }
1439
- }
1440
-
1441
1448
#[ derive( Copy , Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Debug ) ]
1442
1449
pub enum MacDelimiter {
1443
1450
Parenthesis ,
0 commit comments