Point at macro definition when no rules expect token
This commit is contained in:
parent
a66dc8a148
commit
8227a938a4
21 changed files with 256 additions and 82 deletions
|
@ -247,8 +247,13 @@ impl<F> AttrProcMacro for F
|
||||||
|
|
||||||
/// Represents a thing that maps token trees to Macro Results
|
/// Represents a thing that maps token trees to Macro Results
|
||||||
pub trait TTMacroExpander {
|
pub trait TTMacroExpander {
|
||||||
fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, span: Span, input: TokenStream)
|
fn expand<'cx>(
|
||||||
-> Box<dyn MacResult+'cx>;
|
&self,
|
||||||
|
ecx: &'cx mut ExtCtxt,
|
||||||
|
span: Span,
|
||||||
|
input: TokenStream,
|
||||||
|
def_span: Option<Span>,
|
||||||
|
) -> Box<dyn MacResult+'cx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MacroExpanderFn =
|
pub type MacroExpanderFn =
|
||||||
|
@ -259,8 +264,13 @@ impl<F> TTMacroExpander for F
|
||||||
where F: for<'cx> Fn(&'cx mut ExtCtxt, Span, &[tokenstream::TokenTree])
|
where F: for<'cx> Fn(&'cx mut ExtCtxt, Span, &[tokenstream::TokenTree])
|
||||||
-> Box<dyn MacResult+'cx>
|
-> Box<dyn MacResult+'cx>
|
||||||
{
|
{
|
||||||
fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, span: Span, input: TokenStream)
|
fn expand<'cx>(
|
||||||
-> Box<dyn MacResult+'cx> {
|
&self,
|
||||||
|
ecx: &'cx mut ExtCtxt,
|
||||||
|
span: Span,
|
||||||
|
input: TokenStream,
|
||||||
|
_def_span: Option<Span>,
|
||||||
|
) -> Box<dyn MacResult+'cx> {
|
||||||
struct AvoidInterpolatedIdents;
|
struct AvoidInterpolatedIdents;
|
||||||
|
|
||||||
impl Folder for AvoidInterpolatedIdents {
|
impl Folder for AvoidInterpolatedIdents {
|
||||||
|
|
|
@ -764,7 +764,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
edition) {
|
edition) {
|
||||||
dummy_span
|
dummy_span
|
||||||
} else {
|
} else {
|
||||||
kind.make_from(expander.expand(self.cx, span, mac.node.stream()))
|
kind.make_from(expander.expand(self.cx, span, mac.node.stream(), None))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +785,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
edition) {
|
edition) {
|
||||||
dummy_span
|
dummy_span
|
||||||
} else {
|
} else {
|
||||||
kind.make_from(expander.expand(self.cx, span, mac.node.stream()))
|
kind.make_from(expander.expand(
|
||||||
|
self.cx,
|
||||||
|
span,
|
||||||
|
mac.node.stream(),
|
||||||
|
def_info.map(|(_, s)| s),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,16 +74,19 @@ struct MacroRulesMacroExpander {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TTMacroExpander for MacroRulesMacroExpander {
|
impl TTMacroExpander for MacroRulesMacroExpander {
|
||||||
fn expand<'cx>(&self,
|
fn expand<'cx>(
|
||||||
|
&self,
|
||||||
cx: &'cx mut ExtCtxt,
|
cx: &'cx mut ExtCtxt,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
input: TokenStream)
|
input: TokenStream,
|
||||||
-> Box<dyn MacResult+'cx> {
|
def_span: Option<Span>,
|
||||||
|
) -> Box<dyn MacResult+'cx> {
|
||||||
if !self.valid {
|
if !self.valid {
|
||||||
return DummyResult::any(sp);
|
return DummyResult::any(sp);
|
||||||
}
|
}
|
||||||
generic_extension(cx,
|
generic_extension(cx,
|
||||||
sp,
|
sp,
|
||||||
|
def_span,
|
||||||
self.name,
|
self.name,
|
||||||
input,
|
input,
|
||||||
&self.lhses,
|
&self.lhses,
|
||||||
|
@ -99,6 +102,7 @@ fn trace_macros_note(cx: &mut ExtCtxt, sp: Span, message: String) {
|
||||||
/// Given `lhses` and `rhses`, this is the new macro we create
|
/// Given `lhses` and `rhses`, this is the new macro we create
|
||||||
fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
|
fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
|
def_span: Option<Span>,
|
||||||
name: ast::Ident,
|
name: ast::Ident,
|
||||||
arg: TokenStream,
|
arg: TokenStream,
|
||||||
lhses: &[quoted::TokenTree],
|
lhses: &[quoted::TokenTree],
|
||||||
|
@ -178,7 +182,14 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
let best_fail_msg = parse_failure_msg(best_fail_tok.expect("ran no matchers"));
|
let best_fail_msg = parse_failure_msg(best_fail_tok.expect("ran no matchers"));
|
||||||
let mut err = cx.struct_span_err(best_fail_spot.substitute_dummy(sp), &best_fail_msg);
|
let span = best_fail_spot.substitute_dummy(sp);
|
||||||
|
let mut err = cx.struct_span_err(span, &best_fail_msg);
|
||||||
|
err.span_label(span, best_fail_msg);
|
||||||
|
if let Some(sp) = def_span {
|
||||||
|
if cx.source_map().span_to_filename(sp).is_real() && !sp.is_dummy() {
|
||||||
|
err.span_label(sp, "when calling this macro");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check whether there's a missing comma in this macro call, like `println!("{}" a);`
|
// Check whether there's a missing comma in this macro call, like `println!("{}" a);`
|
||||||
if let Some((arg, comma_span)) = arg.add_comma() {
|
if let Some((arg, comma_span)) = arg.add_comma() {
|
||||||
|
@ -189,7 +200,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
|
||||||
};
|
};
|
||||||
match TokenTree::parse(cx, lhs_tt, arg.clone()) {
|
match TokenTree::parse(cx, lhs_tt, arg.clone()) {
|
||||||
Success(_) => {
|
Success(_) => {
|
||||||
if comma_span == DUMMY_SP {
|
if comma_span.is_dummy() {
|
||||||
err.note("you might be missing a comma");
|
err.note("you might be missing a comma");
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion_short_with_applicability(
|
err.span_suggestion_short_with_applicability(
|
||||||
|
|
|
@ -38,7 +38,8 @@ impl TTMacroExpander for Expander {
|
||||||
fn expand<'cx>(&self,
|
fn expand<'cx>(&self,
|
||||||
ecx: &'cx mut ExtCtxt,
|
ecx: &'cx mut ExtCtxt,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
_: TokenStream) -> Box<MacResult+'cx> {
|
_: TokenStream,
|
||||||
|
_: Option<Span>) -> Box<MacResult+'cx> {
|
||||||
let args = self.args.iter().map(|i| pprust::meta_list_item_to_string(i))
|
let args = self.args.iter().map(|i| pprust::meta_list_item_to_string(i))
|
||||||
.collect::<Vec<_>>().join(", ");
|
.collect::<Vec<_>>().join(", ");
|
||||||
MacEager::expr(ecx.expr_str(sp, Symbol::intern(&args)))
|
MacEager::expr(ecx.expr_str(sp, Symbol::intern(&args)))
|
||||||
|
|
|
@ -2,13 +2,13 @@ error: no rules expected the token `r#async`
|
||||||
--> $DIR/edition-keywords-2015-2015-parsing.rs:22:31
|
--> $DIR/edition-keywords-2015-2015-parsing.rs:22:31
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
||||||
| ^^^^^^^
|
| ^^^^^^^ no rules expected the token `r#async`
|
||||||
|
|
||||||
error: no rules expected the token `async`
|
error: no rules expected the token `async`
|
||||||
--> $DIR/edition-keywords-2015-2015-parsing.rs:23:35
|
--> $DIR/edition-keywords-2015-2015-parsing.rs:23:35
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
||||||
| ^^^^^
|
| ^^^^^ no rules expected the token `async`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@ error: no rules expected the token `r#async`
|
||||||
--> $DIR/edition-keywords-2015-2018-parsing.rs:22:31
|
--> $DIR/edition-keywords-2015-2018-parsing.rs:22:31
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
||||||
| ^^^^^^^
|
| ^^^^^^^ no rules expected the token `r#async`
|
||||||
|
|
||||||
error: no rules expected the token `async`
|
error: no rules expected the token `async`
|
||||||
--> $DIR/edition-keywords-2015-2018-parsing.rs:23:35
|
--> $DIR/edition-keywords-2015-2018-parsing.rs:23:35
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
||||||
| ^^^^^
|
| ^^^^^ no rules expected the token `async`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,13 @@ error: no rules expected the token `r#async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:22:31
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:22:31
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
||||||
| ^^^^^^^
|
| ^^^^^^^ no rules expected the token `r#async`
|
||||||
|
|
||||||
error: no rules expected the token `async`
|
error: no rules expected the token `async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:23:35
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:23:35
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
||||||
| ^^^^^
|
| ^^^^^ no rules expected the token `async`
|
||||||
|
|
||||||
error: expected one of `move`, `|`, or `||`, found `<eof>`
|
error: expected one of `move`, `|`, or `||`, found `<eof>`
|
||||||
--> <::edition_kw_macro_2015::passes_ident macros>:1:22
|
--> <::edition_kw_macro_2015::passes_ident macros>:1:22
|
||||||
|
|
|
@ -14,13 +14,13 @@ error: no rules expected the token `r#async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:22:31
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:22:31
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
|
||||||
| ^^^^^^^
|
| ^^^^^^^ no rules expected the token `r#async`
|
||||||
|
|
||||||
error: no rules expected the token `async`
|
error: no rules expected the token `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:23:35
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:23:35
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
||||||
| ^^^^^
|
| ^^^^^ no rules expected the token `async`
|
||||||
|
|
||||||
error: expected one of `move`, `|`, or `||`, found `<eof>`
|
error: expected one of `move`, `|`, or `||`, found `<eof>`
|
||||||
--> <::edition_kw_macro_2018::passes_ident macros>:1:22
|
--> <::edition_kw_macro_2018::passes_ident macros>:1:22
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
error: unexpected end of macro invocation
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/empty-comment.rs:20:5
|
--> $DIR/empty-comment.rs:20:5
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! one_arg_macro {
|
||||||
|
LL | | ($fmt:expr) => (print!(concat!($fmt, "/n")));
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | one_arg_macro!(/**/); //~ ERROR unexpected end
|
LL | one_arg_macro!(/**/); //~ ERROR unexpected end
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ error: no rules expected the token `@`
|
||||||
--> $DIR/fail-simple.rs:12:12
|
--> $DIR/fail-simple.rs:12:12
|
||||||
|
|
|
|
||||||
LL | panic!(@); //~ ERROR no rules expected the token `@`
|
LL | panic!(@); //~ ERROR no rules expected the token `@`
|
||||||
| ^
|
| ^ no rules expected the token `@`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
error: unexpected end of macro invocation
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/issue-7970a.rs:16:5
|
--> $DIR/issue-7970a.rs:16:5
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! one_arg_macro {
|
||||||
|
LL | | ($fmt:expr) => (print!(concat!($fmt, "/n")));
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | one_arg_macro!();
|
LL | one_arg_macro!();
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -51,20 +51,41 @@ LL | ($(a)?*) => {}
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:41:11
|
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:41:11
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($(a)?) => {}
|
||||||
|
LL | | //~^ERROR using the `?` macro Kleene operator for
|
||||||
|
LL | | //~|ERROR expected `*` or `+`
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a?); //~ ERROR no rules expected the token `?`
|
LL | foo!(a?); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:42:11
|
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:42:11
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($(a)?) => {}
|
||||||
|
LL | | //~^ERROR using the `?` macro Kleene operator for
|
||||||
|
LL | | //~|ERROR expected `*` or `+`
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a?a); //~ ERROR no rules expected the token `?`
|
LL | foo!(a?a); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:43:11
|
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:43:11
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($(a)?) => {}
|
||||||
|
LL | | //~^ERROR using the `?` macro Kleene operator for
|
||||||
|
LL | | //~|ERROR expected `*` or `+`
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
|
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,68 +7,123 @@ LL | ($(a),?) => {} //~ERROR the `?` macro repetition operator
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:36:11
|
--> $DIR/macro-at-most-once-rep-2018.rs:36:11
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($(a)?) => {}
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a?); //~ ERROR no rules expected the token `?`
|
LL | foo!(a?); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:37:11
|
--> $DIR/macro-at-most-once-rep-2018.rs:37:11
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($(a)?) => {}
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a?a); //~ ERROR no rules expected the token `?`
|
LL | foo!(a?a); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:38:11
|
--> $DIR/macro-at-most-once-rep-2018.rs:38:11
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($(a)?) => {}
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
|
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: unexpected end of macro invocation
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:40:5
|
--> $DIR/macro-at-most-once-rep-2018.rs:40:5
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barplus {
|
||||||
|
LL | | ($(a)?+) => {} // ok. matches "a+" and "+"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barplus!(); //~ERROR unexpected end of macro invocation
|
LL | barplus!(); //~ERROR unexpected end of macro invocation
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^ unexpected end of macro invocation
|
||||||
|
|
||||||
error: unexpected end of macro invocation
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:41:14
|
--> $DIR/macro-at-most-once-rep-2018.rs:41:14
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barplus {
|
||||||
|
LL | | ($(a)?+) => {} // ok. matches "a+" and "+"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barplus!(a); //~ERROR unexpected end of macro invocation
|
LL | barplus!(a); //~ERROR unexpected end of macro invocation
|
||||||
| ^
|
| ^ unexpected end of macro invocation
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:42:15
|
--> $DIR/macro-at-most-once-rep-2018.rs:42:15
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barplus {
|
||||||
|
LL | | ($(a)?+) => {} // ok. matches "a+" and "+"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barplus!(a?); //~ ERROR no rules expected the token `?`
|
LL | barplus!(a?); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:43:15
|
--> $DIR/macro-at-most-once-rep-2018.rs:43:15
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barplus {
|
||||||
|
LL | | ($(a)?+) => {} // ok. matches "a+" and "+"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barplus!(a?a); //~ ERROR no rules expected the token `?`
|
LL | barplus!(a?a); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: unexpected end of macro invocation
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:47:5
|
--> $DIR/macro-at-most-once-rep-2018.rs:47:5
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barstar {
|
||||||
|
LL | | ($(a)?*) => {} // ok. matches "a*" and "*"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barstar!(); //~ERROR unexpected end of macro invocation
|
LL | barstar!(); //~ERROR unexpected end of macro invocation
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^ unexpected end of macro invocation
|
||||||
|
|
||||||
error: unexpected end of macro invocation
|
error: unexpected end of macro invocation
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:48:14
|
--> $DIR/macro-at-most-once-rep-2018.rs:48:14
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barstar {
|
||||||
|
LL | | ($(a)?*) => {} // ok. matches "a*" and "*"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barstar!(a); //~ERROR unexpected end of macro invocation
|
LL | barstar!(a); //~ERROR unexpected end of macro invocation
|
||||||
| ^
|
| ^ unexpected end of macro invocation
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:49:15
|
--> $DIR/macro-at-most-once-rep-2018.rs:49:15
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barstar {
|
||||||
|
LL | | ($(a)?*) => {} // ok. matches "a*" and "*"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barstar!(a?); //~ ERROR no rules expected the token `?`
|
LL | barstar!(a?); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: no rules expected the token `?`
|
error: no rules expected the token `?`
|
||||||
--> $DIR/macro-at-most-once-rep-2018.rs:50:15
|
--> $DIR/macro-at-most-once-rep-2018.rs:50:15
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! barstar {
|
||||||
|
LL | | ($(a)?*) => {} // ok. matches "a*" and "*"
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | barstar!(a?a); //~ ERROR no rules expected the token `?`
|
LL | barstar!(a?a); //~ ERROR no rules expected the token `?`
|
||||||
| ^
|
| ^ no rules expected the token `?`
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
error: no rules expected the token `a`
|
error: no rules expected the token `a`
|
||||||
--> $DIR/macro-non-lifetime.rs:18:8
|
--> $DIR/macro-non-lifetime.rs:18:8
|
||||||
|
|
|
|
||||||
|
LL | macro_rules! m { ($x:lifetime) => { } }
|
||||||
|
| --------------------------------------- when calling this macro
|
||||||
|
...
|
||||||
LL | m!(a);
|
LL | m!(a);
|
||||||
| ^
|
| ^ no rules expected the token `a`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,32 +7,68 @@ LL | println!("{}" a);
|
||||||
error: no rules expected the token `b`
|
error: no rules expected the token `b`
|
||||||
--> $DIR/missing-comma.rs:22:12
|
--> $DIR/missing-comma.rs:22:12
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($a:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a b);
|
LL | foo!(a b);
|
||||||
| -^
|
| -^ no rules expected the token `b`
|
||||||
| |
|
| |
|
||||||
| help: missing comma here
|
| help: missing comma here
|
||||||
|
|
||||||
error: no rules expected the token `e`
|
error: no rules expected the token `e`
|
||||||
--> $DIR/missing-comma.rs:24:21
|
--> $DIR/missing-comma.rs:24:21
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($a:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a, b, c, d e);
|
LL | foo!(a, b, c, d e);
|
||||||
| -^
|
| -^ no rules expected the token `e`
|
||||||
| |
|
| |
|
||||||
| help: missing comma here
|
| help: missing comma here
|
||||||
|
|
||||||
error: no rules expected the token `d`
|
error: no rules expected the token `d`
|
||||||
--> $DIR/missing-comma.rs:26:18
|
--> $DIR/missing-comma.rs:26:18
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($a:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a, b, c d, e);
|
LL | foo!(a, b, c d, e);
|
||||||
| -^
|
| -^ no rules expected the token `d`
|
||||||
| |
|
| |
|
||||||
| help: missing comma here
|
| help: missing comma here
|
||||||
|
|
||||||
error: no rules expected the token `d`
|
error: no rules expected the token `d`
|
||||||
--> $DIR/missing-comma.rs:28:18
|
--> $DIR/missing-comma.rs:28:18
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! foo {
|
||||||
|
LL | | ($a:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
|
||||||
|
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | foo!(a, b, c d e);
|
LL | foo!(a, b, c d e);
|
||||||
| ^
|
| ^ no rules expected the token `d`
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ error: no rules expected the token `enum E { }`
|
||||||
--> $DIR/nonterminal-matching.rs:29:10
|
--> $DIR/nonterminal-matching.rs:29:10
|
||||||
|
|
|
|
||||||
LL | n!(a $nt_item b); //~ ERROR no rules expected the token `enum E { }`
|
LL | n!(a $nt_item b); //~ ERROR no rules expected the token `enum E { }`
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ no rules expected the token `enum E { }`
|
||||||
...
|
...
|
||||||
LL | complex_nonterminal!(enum E {});
|
LL | complex_nonterminal!(enum E {});
|
||||||
| -------------------------------- in this macro invocation
|
| -------------------------------- in this macro invocation
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
error: no rules expected the token `bcd`
|
error: no rules expected the token `bcd`
|
||||||
--> $DIR/trace_faulty_macros.rs:17:26
|
--> $DIR/trace_faulty_macros.rs:17:26
|
||||||
|
|
|
|
||||||
LL | my_faulty_macro!(bcd); //~ ERROR no rules
|
LL | / macro_rules! my_faulty_macro {
|
||||||
| ^^^
|
LL | | () => {
|
||||||
|
LL | | my_faulty_macro!(bcd); //~ ERROR no rules
|
||||||
|
| | ^^^ no rules expected the token `bcd`
|
||||||
|
LL | | };
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
...
|
...
|
||||||
LL | my_faulty_macro!();
|
LL | my_faulty_macro!();
|
||||||
| ------------------- in this macro invocation
|
| ------------------- in this macro invocation
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
error: no rules expected the token `!`
|
error: no rules expected the token `!`
|
||||||
--> $DIR/macro-doc-comments-1.rs:16:5
|
--> $DIR/macro-doc-comments-1.rs:16:5
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! outer {
|
||||||
|
LL | | (#[$outer:meta]) => ()
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | //! Inner
|
LL | //! Inner
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ no rules expected the token `!`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
error: no rules expected the token `[`
|
error: no rules expected the token `[`
|
||||||
--> $DIR/macro-doc-comments-2.rs:16:5
|
--> $DIR/macro-doc-comments-2.rs:16:5
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! inner {
|
||||||
|
LL | | (#![$inner:meta]) => ()
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | /// Outer
|
LL | /// Outer
|
||||||
| ^
|
| ^ no rules expected the token `[`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
error: no rules expected the token `_`
|
error: no rules expected the token `_`
|
||||||
--> $DIR/underscore-ident-matcher.rs:18:19
|
--> $DIR/underscore-ident-matcher.rs:18:19
|
||||||
|
|
|
|
||||||
|
LL | / macro_rules! identity {
|
||||||
|
LL | | ($i: ident) => (
|
||||||
|
LL | | $i
|
||||||
|
LL | | )
|
||||||
|
LL | | }
|
||||||
|
| |_- when calling this macro
|
||||||
|
...
|
||||||
LL | let identity!(_) = 10; //~ ERROR no rules expected the token `_`
|
LL | let identity!(_) = 10; //~ ERROR no rules expected the token `_`
|
||||||
| ^
|
| ^ no rules expected the token `_`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ error: no rules expected the token `,`
|
||||||
--> $DIR/vec-macro-with-comma-only.rs:12:10
|
--> $DIR/vec-macro-with-comma-only.rs:12:10
|
||||||
|
|
|
|
||||||
LL | vec![,]; //~ ERROR no rules expected the token `,`
|
LL | vec![,]; //~ ERROR no rules expected the token `,`
|
||||||
| ^
|
| ^ no rules expected the token `,`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue