@@ -1379,10 +1379,15 @@ pub enum Movability {
13791379pub struct Mac {
13801380 pub path : Path ,
13811381 pub args : P < MacArgs > ,
1382- pub span : Span ,
13831382 pub prior_type_ascription : Option < ( Span , bool ) > ,
13841383}
13851384
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+
13861391/// Arguments passed to an attribute or a function-like macro.
13871392#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
13881393pub enum MacArgs {
@@ -1403,6 +1408,14 @@ impl MacArgs {
14031408 }
14041409 }
14051410
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+
14061419 /// Tokens inside the delimiters or after `=`.
14071420 /// Proc macros see these tokens, for example.
14081421 pub fn inner_tokens ( & self ) -> TokenStream {
@@ -1432,12 +1445,6 @@ impl MacArgs {
14321445 }
14331446}
14341447
1435- impl Mac {
1436- pub fn stream ( & self ) -> TokenStream {
1437- self . args . inner_tokens ( )
1438- }
1439- }
1440-
14411448#[ derive( Copy , Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Debug ) ]
14421449pub enum MacDelimiter {
14431450 Parenthesis ,
0 commit comments