@@ -44,7 +44,7 @@ impl<'a> ParserAnyMacro<'a> {
4444 /// about e.g. the semicolon in `macro_rules! kapow { () => {
4545 /// panic!(); } }` doesn't get picked up by .parse_expr(), but it's
4646 /// allowed to be there.
47- fn ensure_complete_parse ( & self , allow_semi : bool ) {
47+ fn ensure_complete_parse ( & self , allow_semi : bool , context : & str ) {
4848 let mut parser = self . parser . borrow_mut ( ) ;
4949 if allow_semi && parser. token == token:: Semi {
5050 panictry ! ( parser. bump( ) )
@@ -58,8 +58,8 @@ impl<'a> ParserAnyMacro<'a> {
5858 parser. span_err ( span, & msg[ ..] ) ;
5959
6060 let msg = format ! ( "caused by the macro expansion here; the usage \
61- of `{}` is likely invalid in this context",
62- self . macro_ident) ;
61+ of `{}! ` is likely invalid in {} context",
62+ self . macro_ident, context ) ;
6363 parser. span_note ( self . site_span , & msg[ ..] ) ;
6464 }
6565 }
@@ -68,20 +68,20 @@ impl<'a> ParserAnyMacro<'a> {
6868impl < ' a > MacResult for ParserAnyMacro < ' a > {
6969 fn make_expr ( self : Box < ParserAnyMacro < ' a > > ) -> Option < P < ast:: Expr > > {
7070 let ret = panictry ! ( self . parser. borrow_mut( ) . parse_expr( ) ) ;
71- self . ensure_complete_parse ( true ) ;
71+ self . ensure_complete_parse ( true , "expression" ) ;
7272 Some ( ret)
7373 }
7474 fn make_pat ( self : Box < ParserAnyMacro < ' a > > ) -> Option < P < ast:: Pat > > {
7575 let ret = panictry ! ( self . parser. borrow_mut( ) . parse_pat( ) ) ;
76- self . ensure_complete_parse ( false ) ;
76+ self . ensure_complete_parse ( false , "pattern" ) ;
7777 Some ( ret)
7878 }
7979 fn make_items ( self : Box < ParserAnyMacro < ' a > > ) -> Option < SmallVector < P < ast:: Item > > > {
8080 let mut ret = SmallVector :: zero ( ) ;
8181 while let Some ( item) = panictry ! ( self . parser. borrow_mut( ) . parse_item( ) ) {
8282 ret. push ( item) ;
8383 }
84- self . ensure_complete_parse ( false ) ;
84+ self . ensure_complete_parse ( false , "item" ) ;
8585 Some ( ret)
8686 }
8787
@@ -95,7 +95,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
9595 _ => ret. push ( panictry ! ( parser. parse_impl_item( ) ) )
9696 }
9797 }
98- self . ensure_complete_parse ( false ) ;
98+ self . ensure_complete_parse ( false , "item" ) ;
9999 Some ( ret)
100100 }
101101
@@ -115,13 +115,13 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
115115 }
116116 }
117117 }
118- self . ensure_complete_parse ( false ) ;
118+ self . ensure_complete_parse ( false , "statement" ) ;
119119 Some ( ret)
120120 }
121121
122122 fn make_ty ( self : Box < ParserAnyMacro < ' a > > ) -> Option < P < ast:: Ty > > {
123123 let ret = panictry ! ( self . parser. borrow_mut( ) . parse_ty( ) ) ;
124- self . ensure_complete_parse ( true ) ;
124+ self . ensure_complete_parse ( false , "type" ) ;
125125 Some ( ret)
126126 }
127127}
@@ -327,7 +327,7 @@ fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &TokenTree, sp: Span) {
327327 tt @ & TokenTree :: Sequence ( ..) => {
328328 check_matcher ( cx, Some ( tt) . into_iter ( ) , & Eof ) ;
329329 } ,
330- _ => cx. span_err ( sp, "Invalid macro matcher; matchers must be contained \
330+ _ => cx. span_err ( sp, "invalid macro matcher; matchers must be contained \
331331 in balanced delimiters or a repetition indicator")
332332 } ;
333333 // we don't abort on errors on rejection, the driver will do that for us
0 commit comments