@@ -44,7 +44,7 @@ impl<'a> ParserAnyMacro<'a> {
44
44
/// about e.g. the semicolon in `macro_rules! kapow { () => {
45
45
/// panic!(); } }` doesn't get picked up by .parse_expr(), but it's
46
46
/// allowed to be there.
47
- fn ensure_complete_parse ( & self , allow_semi : bool ) {
47
+ fn ensure_complete_parse ( & self , allow_semi : bool , context : & str ) {
48
48
let mut parser = self . parser . borrow_mut ( ) ;
49
49
if allow_semi && parser. token == token:: Semi {
50
50
panictry ! ( parser. bump( ) )
@@ -58,8 +58,8 @@ impl<'a> ParserAnyMacro<'a> {
58
58
parser. span_err ( span, & msg[ ..] ) ;
59
59
60
60
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 ) ;
63
63
parser. span_note ( self . site_span , & msg[ ..] ) ;
64
64
}
65
65
}
@@ -68,20 +68,20 @@ impl<'a> ParserAnyMacro<'a> {
68
68
impl < ' a > MacResult for ParserAnyMacro < ' a > {
69
69
fn make_expr ( self : Box < ParserAnyMacro < ' a > > ) -> Option < P < ast:: Expr > > {
70
70
let ret = panictry ! ( self . parser. borrow_mut( ) . parse_expr( ) ) ;
71
- self . ensure_complete_parse ( true ) ;
71
+ self . ensure_complete_parse ( true , "expression" ) ;
72
72
Some ( ret)
73
73
}
74
74
fn make_pat ( self : Box < ParserAnyMacro < ' a > > ) -> Option < P < ast:: Pat > > {
75
75
let ret = panictry ! ( self . parser. borrow_mut( ) . parse_pat( ) ) ;
76
- self . ensure_complete_parse ( false ) ;
76
+ self . ensure_complete_parse ( false , "pattern" ) ;
77
77
Some ( ret)
78
78
}
79
79
fn make_items ( self : Box < ParserAnyMacro < ' a > > ) -> Option < SmallVector < P < ast:: Item > > > {
80
80
let mut ret = SmallVector :: zero ( ) ;
81
81
while let Some ( item) = panictry ! ( self . parser. borrow_mut( ) . parse_item( ) ) {
82
82
ret. push ( item) ;
83
83
}
84
- self . ensure_complete_parse ( false ) ;
84
+ self . ensure_complete_parse ( false , "item" ) ;
85
85
Some ( ret)
86
86
}
87
87
@@ -95,7 +95,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
95
95
_ => ret. push ( panictry ! ( parser. parse_impl_item( ) ) )
96
96
}
97
97
}
98
- self . ensure_complete_parse ( false ) ;
98
+ self . ensure_complete_parse ( false , "item" ) ;
99
99
Some ( ret)
100
100
}
101
101
@@ -115,13 +115,13 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
115
115
}
116
116
}
117
117
}
118
- self . ensure_complete_parse ( false ) ;
118
+ self . ensure_complete_parse ( false , "statement" ) ;
119
119
Some ( ret)
120
120
}
121
121
122
122
fn make_ty ( self : Box < ParserAnyMacro < ' a > > ) -> Option < P < ast:: Ty > > {
123
123
let ret = panictry ! ( self . parser. borrow_mut( ) . parse_ty( ) ) ;
124
- self . ensure_complete_parse ( true ) ;
124
+ self . ensure_complete_parse ( false , "type" ) ;
125
125
Some ( ret)
126
126
}
127
127
}
@@ -327,7 +327,7 @@ fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &TokenTree, sp: Span) {
327
327
tt @ & TokenTree :: Sequence ( ..) => {
328
328
check_matcher ( cx, Some ( tt) . into_iter ( ) , & Eof ) ;
329
329
} ,
330
- _ => cx. span_err ( sp, "Invalid macro matcher; matchers must be contained \
330
+ _ => cx. span_err ( sp, "invalid macro matcher; matchers must be contained \
331
331
in balanced delimiters or a repetition indicator")
332
332
} ;
333
333
// we don't abort on errors on rejection, the driver will do that for us
0 commit comments