From 8544db0faa9e0f7a70323ad5f3e75358bba6820d Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 23 Oct 2018 10:07:11 -0700 Subject: Add macro call span when lacking any other span in diagnostic --- src/libsyntax/ext/tt/macro_rules.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 87ade278c68..b70a7989275 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -50,7 +50,12 @@ pub struct ParserAnyMacro<'a> { impl<'a> ParserAnyMacro<'a> { pub fn make(mut self: Box>, kind: AstFragmentKind) -> AstFragment { let ParserAnyMacro { site_span, macro_ident, ref mut parser } = *self; - let fragment = panictry!(parser.parse_ast_fragment(kind, true)); + let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| { + if e.span.is_dummy() { // Get around lack of span in error (#30128) + e.set_span(site_span); + } + e + })); // We allow semicolons at the end of expressions -- e.g. the semicolon in // `macro_rules! m { () => { panic!(); } }` isn't parsed by `.parse_expr()`, -- cgit 1.4.1-3-g733a5 From ad144ac3c1da0d4a25d8ca95113ac6f29bc0fce5 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 23 Oct 2018 10:07:34 -0700 Subject: Modify invalid macro in expression context diagnostic --- src/libsyntax/ext/expand.rs | 24 +++++++++++++++--- src/test/ui/issues/issue-30007.stderr | 9 +++---- src/test/ui/macros/macro-context.stderr | 29 +++++++++++----------- .../ui/macros/macro-in-expression-context.fixed | 15 +++++++++++ src/test/ui/macros/macro-in-expression-context.rs | 15 +++++++++++ .../ui/macros/macro-in-expression-context.stderr | 15 +++++++++++ .../ui/parser/macro/macro-incomplete-parse.stderr | 18 ++++++-------- 7 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 src/test/ui/macros/macro-in-expression-context.fixed create mode 100644 src/test/ui/macros/macro-in-expression-context.rs create mode 100644 src/test/ui/macros/macro-in-expression-context.stderr (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 9e06384f5a8..436e0b53a76 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1036,10 +1036,26 @@ impl<'a> Parser<'a> { // Avoid emitting backtrace info twice. let def_site_span = self.span.with_ctxt(SyntaxContext::empty()); let mut err = self.diagnostic().struct_span_err(def_site_span, &msg); - let msg = format!("caused by the macro expansion here; the usage \ - of `{}!` is likely invalid in {} context", - macro_path, kind_name); - err.span_note(span, &msg).emit(); + err.span_label(span, "caused by the macro expansion here"); + let msg = format!( + "the usage of `{}!` is likely invalid in {} context", + macro_path, + kind_name, + ); + err.note(&msg); + let semi_span = self.sess.source_map().next_point(span); + match self.sess.source_map().span_to_snippet(semi_span) { + Ok(ref snippet) if &snippet[..] != ";" && kind_name == "expression" => { + err.span_suggestion_with_applicability( + semi_span, + "you might be missing a semicolon here", + ";".to_owned(), + Applicability::MaybeIncorrect, + ); + } + _ => {} + } + err.emit(); } } } diff --git a/src/test/ui/issues/issue-30007.stderr b/src/test/ui/issues/issue-30007.stderr index a467ff6dd0a..028ed048d65 100644 --- a/src/test/ui/issues/issue-30007.stderr +++ b/src/test/ui/issues/issue-30007.stderr @@ -3,12 +3,11 @@ error: macro expansion ignores token `;` and any following | LL | () => ( String ; ); //~ ERROR macro expansion ignores token `;` | ^ - | -note: caused by the macro expansion here; the usage of `t!` is likely invalid in type context - --> $DIR/issue-30007.rs:16:16 - | +... LL | let i: Vec; - | ^^^^ + | ---- caused by the macro expansion here + | + = note: the usage of `t!` is likely invalid in type context error: aborting due to previous error diff --git a/src/test/ui/macros/macro-context.stderr b/src/test/ui/macros/macro-context.stderr index b3e67fb2607..5ea7825080c 100644 --- a/src/test/ui/macros/macro-context.stderr +++ b/src/test/ui/macros/macro-context.stderr @@ -3,36 +3,35 @@ error: macro expansion ignores token `;` and any following | LL | () => ( i ; typeof ); //~ ERROR expected expression, found reserved keyword `typeof` | ^ - | -note: caused by the macro expansion here; the usage of `m!` is likely invalid in type context - --> $DIR/macro-context.rs:20:12 - | +... LL | let a: m!(); - | ^^^^ + | ---- caused by the macro expansion here + | + = note: the usage of `m!` is likely invalid in type context error: macro expansion ignores token `typeof` and any following --> $DIR/macro-context.rs:13:17 | LL | () => ( i ; typeof ); //~ ERROR expected expression, found reserved keyword `typeof` | ^^^^^^ - | -note: caused by the macro expansion here; the usage of `m!` is likely invalid in expression context - --> $DIR/macro-context.rs:21:13 - | +... LL | let i = m!(); - | ^^^^ + | ----- help: you might be missing a semicolon here: `;` + | | + | caused by the macro expansion here + | + = note: the usage of `m!` is likely invalid in expression context error: macro expansion ignores token `;` and any following --> $DIR/macro-context.rs:13:15 | LL | () => ( i ; typeof ); //~ ERROR expected expression, found reserved keyword `typeof` | ^ - | -note: caused by the macro expansion here; the usage of `m!` is likely invalid in pattern context - --> $DIR/macro-context.rs:23:9 - | +... LL | m!() => {} - | ^^^^ + | ---- caused by the macro expansion here + | + = note: the usage of `m!` is likely invalid in pattern context error: expected expression, found reserved keyword `typeof` --> $DIR/macro-context.rs:13:17 diff --git a/src/test/ui/macros/macro-in-expression-context.fixed b/src/test/ui/macros/macro-in-expression-context.fixed new file mode 100644 index 00000000000..df36db0f49e --- /dev/null +++ b/src/test/ui/macros/macro-in-expression-context.fixed @@ -0,0 +1,15 @@ +// run-rustfix + +macro_rules! foo { + () => { + assert_eq!("A", "A"); + assert_eq!("B", "B"); + } + //~^^ ERROR macro expansion ignores token `assert_eq` and any following + //~| NOTE the usage of `foo!` is likely invalid in expression context +} + +fn main() { + foo!(); + //~^ NOTE caused by the macro expansion here +} diff --git a/src/test/ui/macros/macro-in-expression-context.rs b/src/test/ui/macros/macro-in-expression-context.rs new file mode 100644 index 00000000000..b3f5e568967 --- /dev/null +++ b/src/test/ui/macros/macro-in-expression-context.rs @@ -0,0 +1,15 @@ +// run-rustfix + +macro_rules! foo { + () => { + assert_eq!("A", "A"); + assert_eq!("B", "B"); + } + //~^^ ERROR macro expansion ignores token `assert_eq` and any following + //~| NOTE the usage of `foo!` is likely invalid in expression context +} + +fn main() { + foo!() + //~^ NOTE caused by the macro expansion here +} diff --git a/src/test/ui/macros/macro-in-expression-context.stderr b/src/test/ui/macros/macro-in-expression-context.stderr new file mode 100644 index 00000000000..d27d6fbaef7 --- /dev/null +++ b/src/test/ui/macros/macro-in-expression-context.stderr @@ -0,0 +1,15 @@ +error: macro expansion ignores token `assert_eq` and any following + --> $DIR/macro-in-expression-context.rs:6:9 + | +LL | assert_eq!("B", "B"); + | ^^^^^^^^^ +... +LL | foo!() + | ------- help: you might be missing a semicolon here: `;` + | | + | caused by the macro expansion here + | + = note: the usage of `foo!` is likely invalid in expression context + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/macro-incomplete-parse.stderr b/src/test/ui/parser/macro/macro-incomplete-parse.stderr index 198730dc07a..806aca511d0 100644 --- a/src/test/ui/parser/macro/macro-incomplete-parse.stderr +++ b/src/test/ui/parser/macro/macro-incomplete-parse.stderr @@ -3,12 +3,11 @@ error: macro expansion ignores token `,` and any following | LL | , //~ ERROR macro expansion ignores token `,` | ^ - | -note: caused by the macro expansion here; the usage of `ignored_item!` is likely invalid in item context - --> $DIR/macro-incomplete-parse.rs:31:1 - | +... LL | ignored_item!(); - | ^^^^^^^^^^^^^^^^ + | ---------------- caused by the macro expansion here + | + = note: the usage of `ignored_item!` is likely invalid in item context error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` --> $DIR/macro-incomplete-parse.rs:22:14 @@ -24,12 +23,11 @@ error: macro expansion ignores token `,` and any following | LL | () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` | ^ - | -note: caused by the macro expansion here; the usage of `ignored_pat!` is likely invalid in pattern context - --> $DIR/macro-incomplete-parse.rs:36:9 - | +... LL | ignored_pat!() => (), - | ^^^^^^^^^^^^^^ + | -------------- caused by the macro expansion here + | + = note: the usage of `ignored_pat!` is likely invalid in pattern context error: aborting due to 3 previous errors -- cgit 1.4.1-3-g733a5 From 8227a938a4970008ec333f6cd66be9d4be0e981c Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 23 Oct 2018 17:18:14 -0700 Subject: Point at macro definition when no rules expect token --- src/libsyntax/ext/base.rs | 18 +++- src/libsyntax/ext/expand.rs | 9 +- src/libsyntax/ext/tt/macro_rules.rs | 25 ++++-- .../run-pass-fulldeps/auxiliary/plugin_args.rs | 3 +- .../edition-keywords-2015-2015-parsing.stderr | 4 +- .../edition-keywords-2015-2018-parsing.stderr | 4 +- .../edition-keywords-2018-2015-parsing.stderr | 4 +- .../edition-keywords-2018-2018-parsing.stderr | 4 +- src/test/ui/empty/empty-comment.stderr | 9 +- src/test/ui/fail-simple.stderr | 2 +- src/test/ui/issues/issue-7970a.stderr | 9 +- ...macro-at-most-once-rep-2018-feature-gate.stderr | 33 ++++++-- .../ui/macros/macro-at-most-once-rep-2018.stderr | 99 +++++++++++++++++----- src/test/ui/macros/macro-non-lifetime.stderr | 5 +- src/test/ui/macros/missing-comma.stderr | 64 +++++++++++--- src/test/ui/macros/nonterminal-matching.stderr | 2 +- src/test/ui/macros/trace_faulty_macros.stderr | 13 ++- .../ui/parser/macro/macro-doc-comments-1.stderr | 9 +- .../ui/parser/macro/macro-doc-comments-2.stderr | 9 +- src/test/ui/underscore-ident-matcher.stderr | 11 ++- src/test/ui/vec/vec-macro-with-comma-only.stderr | 2 +- 21 files changed, 256 insertions(+), 82 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 5bf1a7dd663..1701c8da2c5 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -247,8 +247,13 @@ impl AttrProcMacro for F /// Represents a thing that maps token trees to Macro Results pub trait TTMacroExpander { - fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, span: Span, input: TokenStream) - -> Box; + fn expand<'cx>( + &self, + ecx: &'cx mut ExtCtxt, + span: Span, + input: TokenStream, + def_span: Option, + ) -> Box; } pub type MacroExpanderFn = @@ -259,8 +264,13 @@ impl TTMacroExpander for F where F: for<'cx> Fn(&'cx mut ExtCtxt, Span, &[tokenstream::TokenTree]) -> Box { - fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, span: Span, input: TokenStream) - -> Box { + fn expand<'cx>( + &self, + ecx: &'cx mut ExtCtxt, + span: Span, + input: TokenStream, + _def_span: Option, + ) -> Box { struct AvoidInterpolatedIdents; impl Folder for AvoidInterpolatedIdents { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 9e06384f5a8..46ffdf4eba2 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -764,7 +764,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { edition) { dummy_span } 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) { dummy_span } 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), + )) } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 87ade278c68..41e8cbe5502 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -74,16 +74,19 @@ struct MacroRulesMacroExpander { } impl TTMacroExpander for MacroRulesMacroExpander { - fn expand<'cx>(&self, - cx: &'cx mut ExtCtxt, - sp: Span, - input: TokenStream) - -> Box { + fn expand<'cx>( + &self, + cx: &'cx mut ExtCtxt, + sp: Span, + input: TokenStream, + def_span: Option, + ) -> Box { if !self.valid { return DummyResult::any(sp); } generic_extension(cx, sp, + def_span, self.name, input, &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 fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, sp: Span, + def_span: Option, name: ast::Ident, arg: TokenStream, 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 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);` 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()) { Success(_) => { - if comma_span == DUMMY_SP { + if comma_span.is_dummy() { err.note("you might be missing a comma"); } else { err.span_suggestion_short_with_applicability( diff --git a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs index ac39118c5f1..27169299c8a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs +++ b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs @@ -38,7 +38,8 @@ impl TTMacroExpander for Expander { fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, sp: Span, - _: TokenStream) -> Box { + _: TokenStream, + _: Option) -> Box { let args = self.args.iter().map(|i| pprust::meta_list_item_to_string(i)) .collect::>().join(", "); MacEager::expr(ecx.expr_str(sp, Symbol::intern(&args))) diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr index a629d13e6c3..e8f05cbb0ef 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr @@ -2,13 +2,13 @@ error: no rules expected the token `r#async` --> $DIR/edition-keywords-2015-2015-parsing.rs:22:31 | 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` --> $DIR/edition-keywords-2015-2015-parsing.rs:23:35 | 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 diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr index ab8a34a4a9e..3f5e1137383 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr @@ -2,13 +2,13 @@ error: no rules expected the token `r#async` --> $DIR/edition-keywords-2015-2018-parsing.rs:22:31 | 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` --> $DIR/edition-keywords-2015-2018-parsing.rs:23:35 | 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 diff --git a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr index 5955410aa10..b6ff60f1492 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -14,13 +14,13 @@ error: no rules expected the token `r#async` --> $DIR/edition-keywords-2018-2015-parsing.rs:22:31 | 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` --> $DIR/edition-keywords-2018-2015-parsing.rs:23:35 | 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 `` --> <::edition_kw_macro_2015::passes_ident macros>:1:22 diff --git a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr index 6ea736828f9..ffe666a7e64 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -14,13 +14,13 @@ error: no rules expected the token `r#async` --> $DIR/edition-keywords-2018-2018-parsing.rs:22:31 | 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` --> $DIR/edition-keywords-2018-2018-parsing.rs:23:35 | 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 `` --> <::edition_kw_macro_2018::passes_ident macros>:1:22 diff --git a/src/test/ui/empty/empty-comment.stderr b/src/test/ui/empty/empty-comment.stderr index d6990c4eaeb..e15f347f49d 100644 --- a/src/test/ui/empty/empty-comment.stderr +++ b/src/test/ui/empty/empty-comment.stderr @@ -1,8 +1,13 @@ error: unexpected end of macro invocation --> $DIR/empty-comment.rs:20:5 | -LL | one_arg_macro!(/**/); //~ ERROR unexpected end - | ^^^^^^^^^^^^^^^^^^^^^ +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 + | ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation error: aborting due to previous error diff --git a/src/test/ui/fail-simple.stderr b/src/test/ui/fail-simple.stderr index 764f2c464bc..4a4aec5b6ac 100644 --- a/src/test/ui/fail-simple.stderr +++ b/src/test/ui/fail-simple.stderr @@ -2,7 +2,7 @@ error: no rules expected the token `@` --> $DIR/fail-simple.rs:12:12 | LL | panic!(@); //~ ERROR no rules expected the token `@` - | ^ + | ^ no rules expected the token `@` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-7970a.stderr b/src/test/ui/issues/issue-7970a.stderr index 7ad95717185..94beebf514e 100644 --- a/src/test/ui/issues/issue-7970a.stderr +++ b/src/test/ui/issues/issue-7970a.stderr @@ -1,8 +1,13 @@ error: unexpected end of macro invocation --> $DIR/issue-7970a.rs:16:5 | -LL | one_arg_macro!(); - | ^^^^^^^^^^^^^^^^^ +LL | / macro_rules! one_arg_macro { +LL | | ($fmt:expr) => (print!(concat!($fmt, "/n"))); +LL | | } + | |_- when calling this macro +... +LL | one_arg_macro!(); + | ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation error: aborting due to previous error diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr index 22f1c94fced..6f77eb63439 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr @@ -51,20 +51,41 @@ LL | ($(a)?*) => {} error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:41:11 | -LL | foo!(a?); //~ ERROR no rules expected the token `?` - | ^ +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 `?` + | ^ no rules expected the token `?` error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:42:11 | -LL | foo!(a?a); //~ ERROR no rules expected the token `?` - | ^ +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 `?` + | ^ no rules expected the token `?` error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:43:11 | -LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` - | ^ +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 `?` + | ^ no rules expected the token `?` error: aborting due to 10 previous errors diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr index 0a15bdb1068..3bdfae5ccdf 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr @@ -7,68 +7,123 @@ LL | ($(a),?) => {} //~ERROR the `?` macro repetition operator error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:36:11 | -LL | foo!(a?); //~ ERROR no rules expected the token `?` - | ^ +LL | / macro_rules! foo { +LL | | ($(a)?) => {} +LL | | } + | |_- when calling this macro +... +LL | foo!(a?); //~ ERROR no rules expected the token `?` + | ^ no rules expected the token `?` error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:37:11 | -LL | foo!(a?a); //~ ERROR no rules expected the token `?` - | ^ +LL | / macro_rules! foo { +LL | | ($(a)?) => {} +LL | | } + | |_- when calling this macro +... +LL | foo!(a?a); //~ ERROR no rules expected the token `?` + | ^ no rules expected the token `?` error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:38:11 | -LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` - | ^ +LL | / macro_rules! foo { +LL | | ($(a)?) => {} +LL | | } + | |_- when calling this macro +... +LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` + | ^ no rules expected the token `?` error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:40:5 | -LL | barplus!(); //~ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ +LL | / macro_rules! barplus { +LL | | ($(a)?+) => {} // ok. matches "a+" and "+" +LL | | } + | |_- when calling this macro +... +LL | barplus!(); //~ERROR unexpected end of macro invocation + | ^^^^^^^^^^^ unexpected end of macro invocation error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:41:14 | -LL | barplus!(a); //~ERROR unexpected end of macro invocation - | ^ +LL | / macro_rules! barplus { +LL | | ($(a)?+) => {} // ok. matches "a+" and "+" +LL | | } + | |_- when calling this macro +... +LL | barplus!(a); //~ERROR unexpected end of macro invocation + | ^ unexpected end of macro invocation error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:42:15 | -LL | barplus!(a?); //~ ERROR no rules expected the token `?` - | ^ +LL | / macro_rules! barplus { +LL | | ($(a)?+) => {} // ok. matches "a+" and "+" +LL | | } + | |_- when calling this macro +... +LL | barplus!(a?); //~ ERROR no rules expected the token `?` + | ^ no rules expected the token `?` error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:43:15 | -LL | barplus!(a?a); //~ ERROR no rules expected the token `?` - | ^ +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 `?` + | ^ no rules expected the token `?` error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:47:5 | -LL | barstar!(); //~ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ +LL | / macro_rules! barstar { +LL | | ($(a)?*) => {} // ok. matches "a*" and "*" +LL | | } + | |_- when calling this macro +... +LL | barstar!(); //~ERROR unexpected end of macro invocation + | ^^^^^^^^^^^ unexpected end of macro invocation error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:48:14 | -LL | barstar!(a); //~ERROR unexpected end of macro invocation - | ^ +LL | / macro_rules! barstar { +LL | | ($(a)?*) => {} // ok. matches "a*" and "*" +LL | | } + | |_- when calling this macro +... +LL | barstar!(a); //~ERROR unexpected end of macro invocation + | ^ unexpected end of macro invocation error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:49:15 | -LL | barstar!(a?); //~ ERROR no rules expected the token `?` - | ^ +LL | / macro_rules! barstar { +LL | | ($(a)?*) => {} // ok. matches "a*" and "*" +LL | | } + | |_- when calling this macro +... +LL | barstar!(a?); //~ ERROR no rules expected the token `?` + | ^ no rules expected the token `?` error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:50:15 | -LL | barstar!(a?a); //~ ERROR no rules expected the token `?` - | ^ +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 `?` + | ^ no rules expected the token `?` error: aborting due to 12 previous errors diff --git a/src/test/ui/macros/macro-non-lifetime.stderr b/src/test/ui/macros/macro-non-lifetime.stderr index 93b7f481842..48a93010c3b 100644 --- a/src/test/ui/macros/macro-non-lifetime.stderr +++ b/src/test/ui/macros/macro-non-lifetime.stderr @@ -1,8 +1,11 @@ error: no rules expected the token `a` --> $DIR/macro-non-lifetime.rs:18:8 | +LL | macro_rules! m { ($x:lifetime) => { } } + | --------------------------------------- when calling this macro +... LL | m!(a); - | ^ + | ^ no rules expected the token `a` error: aborting due to previous error diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index 9d8de87e5bb..5548be86a13 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -7,32 +7,68 @@ LL | println!("{}" a); error: no rules expected the token `b` --> $DIR/missing-comma.rs:22:12 | -LL | foo!(a b); - | -^ - | | - | help: missing comma here +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); + | -^ no rules expected the token `b` + | | + | help: missing comma here error: no rules expected the token `e` --> $DIR/missing-comma.rs:24:21 | -LL | foo!(a, b, c, d e); - | -^ - | | - | help: missing comma here +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); + | -^ no rules expected the token `e` + | | + | help: missing comma here error: no rules expected the token `d` --> $DIR/missing-comma.rs:26:18 | -LL | foo!(a, b, c d, e); - | -^ - | | - | help: missing comma here +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); + | -^ no rules expected the token `d` + | | + | help: missing comma here error: no rules expected the token `d` --> $DIR/missing-comma.rs:28:18 | -LL | foo!(a, b, c d e); - | ^ +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); + | ^ no rules expected the token `d` error: aborting due to 5 previous errors diff --git a/src/test/ui/macros/nonterminal-matching.stderr b/src/test/ui/macros/nonterminal-matching.stderr index bf2221d52a4..23853978d37 100644 --- a/src/test/ui/macros/nonterminal-matching.stderr +++ b/src/test/ui/macros/nonterminal-matching.stderr @@ -2,7 +2,7 @@ error: no rules expected the token `enum E { }` --> $DIR/nonterminal-matching.rs:29:10 | 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 {}); | -------------------------------- in this macro invocation diff --git a/src/test/ui/macros/trace_faulty_macros.stderr b/src/test/ui/macros/trace_faulty_macros.stderr index a9ffef8ef80..ecc3694d120 100644 --- a/src/test/ui/macros/trace_faulty_macros.stderr +++ b/src/test/ui/macros/trace_faulty_macros.stderr @@ -1,11 +1,16 @@ error: no rules expected the token `bcd` --> $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!(); - | ------------------- in this macro invocation +LL | my_faulty_macro!(); + | ------------------- in this macro invocation note: trace_macro --> $DIR/trace_faulty_macros.rs:43:5 diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.stderr b/src/test/ui/parser/macro/macro-doc-comments-1.stderr index a7fdd28b0ca..4fcc56ac832 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-1.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-1.stderr @@ -1,8 +1,13 @@ error: no rules expected the token `!` --> $DIR/macro-doc-comments-1.rs:16:5 | -LL | //! Inner - | ^^^^^^^^^ +LL | / macro_rules! outer { +LL | | (#[$outer:meta]) => () +LL | | } + | |_- when calling this macro +... +LL | //! Inner + | ^^^^^^^^^ no rules expected the token `!` error: aborting due to previous error diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.stderr b/src/test/ui/parser/macro/macro-doc-comments-2.stderr index bae9823b9b2..b34e99fbd9e 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-2.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-2.stderr @@ -1,8 +1,13 @@ error: no rules expected the token `[` --> $DIR/macro-doc-comments-2.rs:16:5 | -LL | /// Outer - | ^ +LL | / macro_rules! inner { +LL | | (#![$inner:meta]) => () +LL | | } + | |_- when calling this macro +... +LL | /// Outer + | ^ no rules expected the token `[` error: aborting due to previous error diff --git a/src/test/ui/underscore-ident-matcher.stderr b/src/test/ui/underscore-ident-matcher.stderr index 7f2b6ac30b0..19d489db572 100644 --- a/src/test/ui/underscore-ident-matcher.stderr +++ b/src/test/ui/underscore-ident-matcher.stderr @@ -1,8 +1,15 @@ error: no rules expected the token `_` --> $DIR/underscore-ident-matcher.rs:18:19 | -LL | let identity!(_) = 10; //~ ERROR no rules expected the token `_` - | ^ +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 `_` + | ^ no rules expected the token `_` error: aborting due to previous error diff --git a/src/test/ui/vec/vec-macro-with-comma-only.stderr b/src/test/ui/vec/vec-macro-with-comma-only.stderr index f5341ccc312..856d85ef5cd 100644 --- a/src/test/ui/vec/vec-macro-with-comma-only.stderr +++ b/src/test/ui/vec/vec-macro-with-comma-only.stderr @@ -2,7 +2,7 @@ error: no rules expected the token `,` --> $DIR/vec-macro-with-comma-only.rs:12:10 | LL | vec![,]; //~ ERROR no rules expected the token `,` - | ^ + | ^ no rules expected the token `,` error: aborting due to previous error -- cgit 1.4.1-3-g733a5 From 1ab45ec7e366f6f16a6a3d0a58cacb0ee48ef406 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 24 Oct 2018 11:34:23 -0700 Subject: Point to macro def span instead of whole body --- src/libsyntax/ext/tt/macro_rules.rs | 2 +- src/test/ui/empty/empty-comment.stderr | 10 +- src/test/ui/issues/issue-7970a.stderr | 10 +- ...macro-at-most-once-rep-2018-feature-gate.stderr | 36 +++---- .../ui/macros/macro-at-most-once-rep-2018.stderr | 110 +++++++++------------ src/test/ui/macros/macro-non-lifetime.stderr | 2 +- src/test/ui/macros/missing-comma.stderr | 68 +++++-------- src/test/ui/macros/trace_faulty_macros.stderr | 16 ++- .../ui/parser/macro/macro-doc-comments-1.stderr | 10 +- .../ui/parser/macro/macro-doc-comments-2.stderr | 10 +- src/test/ui/underscore-ident-matcher.stderr | 12 +-- 11 files changed, 107 insertions(+), 179 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 41e8cbe5502..03fb89b21a4 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -187,7 +187,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, 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"); + err.span_label(cx.source_map().def_span(sp), "when calling this macro"); } } diff --git a/src/test/ui/empty/empty-comment.stderr b/src/test/ui/empty/empty-comment.stderr index e15f347f49d..de826102081 100644 --- a/src/test/ui/empty/empty-comment.stderr +++ b/src/test/ui/empty/empty-comment.stderr @@ -1,13 +1,11 @@ error: unexpected end of macro invocation --> $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 | macro_rules! one_arg_macro { + | -------------------------- when calling this macro ... -LL | one_arg_macro!(/**/); //~ ERROR unexpected end - | ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation +LL | one_arg_macro!(/**/); //~ ERROR unexpected end + | ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation error: aborting due to previous error diff --git a/src/test/ui/issues/issue-7970a.stderr b/src/test/ui/issues/issue-7970a.stderr index 94beebf514e..96fb374b58c 100644 --- a/src/test/ui/issues/issue-7970a.stderr +++ b/src/test/ui/issues/issue-7970a.stderr @@ -1,13 +1,11 @@ error: unexpected end of macro invocation --> $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 | macro_rules! one_arg_macro { + | -------------------------- when calling this macro ... -LL | one_arg_macro!(); - | ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation +LL | one_arg_macro!(); + | ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation error: aborting due to previous error diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr index 6f77eb63439..7705ba3b11e 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr @@ -51,41 +51,29 @@ LL | ($(a)?*) => {} error: no rules expected the token `?` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a?); //~ ERROR no rules expected the token `?` - | ^ 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 `?` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a?a); //~ ERROR no rules expected the token `?` - | ^ 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 `?` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` - | ^ 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 diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr index 3bdfae5ccdf..25dd66b81f5 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr @@ -7,123 +7,101 @@ LL | ($(a),?) => {} //~ERROR the `?` macro repetition operator error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:36:11 | -LL | / macro_rules! foo { -LL | | ($(a)?) => {} -LL | | } - | |_- when calling this macro +LL | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a?); //~ ERROR no rules expected the token `?` - | ^ 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 `?` --> $DIR/macro-at-most-once-rep-2018.rs:37:11 | -LL | / macro_rules! foo { -LL | | ($(a)?) => {} -LL | | } - | |_- when calling this macro +LL | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a?a); //~ ERROR no rules expected the token `?` - | ^ 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 `?` --> $DIR/macro-at-most-once-rep-2018.rs:38:11 | -LL | / macro_rules! foo { -LL | | ($(a)?) => {} -LL | | } - | |_- when calling this macro +LL | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` - | ^ 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 --> $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 | macro_rules! barplus { + | -------------------- when calling this macro ... -LL | barplus!(); //~ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ unexpected end of macro invocation +LL | barplus!(); //~ERROR unexpected end of macro invocation + | ^^^^^^^^^^^ unexpected end of macro invocation error: unexpected end of macro invocation --> $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 | macro_rules! barplus { + | -------------------- when calling this macro ... -LL | barplus!(a); //~ERROR unexpected end of macro invocation - | ^ 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 `?` --> $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 | macro_rules! barplus { + | -------------------- when calling this macro ... -LL | barplus!(a?); //~ ERROR no rules expected the token `?` - | ^ 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 `?` --> $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 | macro_rules! barplus { + | -------------------- when calling this macro ... -LL | barplus!(a?a); //~ ERROR no rules expected the token `?` - | ^ 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 --> $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 | macro_rules! barstar { + | -------------------- when calling this macro ... -LL | barstar!(); //~ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ unexpected end of macro invocation +LL | barstar!(); //~ERROR unexpected end of macro invocation + | ^^^^^^^^^^^ unexpected end of macro invocation error: unexpected end of macro invocation --> $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 | macro_rules! barstar { + | -------------------- when calling this macro ... -LL | barstar!(a); //~ERROR unexpected end of macro invocation - | ^ 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 `?` --> $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 | macro_rules! barstar { + | -------------------- when calling this macro ... -LL | barstar!(a?); //~ ERROR no rules expected the token `?` - | ^ 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 `?` --> $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 | macro_rules! barstar { + | -------------------- when calling this macro ... -LL | barstar!(a?a); //~ ERROR no rules expected the token `?` - | ^ 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 diff --git a/src/test/ui/macros/macro-non-lifetime.stderr b/src/test/ui/macros/macro-non-lifetime.stderr index 48a93010c3b..d526023d441 100644 --- a/src/test/ui/macros/macro-non-lifetime.stderr +++ b/src/test/ui/macros/macro-non-lifetime.stderr @@ -2,7 +2,7 @@ error: no rules expected the token `a` --> $DIR/macro-non-lifetime.rs:18:8 | LL | macro_rules! m { ($x:lifetime) => { } } - | --------------------------------------- when calling this macro + | -------------- when calling this macro ... LL | m!(a); | ^ no rules expected the token `a` diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index 5548be86a13..1d6af44bd08 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -7,68 +7,44 @@ LL | println!("{}" a); error: no rules expected the token `b` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a b); - | -^ no rules expected the token `b` - | | - | help: missing comma here +LL | foo!(a b); + | -^ no rules expected the token `b` + | | + | help: missing comma here error: no rules expected the token `e` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a, b, c, d e); - | -^ no rules expected the token `e` - | | - | help: missing comma here +LL | foo!(a, b, c, d e); + | -^ no rules expected the token `e` + | | + | help: missing comma here error: no rules expected the token `d` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a, b, c d, e); - | -^ no rules expected the token `d` - | | - | help: missing comma here +LL | foo!(a, b, c d, e); + | -^ no rules expected the token `d` + | | + | help: missing comma here error: no rules expected the token `d` --> $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 | macro_rules! foo { + | ---------------- when calling this macro ... -LL | foo!(a, b, c d e); - | ^ no rules expected the token `d` +LL | foo!(a, b, c d e); + | ^ no rules expected the token `d` error: aborting due to 5 previous errors diff --git a/src/test/ui/macros/trace_faulty_macros.stderr b/src/test/ui/macros/trace_faulty_macros.stderr index ecc3694d120..853eb5847c0 100644 --- a/src/test/ui/macros/trace_faulty_macros.stderr +++ b/src/test/ui/macros/trace_faulty_macros.stderr @@ -1,16 +1,14 @@ error: no rules expected the token `bcd` --> $DIR/trace_faulty_macros.rs:17:26 | -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 | macro_rules! my_faulty_macro { + | ---------------------------- when calling this macro +LL | () => { +LL | my_faulty_macro!(bcd); //~ ERROR no rules + | ^^^ no rules expected the token `bcd` ... -LL | my_faulty_macro!(); - | ------------------- in this macro invocation +LL | my_faulty_macro!(); + | ------------------- in this macro invocation note: trace_macro --> $DIR/trace_faulty_macros.rs:43:5 diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.stderr b/src/test/ui/parser/macro/macro-doc-comments-1.stderr index 4fcc56ac832..1e765dcde4f 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-1.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-1.stderr @@ -1,13 +1,11 @@ error: no rules expected the token `!` --> $DIR/macro-doc-comments-1.rs:16:5 | -LL | / macro_rules! outer { -LL | | (#[$outer:meta]) => () -LL | | } - | |_- when calling this macro +LL | macro_rules! outer { + | ------------------ when calling this macro ... -LL | //! Inner - | ^^^^^^^^^ no rules expected the token `!` +LL | //! Inner + | ^^^^^^^^^ no rules expected the token `!` error: aborting due to previous error diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.stderr b/src/test/ui/parser/macro/macro-doc-comments-2.stderr index b34e99fbd9e..0ab8a3cafb5 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-2.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-2.stderr @@ -1,13 +1,11 @@ error: no rules expected the token `[` --> $DIR/macro-doc-comments-2.rs:16:5 | -LL | / macro_rules! inner { -LL | | (#![$inner:meta]) => () -LL | | } - | |_- when calling this macro +LL | macro_rules! inner { + | ------------------ when calling this macro ... -LL | /// Outer - | ^ no rules expected the token `[` +LL | /// Outer + | ^ no rules expected the token `[` error: aborting due to previous error diff --git a/src/test/ui/underscore-ident-matcher.stderr b/src/test/ui/underscore-ident-matcher.stderr index 19d489db572..e148c48ed13 100644 --- a/src/test/ui/underscore-ident-matcher.stderr +++ b/src/test/ui/underscore-ident-matcher.stderr @@ -1,15 +1,11 @@ error: no rules expected the token `_` --> $DIR/underscore-ident-matcher.rs:18:19 | -LL | / macro_rules! identity { -LL | | ($i: ident) => ( -LL | | $i -LL | | ) -LL | | } - | |_- when calling this macro +LL | macro_rules! identity { + | --------------------- when calling this macro ... -LL | let identity!(_) = 10; //~ ERROR no rules expected the token `_` - | ^ 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 -- cgit 1.4.1-3-g733a5 From f8818cbf8fc30ac626b2a0a306736c1293257209 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 24 Oct 2018 12:52:24 -0700 Subject: Fix incorrect semicolon suggestion --- src/libsyntax/ext/expand.rs | 4 +++- src/test/ui/macros/macro-context.stderr | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 436e0b53a76..4deeb4a43d9 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1044,7 +1044,9 @@ impl<'a> Parser<'a> { ); err.note(&msg); let semi_span = self.sess.source_map().next_point(span); - match self.sess.source_map().span_to_snippet(semi_span) { + + let semi_full_span = semi_span.to(self.sess.source_map().next_point(semi_span)); + match self.sess.source_map().span_to_snippet(semi_full_span) { Ok(ref snippet) if &snippet[..] != ";" && kind_name == "expression" => { err.span_suggestion_with_applicability( semi_span, diff --git a/src/test/ui/macros/macro-context.stderr b/src/test/ui/macros/macro-context.stderr index 5ea7825080c..005e1d1c8e7 100644 --- a/src/test/ui/macros/macro-context.stderr +++ b/src/test/ui/macros/macro-context.stderr @@ -16,9 +16,7 @@ LL | () => ( i ; typeof ); //~ ERROR expected expression, found reserved k | ^^^^^^ ... LL | let i = m!(); - | ----- help: you might be missing a semicolon here: `;` - | | - | caused by the macro expansion here + | ---- caused by the macro expansion here | = note: the usage of `m!` is likely invalid in expression context -- cgit 1.4.1-3-g733a5 From 2cfd79017744aa55abdd470b93bc544685644612 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 23 Oct 2018 21:37:32 -0700 Subject: List allowed tokens after macro fragments --- src/libsyntax/ext/tt/macro_rules.rs | 138 ++++++--- src/test/ui/macros/macro-follow.stderr | 340 +++++++++++++++------ .../ui/macros/macro-followed-by-seq-bad.stderr | 8 +- .../ui/macros/macro-input-future-proofing.stderr | 36 ++- .../unused-macro-with-follow-violation.stderr | 4 +- 5 files changed, 385 insertions(+), 141 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 805aa9bef22..a28d114bda7 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -792,15 +792,15 @@ fn check_matcher_core(sess: &ParseSess, if let TokenTree::MetaVarDecl(_, ref name, ref frag_spec) = *token { for next_token in &suffix_first.tokens { match is_in_follow(next_token, &frag_spec.as_str()) { - Err((msg, help)) => { + IsInFollow::Invalid(msg, help) => { sess.span_diagnostic.struct_span_err(next_token.span(), &msg) .help(help).emit(); // don't bother reporting every source of // conflict for a particular element of `last`. continue 'each_last; } - Ok(true) => {} - Ok(false) => { + IsInFollow::Yes => {} + IsInFollow::No(ref possible) => { let may_be = if last.tokens.len() == 1 && suffix_first.tokens.len() == 1 { @@ -809,15 +809,41 @@ fn check_matcher_core(sess: &ParseSess, "may be" }; - sess.span_diagnostic.span_err( - next_token.span(), + let sp = next_token.span(); + let mut err = sess.span_diagnostic.struct_span_err( + sp, &format!("`${name}:{frag}` {may_be} followed by `{next}`, which \ is not allowed for `{frag}` fragments", name=name, frag=frag_spec, next=quoted_tt_to_string(next_token), - may_be=may_be) + may_be=may_be), ); + err.span_label( + sp, + format!("not allowed after `{}` fragments", frag_spec), + ); + let msg = "allowed there are: "; + match &possible[..] { + &[] => {} + &[t] => { + err.note(&format!( + "only {} is allowed after `{}` fragments", + t, + frag_spec, + )); + } + ts => { + err.note(&format!( + "{}{} or {}", + msg, + ts[..ts.len() - 1].iter().map(|s| *s) + .collect::>().join(", "), + ts[ts.len() - 1], + )); + } + } + err.emit(); } } } @@ -860,6 +886,12 @@ fn frag_can_be_followed_by_any(frag: &str) -> bool { } } +enum IsInFollow { + Yes, + No(Vec<&'static str>), + Invalid(String, &'static str), +} + /// True if `frag` can legally be followed by the token `tok`. For /// fragments that can consume an unbounded number of tokens, `tok` /// must be within a well-defined follow set. This is intended to @@ -868,81 +900,99 @@ fn frag_can_be_followed_by_any(frag: &str) -> bool { /// break macros that were relying on that binary operator as a /// separator. // when changing this do not forget to update doc/book/macros.md! -fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result { +fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow { use self::quoted::TokenTree; if let TokenTree::Token(_, token::CloseDelim(_)) = *tok { // closing a token tree can never be matched by any fragment; // iow, we always require that `(` and `)` match, etc. - Ok(true) + IsInFollow::Yes } else { match frag { "item" => { // since items *must* be followed by either a `;` or a `}`, we can // accept anything after them - Ok(true) + IsInFollow::Yes }, "block" => { // anything can follow block, the braces provide an easy boundary to // maintain - Ok(true) + IsInFollow::Yes }, - "stmt" | "expr" => match *tok { - TokenTree::Token(_, ref tok) => match *tok { - FatArrow | Comma | Semi => Ok(true), - _ => Ok(false) - }, - _ => Ok(false), + "stmt" | "expr" => { + let tokens = vec!["`=>`", "`,`", "`;`"]; + match *tok { + TokenTree::Token(_, ref tok) => match *tok { + FatArrow | Comma | Semi => IsInFollow::Yes, + _ => IsInFollow::No(tokens), + }, + _ => IsInFollow::No(tokens), + } }, - "pat" => match *tok { - TokenTree::Token(_, ref tok) => match *tok { - FatArrow | Comma | Eq | BinOp(token::Or) => Ok(true), - Ident(i, false) if i.name == "if" || i.name == "in" => Ok(true), - _ => Ok(false) - }, - _ => Ok(false), + "pat" => { + let tokens = vec!["`=>`", "`,`", "`=`", "`|`", "`if`", "`in`"]; + match *tok { + TokenTree::Token(_, ref tok) => match *tok { + FatArrow | Comma | Eq | BinOp(token::Or) => IsInFollow::Yes, + Ident(i, false) if i.name == "if" || i.name == "in" => IsInFollow::Yes, + _ => IsInFollow::No(tokens), + }, + _ => IsInFollow::No(tokens), + } }, - "path" | "ty" => match *tok { - TokenTree::Token(_, ref tok) => match *tok { - OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) | - Comma | FatArrow | Colon | Eq | Gt | BinOp(token::Shr) | Semi | - BinOp(token::Or) => Ok(true), - Ident(i, false) if i.name == "as" || i.name == "where" => Ok(true), - _ => Ok(false) - }, - TokenTree::MetaVarDecl(_, _, frag) if frag.name == "block" => Ok(true), - _ => Ok(false), + "path" | "ty" => { + let tokens = vec![ + "`{`", "`[`", "`=>`", "`,`", "`>`","`=`", "`:`", "`;`", "`|`", "`as`", + "`where`", + ]; + match *tok { + TokenTree::Token(_, ref tok) => match *tok { + OpenDelim(token::DelimToken::Brace) | + OpenDelim(token::DelimToken::Bracket) | + Comma | FatArrow | Colon | Eq | Gt | BinOp(token::Shr) | Semi | + BinOp(token::Or) => IsInFollow::Yes, + Ident(i, false) if i.name == "as" || i.name == "where" => IsInFollow::Yes, + _ => IsInFollow::No(tokens), + }, + TokenTree::MetaVarDecl(_, _, frag) if frag.name == "block" => IsInFollow::Yes, + _ => IsInFollow::No(tokens), + } }, "ident" | "lifetime" => { // being a single token, idents and lifetimes are harmless - Ok(true) + IsInFollow::Yes }, "literal" => { // literals may be of a single token, or two tokens (negative numbers) - Ok(true) + IsInFollow::Yes }, "meta" | "tt" => { // being either a single token or a delimited sequence, tt is // harmless - Ok(true) + IsInFollow::Yes }, "vis" => { // Explicitly disallow `priv`, on the off chance it comes back. + let tokens = vec!["`,`", "an ident", "a type"]; match *tok { TokenTree::Token(_, ref tok) => match *tok { - Comma => Ok(true), - Ident(i, is_raw) if is_raw || i.name != "priv" => Ok(true), - ref tok => Ok(tok.can_begin_type()) + Comma => IsInFollow::Yes, + Ident(i, is_raw) if is_raw || i.name != "priv" => IsInFollow::Yes, + ref tok => if tok.can_begin_type() { + IsInFollow::Yes + } else { + IsInFollow::No(tokens) + } }, TokenTree::MetaVarDecl(_, _, frag) if frag.name == "ident" || frag.name == "ty" - || frag.name == "path" => Ok(true), - _ => Ok(false) + || frag.name == "path" => IsInFollow::Yes, + _ => IsInFollow::No(tokens), } }, - "" => Ok(true), // keywords::Invalid - _ => Err((format!("invalid fragment specifier `{}`", frag), - VALID_FRAGMENT_NAMES_MSG)) + "" => IsInFollow::Yes, // keywords::Invalid + _ => IsInFollow::Invalid(format!("invalid fragment specifier `{}`", frag), + VALID_FRAGMENT_NAMES_MSG), } } } diff --git a/src/test/ui/macros/macro-follow.stderr b/src/test/ui/macros/macro-follow.stderr index ccd658af89f..8760f6eb572 100644 --- a/src/test/ui/macros/macro-follow.stderr +++ b/src/test/ui/macros/macro-follow.stderr @@ -2,511 +2,681 @@ error: `$p:pat` is followed by `(`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:17:14 | LL | ($p:pat ()) => {}; //~ERROR `$p:pat` is followed by `(` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `[`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:18:14 | LL | ($p:pat []) => {}; //~ERROR `$p:pat` is followed by `[` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `{`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:19:14 | LL | ($p:pat {}) => {}; //~ERROR `$p:pat` is followed by `{` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `:`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:20:13 | LL | ($p:pat :) => {}; //~ERROR `$p:pat` is followed by `:` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `>`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:21:13 | LL | ($p:pat >) => {}; //~ERROR `$p:pat` is followed by `>` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `+`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:22:13 | LL | ($p:pat +) => {}; //~ERROR `$p:pat` is followed by `+` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `ident`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:23:13 | LL | ($p:pat ident) => {}; //~ERROR `$p:pat` is followed by `ident` - | ^^^^^ + | ^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$p:pat`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:24:13 | LL | ($p:pat $p:pat) => {}; //~ERROR `$p:pat` is followed by `$p:pat` - | ^^^^^^ + | ^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$e:expr`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:25:13 | LL | ($p:pat $e:expr) => {}; //~ERROR `$p:pat` is followed by `$e:expr` - | ^^^^^^^ + | ^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$t:ty`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:26:13 | LL | ($p:pat $t:ty) => {}; //~ERROR `$p:pat` is followed by `$t:ty` - | ^^^^^ + | ^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$s:stmt`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:27:13 | LL | ($p:pat $s:stmt) => {}; //~ERROR `$p:pat` is followed by `$s:stmt` - | ^^^^^^^ + | ^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$p:path`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:28:13 | LL | ($p:pat $p:path) => {}; //~ERROR `$p:pat` is followed by `$p:path` - | ^^^^^^^ + | ^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$b:block`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:29:13 | LL | ($p:pat $b:block) => {}; //~ERROR `$p:pat` is followed by `$b:block` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$i:ident`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:30:13 | LL | ($p:pat $i:ident) => {}; //~ERROR `$p:pat` is followed by `$i:ident` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$t:tt`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:31:13 | LL | ($p:pat $t:tt) => {}; //~ERROR `$p:pat` is followed by `$t:tt` - | ^^^^^ + | ^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$i:item`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:32:13 | LL | ($p:pat $i:item) => {}; //~ERROR `$p:pat` is followed by `$i:item` - | ^^^^^^^ + | ^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$p:pat` is followed by `$m:meta`, which is not allowed for `pat` fragments --> $DIR/macro-follow.rs:33:13 | LL | ($p:pat $m:meta) => {}; //~ERROR `$p:pat` is followed by `$m:meta` - | ^^^^^^^ + | ^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$e:expr` is followed by `(`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:37:15 | LL | ($e:expr ()) => {}; //~ERROR `$e:expr` is followed by `(` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `[`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:38:15 | LL | ($e:expr []) => {}; //~ERROR `$e:expr` is followed by `[` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `{`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:39:15 | LL | ($e:expr {}) => {}; //~ERROR `$e:expr` is followed by `{` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `=`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:40:14 | LL | ($e:expr =) => {}; //~ERROR `$e:expr` is followed by `=` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `|`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:41:14 | LL | ($e:expr |) => {}; //~ERROR `$e:expr` is followed by `|` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `:`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:42:14 | LL | ($e:expr :) => {}; //~ERROR `$e:expr` is followed by `:` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `>`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:43:14 | LL | ($e:expr >) => {}; //~ERROR `$e:expr` is followed by `>` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `+`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:44:14 | LL | ($e:expr +) => {}; //~ERROR `$e:expr` is followed by `+` - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `ident`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:45:14 | LL | ($e:expr ident) => {}; //~ERROR `$e:expr` is followed by `ident` - | ^^^^^ + | ^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `if`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:46:14 | LL | ($e:expr if) => {}; //~ERROR `$e:expr` is followed by `if` - | ^^ + | ^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `in`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:47:14 | LL | ($e:expr in) => {}; //~ERROR `$e:expr` is followed by `in` - | ^^ + | ^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$p:pat`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:48:14 | LL | ($e:expr $p:pat) => {}; //~ERROR `$e:expr` is followed by `$p:pat` - | ^^^^^^ + | ^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$e:expr`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:49:14 | LL | ($e:expr $e:expr) => {}; //~ERROR `$e:expr` is followed by `$e:expr` - | ^^^^^^^ + | ^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$t:ty`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:50:14 | LL | ($e:expr $t:ty) => {}; //~ERROR `$e:expr` is followed by `$t:ty` - | ^^^^^ + | ^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$s:stmt`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:51:14 | LL | ($e:expr $s:stmt) => {}; //~ERROR `$e:expr` is followed by `$s:stmt` - | ^^^^^^^ + | ^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$p:path`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:52:14 | LL | ($e:expr $p:path) => {}; //~ERROR `$e:expr` is followed by `$p:path` - | ^^^^^^^ + | ^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$b:block`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:53:14 | LL | ($e:expr $b:block) => {}; //~ERROR `$e:expr` is followed by `$b:block` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$i:ident`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:54:14 | LL | ($e:expr $i:ident) => {}; //~ERROR `$e:expr` is followed by `$i:ident` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$t:tt`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:55:14 | LL | ($e:expr $t:tt) => {}; //~ERROR `$e:expr` is followed by `$t:tt` - | ^^^^^ + | ^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$i:item`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:56:14 | LL | ($e:expr $i:item) => {}; //~ERROR `$e:expr` is followed by `$i:item` - | ^^^^^^^ + | ^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$e:expr` is followed by `$m:meta`, which is not allowed for `expr` fragments --> $DIR/macro-follow.rs:57:14 | LL | ($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta` - | ^^^^^^^ + | ^^^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$t:ty` is followed by `(`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:62:13 | LL | ($t:ty ()) => {}; //~ERROR `$t:ty` is followed by `(` - | ^ + | ^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `+`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:64:12 | LL | ($t:ty +) => {}; //~ERROR `$t:ty` is followed by `+` - | ^ + | ^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `ident`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:65:12 | LL | ($t:ty ident) => {}; //~ERROR `$t:ty` is followed by `ident` - | ^^^^^ + | ^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `if`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:66:12 | LL | ($t:ty if) => {}; //~ERROR `$t:ty` is followed by `if` - | ^^ + | ^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$p:pat`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:67:12 | LL | ($t:ty $p:pat) => {}; //~ERROR `$t:ty` is followed by `$p:pat` - | ^^^^^^ + | ^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$e:expr`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:68:12 | LL | ($t:ty $e:expr) => {}; //~ERROR `$t:ty` is followed by `$e:expr` - | ^^^^^^^ + | ^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$t:ty`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:69:12 | LL | ($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty` - | ^^^^^ + | ^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$s:stmt`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:70:12 | LL | ($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt` - | ^^^^^^^ + | ^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$p:path`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:71:12 | LL | ($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path` - | ^^^^^^^ + | ^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$i:ident`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:73:12 | LL | ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$t:tt`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:74:12 | LL | ($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt` - | ^^^^^ + | ^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$i:item`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:75:12 | LL | ($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item` - | ^^^^^^^ + | ^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$t:ty` is followed by `$m:meta`, which is not allowed for `ty` fragments --> $DIR/macro-follow.rs:76:12 | LL | ($t:ty $m:meta) => {}; //~ERROR `$t:ty` is followed by `$m:meta` - | ^^^^^^^ + | ^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$s:stmt` is followed by `(`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:80:15 | LL | ($s:stmt ()) => {}; //~ERROR `$s:stmt` is followed by `(` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `[`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:81:15 | LL | ($s:stmt []) => {}; //~ERROR `$s:stmt` is followed by `[` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `{`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:82:15 | LL | ($s:stmt {}) => {}; //~ERROR `$s:stmt` is followed by `{` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `=`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:83:14 | LL | ($s:stmt =) => {}; //~ERROR `$s:stmt` is followed by `=` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `|`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:84:14 | LL | ($s:stmt |) => {}; //~ERROR `$s:stmt` is followed by `|` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `:`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:85:14 | LL | ($s:stmt :) => {}; //~ERROR `$s:stmt` is followed by `:` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `>`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:86:14 | LL | ($s:stmt >) => {}; //~ERROR `$s:stmt` is followed by `>` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `+`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:87:14 | LL | ($s:stmt +) => {}; //~ERROR `$s:stmt` is followed by `+` - | ^ + | ^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `ident`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:88:14 | LL | ($s:stmt ident) => {}; //~ERROR `$s:stmt` is followed by `ident` - | ^^^^^ + | ^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `if`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:89:14 | LL | ($s:stmt if) => {}; //~ERROR `$s:stmt` is followed by `if` - | ^^ + | ^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `in`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:90:14 | LL | ($s:stmt in) => {}; //~ERROR `$s:stmt` is followed by `in` - | ^^ + | ^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$p:pat`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:91:14 | LL | ($s:stmt $p:pat) => {}; //~ERROR `$s:stmt` is followed by `$p:pat` - | ^^^^^^ + | ^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$e:expr`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:92:14 | LL | ($s:stmt $e:expr) => {}; //~ERROR `$s:stmt` is followed by `$e:expr` - | ^^^^^^^ + | ^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$t:ty`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:93:14 | LL | ($s:stmt $t:ty) => {}; //~ERROR `$s:stmt` is followed by `$t:ty` - | ^^^^^ + | ^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$s:stmt`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:94:14 | LL | ($s:stmt $s:stmt) => {}; //~ERROR `$s:stmt` is followed by `$s:stmt` - | ^^^^^^^ + | ^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$p:path`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:95:14 | LL | ($s:stmt $p:path) => {}; //~ERROR `$s:stmt` is followed by `$p:path` - | ^^^^^^^ + | ^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$b:block`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:96:14 | LL | ($s:stmt $b:block) => {}; //~ERROR `$s:stmt` is followed by `$b:block` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$i:ident`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:97:14 | LL | ($s:stmt $i:ident) => {}; //~ERROR `$s:stmt` is followed by `$i:ident` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$t:tt`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:98:14 | LL | ($s:stmt $t:tt) => {}; //~ERROR `$s:stmt` is followed by `$t:tt` - | ^^^^^ + | ^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$i:item`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:99:14 | LL | ($s:stmt $i:item) => {}; //~ERROR `$s:stmt` is followed by `$i:item` - | ^^^^^^^ + | ^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$s:stmt` is followed by `$m:meta`, which is not allowed for `stmt` fragments --> $DIR/macro-follow.rs:100:14 | LL | ($s:stmt $m:meta) => {}; //~ERROR `$s:stmt` is followed by `$m:meta` - | ^^^^^^^ + | ^^^^^^^ not allowed after `stmt` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$p:path` is followed by `(`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:104:15 | LL | ($p:path ()) => {}; //~ERROR `$p:path` is followed by `(` - | ^ + | ^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `+`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:106:14 | LL | ($p:path +) => {}; //~ERROR `$p:path` is followed by `+` - | ^ + | ^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `ident`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:107:14 | LL | ($p:path ident) => {}; //~ERROR `$p:path` is followed by `ident` - | ^^^^^ + | ^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `if`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:108:14 | LL | ($p:path if) => {}; //~ERROR `$p:path` is followed by `if` - | ^^ + | ^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$p:pat`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:109:14 | LL | ($p:path $p:pat) => {}; //~ERROR `$p:path` is followed by `$p:pat` - | ^^^^^^ + | ^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$e:expr`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:110:14 | LL | ($p:path $e:expr) => {}; //~ERROR `$p:path` is followed by `$e:expr` - | ^^^^^^^ + | ^^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$t:ty`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:111:14 | LL | ($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty` - | ^^^^^ + | ^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$s:stmt`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:112:14 | LL | ($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt` - | ^^^^^^^ + | ^^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$p:path`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:113:14 | LL | ($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path` - | ^^^^^^^ + | ^^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$i:ident`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:115:14 | LL | ($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$t:tt`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:116:14 | LL | ($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt` - | ^^^^^ + | ^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$i:item`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:117:14 | LL | ($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item` - | ^^^^^^^ + | ^^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$p:path` is followed by `$m:meta`, which is not allowed for `path` fragments --> $DIR/macro-follow.rs:118:14 | LL | ($p:path $m:meta) => {}; //~ERROR `$p:path` is followed by `$m:meta` - | ^^^^^^^ + | ^^^^^^^ not allowed after `path` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: aborting due to 85 previous errors diff --git a/src/test/ui/macros/macro-followed-by-seq-bad.stderr b/src/test/ui/macros/macro-followed-by-seq-bad.stderr index bb070334d36..2ad8990e115 100644 --- a/src/test/ui/macros/macro-followed-by-seq-bad.stderr +++ b/src/test/ui/macros/macro-followed-by-seq-bad.stderr @@ -2,13 +2,17 @@ error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragmen --> $DIR/macro-followed-by-seq-bad.rs:17:15 | LL | ( $a:expr $($b:tt)* ) => { }; //~ ERROR not allowed for `expr` fragments - | ^^^^^ + | ^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: `$a:ty` is followed by `$b:tt`, which is not allowed for `ty` fragments --> $DIR/macro-followed-by-seq-bad.rs:18:13 | LL | ( $a:ty $($b:tt)* ) => { }; //~ ERROR not allowed for `ty` fragments - | ^^^^^ + | ^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: aborting due to 2 previous errors diff --git a/src/test/ui/macros/macro-input-future-proofing.stderr b/src/test/ui/macros/macro-input-future-proofing.stderr index aed7a8a119c..4bb46e39562 100644 --- a/src/test/ui/macros/macro-input-future-proofing.stderr +++ b/src/test/ui/macros/macro-input-future-proofing.stderr @@ -2,55 +2,73 @@ error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments --> $DIR/macro-input-future-proofing.rs:14:13 | LL | ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` - | ^ + | ^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments --> $DIR/macro-input-future-proofing.rs:15:13 | LL | ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` - | ^ + | ^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$pa:pat` is followed by `>`, which is not allowed for `pat` fragments --> $DIR/macro-input-future-proofing.rs:21:14 | LL | ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat` - | ^ + | ^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$pa:pat` is followed by `$pb:pat`, which is not allowed for `pat` fragments --> $DIR/macro-input-future-proofing.rs:23:14 | LL | ($pa:pat $pb:pat $ty:ty ,) => (); - | ^^^^^^^ + | ^^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$pb:pat` is followed by `$ty:ty`, which is not allowed for `pat` fragments --> $DIR/macro-input-future-proofing.rs:23:22 | LL | ($pa:pat $pb:pat $ty:ty ,) => (); - | ^^^^^^ + | ^^^^^^ not allowed after `pat` fragments + | + = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in` error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments --> $DIR/macro-input-future-proofing.rs:26:17 | LL | ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-` - | ^ + | ^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$b:ty` is followed by `-`, which is not allowed for `ty` fragments --> $DIR/macro-input-future-proofing.rs:27:23 | LL | ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-` - | ^ + | ^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments --> $DIR/macro-input-future-proofing.rs:28:7 | LL | ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty` - | ^^^^^^^^ + | ^^^^^^^^ not allowed after `ty` fragments + | + = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where` error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments --> $DIR/macro-input-future-proofing.rs:29:21 | LL | ( $($a:expr)* $($b:tt)* ) => { }; - | ^^^^^ + | ^^^^^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: aborting due to 9 previous errors diff --git a/src/test/ui/unused/unused-macro-with-follow-violation.stderr b/src/test/ui/unused/unused-macro-with-follow-violation.stderr index 8efb191c7c6..78362fcb05a 100644 --- a/src/test/ui/unused/unused-macro-with-follow-violation.stderr +++ b/src/test/ui/unused/unused-macro-with-follow-violation.stderr @@ -2,7 +2,9 @@ error: `$e:expr` is followed by `+`, which is not allowed for `expr` fragments --> $DIR/unused-macro-with-follow-violation.rs:14:14 | LL | ($e:expr +) => () //~ ERROR not allowed for `expr` fragments - | ^ + | ^ not allowed after `expr` fragments + | + = note: allowed there are: `=>`, `,` or `;` error: aborting due to previous error -- cgit 1.4.1-3-g733a5 From 3878d24ef6922c133539fe67e0c907166f6261cb Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Fri, 26 Oct 2018 03:11:11 +0900 Subject: Remove redundant clone --- src/bootstrap/dist.rs | 4 ++-- src/bootstrap/test.rs | 2 +- src/librustc/infer/outlives/obligations.rs | 2 +- src/librustc/infer/region_constraints/mod.rs | 4 ++-- src/librustc/traits/error_reporting.rs | 4 ++-- src/librustc/traits/project.rs | 2 +- src/librustc/ty/context.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_borrowck/borrowck/move_data.rs | 6 +++--- src/librustc_codegen_llvm/base.rs | 2 +- src/librustc_codegen_utils/link.rs | 2 +- src/librustc_mir/borrow_check/error_reporting.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 4 ++-- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/build/mod.rs | 4 ++-- src/librustc_mir/shim.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 4 ++-- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 2 +- src/librustc_target/spec/mod.rs | 8 ++++---- src/librustc_typeck/check/autoderef.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 16 ++++------------ src/librustdoc/clean/auto_trait.rs | 2 +- src/librustdoc/clean/blanket_impl.rs | 4 ++-- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/html/render.rs | 8 ++++---- src/librustdoc/lib.rs | 2 +- src/librustdoc/test.rs | 4 ++-- src/libsyntax/ext/tt/macro_rules.rs | 3 +-- src/libsyntax/ext/tt/transcribe.rs | 4 ++-- src/libsyntax/test.rs | 2 +- src/libsyntax_ext/deriving/cmp/partial_ord.rs | 2 +- src/libsyntax_ext/deriving/custom.rs | 2 +- 35 files changed, 56 insertions(+), 65 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 4de899ee2d5..fea6302d0a1 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1447,8 +1447,8 @@ impl Step for Extended { tarballs.extend(rls_installer.clone()); tarballs.extend(clippy_installer.clone()); tarballs.extend(rustfmt_installer.clone()); - tarballs.extend(llvm_tools_installer.clone()); - tarballs.extend(lldb_installer.clone()); + tarballs.extend(llvm_tools_installer); + tarballs.extend(lldb_installer); tarballs.push(analysis_installer); tarballs.push(std_installer); if builder.config.docs { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index fe04a91011e..f6032eb9931 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1052,7 +1052,7 @@ impl Step for Compiletest { let hostflags = flags.clone(); cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); - let mut targetflags = flags.clone(); + let mut targetflags = flags; targetflags.push(format!( "-Lnative={}", builder.test_helpers_out(target).display() diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index 332859d4f81..5db850f1588 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -458,7 +458,7 @@ where ); debug!("projection_must_outlive: unique declared bound appears in trait ref"); self.delegate - .push_sub_region_constraint(origin.clone(), region, unique_bound); + .push_sub_region_constraint(origin, region, unique_bound); return; } diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index 96278e5140c..c82603bf560 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -749,7 +749,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { a // LUB(a,a) = a } - _ => self.combine_vars(tcx, Lub, a, b, origin.clone()), + _ => self.combine_vars(tcx, Lub, a, b, origin), } } @@ -771,7 +771,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { a // GLB(a,a) = a } - _ => self.combine_vars(tcx, Glb, a, b, origin.clone()), + _ => self.combine_vars(tcx, Glb, a, b, origin), } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index ea30752a820..b6df8ebe909 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -239,7 +239,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let msg = format!("type mismatch resolving `{}`", predicate); let error_id = (DiagnosticMessageId::ErrorId(271), - Some(obligation.cause.span), msg.clone()); + Some(obligation.cause.span), msg); let fresh = self.tcx.sess.one_time_diagnostics.borrow_mut().insert(error_id); if fresh { let mut diag = struct_span_err!( @@ -379,7 +379,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } if let Some(t) = self.get_parent_trait_ref(&obligation.cause.code) { - flags.push(("parent_trait".to_owned(), Some(t.to_string()))); + flags.push(("parent_trait".to_owned(), Some(t))); } if let Some(k) = obligation.cause.span.compiler_desugaring_kind() { diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index b266fbe0d11..4eda47d31eb 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -594,7 +594,7 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( // But for now, let's classify this as an overflow: let recursion_limit = *selcx.tcx().sess.recursion_limit.get(); - let obligation = Obligation::with_depth(cause.clone(), + let obligation = Obligation::with_depth(cause, recursion_limit, param_env, projection_ty); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 1a9f8630632..1686e3e0e0c 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1200,7 +1200,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { cstore, global_arenas: &arenas.global, global_interners: interners, - dep_graph: dep_graph.clone(), + dep_graph, types: common_types, trait_map, export_map: resolutions.export_map.into_iter().map(|(k, v)| { diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index da5c5f47c08..bf8d0231303 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -695,7 +695,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { let mut err = self.cannot_act_on_moved_value(use_span, verb, msg, - Some(nl.to_string()), + Some(nl), Origin::Ast); let need_note = match lp.ty.sty { ty::Closure(id, _) => { diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index d9f223daf60..8aa2e4641d4 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -347,7 +347,7 @@ impl<'a, 'tcx> MoveData<'tcx> { lp = base_lp.clone(); } - self.add_move_helper(tcx, orig_lp.clone(), id, kind); + self.add_move_helper(tcx, orig_lp, id, kind); } fn add_move_helper(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -359,7 +359,7 @@ impl<'a, 'tcx> MoveData<'tcx> { id, kind); - let path_index = self.move_path(tcx, lp.clone()); + let path_index = self.move_path(tcx, lp); let move_index = MoveIndex(self.moves.borrow().len()); let next_move = self.path_first_move(path_index); @@ -402,7 +402,7 @@ impl<'a, 'tcx> MoveData<'tcx> { } } - self.add_assignment_helper(tcx, lp.clone(), assign_id, span); + self.add_assignment_helper(tcx, lp, assign_id, span); } fn add_assignment_helper(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 614a562846e..a9119d49e8b 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -784,7 +784,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, !tcx.sess.opts.output_types.should_codegen() { let ongoing_codegen = write::start_async_codegen( tcx, - time_graph.clone(), + time_graph, metadata, rx, 1); diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs index 2a1fbe6ace5..66e98793f42 100644 --- a/src/librustc_codegen_utils/link.rs +++ b/src/librustc_codegen_utils/link.rs @@ -138,7 +138,7 @@ pub fn filename_for_input(sess: &Session, let suffix = &sess.target.target.options.exe_suffix; let out_filename = outputs.path(OutputType::Exe); if suffix.is_empty() { - out_filename.to_path_buf() + out_filename } else { out_filename.with_extension(&suffix[1..]) } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index b6bb130d3e2..b2b92a6f857 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -1615,7 +1615,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ProjectionElem::Index(..) | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => { - self.describe_field(&proj.base, field).to_string() + self.describe_field(&proj.base, field) } }, } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index a864b39e157..23a70be66c0 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -265,7 +265,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { block, Statement { source_info, - kind: StatementKind::FakeRead(FakeReadCause::ForLet, place.clone()), + kind: StatementKind::FakeRead(FakeReadCause::ForLet, place), }, ); @@ -314,7 +314,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { Statement { source_info: ty_source_info, kind: StatementKind::AscribeUserType( - place.clone(), + place, ty::Variance::Invariant, ascription_user_ty, ), diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index c7da9c4fbd7..9e6f32909bd 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -324,7 +324,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let ref_ty = self.hir.tcx().mk_ref(region, tam); // let lhs_ref_place = &lhs; - let ref_rvalue = Rvalue::Ref(region, BorrowKind::Shared, place.clone()); + let ref_rvalue = Rvalue::Ref(region, BorrowKind::Shared, place); let lhs_ref_place = self.temp(ref_ty, test.span); self.cfg.push_assign(block, source_info, &lhs_ref_place, ref_rvalue); let val = Operand::Move(lhs_ref_place); diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index e6dd0107e91..6ea4628de24 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -644,7 +644,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, }).collect() }); - let mut builder = Builder::new(hir.clone(), + let mut builder = Builder::new(hir, span, arguments.len(), safety, @@ -714,7 +714,7 @@ fn construct_const<'a, 'gcx, 'tcx>( let ty = hir.tables().expr_ty_adjusted(ast_expr); let owner_id = tcx.hir.body_owner(body_id); let span = tcx.hir.span(owner_id); - let mut builder = Builder::new(hir.clone(), span, 0, Safety::Safe, ty, ty_span,vec![]); + let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]); let mut block = START_BLOCK; let expr = builder.hir.mirror(ast_expr); diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 4b26094b9fc..d8f627fcf4d 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -547,7 +547,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { // `dest[i] = Clone::clone(src[beg])`; // Goto #3 if ok, #5 if unwinding happens. let dest_field = dest.clone().index(beg); - let src_field = src.clone().index(beg); + let src_field = src.index(beg); self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), BasicBlock::new(5)); diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 1dca367ffdf..d9a1e4a0fd6 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -753,11 +753,11 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.place.clone() ))); drop_block_stmts.push(self.assign(&cur, Rvalue::Cast( - CastKind::Misc, Operand::Move(tmp.clone()), iter_ty + CastKind::Misc, Operand::Move(tmp), iter_ty ))); drop_block_stmts.push(self.assign(&length_or_end, Rvalue::BinaryOp(BinOp::Offset, - Operand::Copy(cur.clone()), Operand::Move(length.clone()) + Operand::Copy(cur), Operand::Move(length) ))); } else { // index = 0 (length already pushed) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index b7ed3ef59b4..a43a3c6ac5a 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -218,7 +218,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { }; this.add_import_directive( base.into_iter().collect(), - subclass.clone(), + subclass, source.ident.span, id, root_use_tree.span, diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index a7fe1bb421c..c0b718e4863 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -105,7 +105,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { tcx: save_ctxt.tcx, save_ctxt, dumper, - span: span_utils.clone(), + span: span_utils, cur_scope: CRATE_NODE_ID, // mac_defs: FxHashSet::default(), macro_calls: FxHashSet::default(), diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 9ee4582fabf..d43d45f64a5 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -1132,7 +1132,7 @@ impl ToJson for Target { macro_rules! target_val { ($attr:ident) => ( { let name = (stringify!($attr)).replace("_", "-"); - d.insert(name.to_string(), self.$attr.to_json()); + d.insert(name, self.$attr.to_json()); } ); ($attr:ident, $key_name:expr) => ( { let name = $key_name; @@ -1144,7 +1144,7 @@ impl ToJson for Target { ($attr:ident) => ( { let name = (stringify!($attr)).replace("_", "-"); if default.$attr != self.options.$attr { - d.insert(name.to_string(), self.options.$attr.to_json()); + d.insert(name, self.options.$attr.to_json()); } } ); ($attr:ident, $key_name:expr) => ( { @@ -1160,7 +1160,7 @@ impl ToJson for Target { .iter() .map(|(k, v)| (k.desc().to_owned(), v.clone())) .collect::>(); - d.insert(name.to_string(), obj.to_json()); + d.insert(name, obj.to_json()); } } ); (env - $attr:ident) => ( { @@ -1170,7 +1170,7 @@ impl ToJson for Target { .iter() .map(|&(ref k, ref v)| k.clone() + "=" + &v) .collect::>(); - d.insert(name.to_string(), obj.to_json()); + d.insert(name, obj.to_json()); } } ); diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index 743a2390ec4..73489309d07 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> { let suggested_limit = *tcx.sess.recursion_limit.get() * 2; let msg = format!("reached the recursion limit while auto-dereferencing {:?}", self.cur_ty); - let error_id = (DiagnosticMessageId::ErrorId(55), Some(self.span), msg.clone()); + let error_id = (DiagnosticMessageId::ErrorId(55), Some(self.span), msg); let fresh = tcx.sess.one_time_diagnostics.borrow_mut().insert(error_id); if fresh { struct_span_err!(tcx.sess, diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 695812faaff..54c6c8f7b93 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -325,7 +325,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, diag.span_suggestion_with_applicability( impl_err_span, "consider change the type to match the mutability in trait", - trait_err_str.to_string(), + trait_err_str, Applicability::MachineApplicable, ); } diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index f4538dbd25e..c506f23078f 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1157,7 +1157,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { // Convert the bounds into obligations. let impl_obligations = traits::predicates_for_generics( - cause.clone(), self.param_env, &impl_bounds); + cause, self.param_env, &impl_bounds); debug!("impl_obligations={:?}", impl_obligations); impl_obligations.into_iter() @@ -1175,7 +1175,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { TraitCandidate(trait_ref) => { let predicate = trait_ref.to_predicate(); let obligation = - traits::Obligation::new(cause.clone(), self.param_env, predicate); + traits::Obligation::new(cause, self.param_env, predicate); if !self.predicate_may_hold(&obligation) { if self.probe(|_| self.select_trait_candidate(trait_ref).is_err()) { // This candidate's primary obligation doesn't even diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 77151351d08..85c69d50a12 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4752,25 +4752,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else if !self.check_for_cast(err, expr, found, expected) { let methods = self.get_conversion_methods(expr.span, expected, found); if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) { - let suggestions = iter::repeat(expr_text).zip(methods.iter()) + let suggestions = iter::repeat(&expr_text).zip(methods.iter()) .filter_map(|(receiver, method)| { let method_call = format!(".{}()", method.ident); if receiver.ends_with(&method_call) { None // do not suggest code that is already there (#53348) } else { - /* - methods defined in `method_call_list` will overwrite - `.clone()` in copy of `receiver` - */ let method_call_list = [".to_vec()", ".to_string()"]; if receiver.ends_with(".clone()") - && method_call_list.contains(&method_call.as_str()){ - // created copy of `receiver` because we don't want other - // suggestion to get affected - let mut new_receiver = receiver.clone(); - let max_len = new_receiver.rfind(".").unwrap(); - new_receiver.truncate(max_len); - Some(format!("{}{}", new_receiver, method_call)) + && method_call_list.contains(&method_call.as_str()) { + let max_len = receiver.rfind(".").unwrap(); + Some(format!("{}{}", &receiver[..max_len], method_call)) } else { Some(format!("{}{}", receiver, method_call)) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 26487605bac..fde8648c0c4 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -84,7 +84,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { .into_iter() .chain(self.get_auto_trait_impl_for( def_id, - name.clone(), + name, generics.clone(), def_ctor, tcx.require_lang_item(lang_items::SyncTraitLangItem), diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index b6bc8d603d5..858685ef00e 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -66,7 +66,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> BlanketImplFinder <'a, 'tcx, 'rcx, 'cstore> { } let ty = self.cx.tcx.type_of(def_id); let generics = self.cx.tcx.generics_of(def_id); - let real_name = name.clone().map(|name| Ident::from_str(&name)); + let real_name = name.map(|name| Ident::from_str(&name)); let param_env = self.cx.tcx.param_env(def_id); for &trait_def_id in self.cx.all_traits.iter() { if !self.cx.renderinfo.borrow().access_levels.is_doc_reachable(trait_def_id) || @@ -109,7 +109,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> BlanketImplFinder <'a, 'tcx, 'rcx, 'cstore> { ); let may_apply = match infcx.evaluate_obligation( &traits::Obligation::new( - cause.clone(), + cause, param_env, trait_ref.to_predicate(), ), diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 9b2720717c9..88240e844ed 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3611,7 +3611,7 @@ impl ToSource for syntax_pos::Span { fn to_src(&self, cx: &DocContext) -> String { debug!("converting span {:?} to snippet", self.clean(cx)); let sn = match cx.sess().source_map().span_to_snippet(*self) { - Ok(x) => x.to_string(), + Ok(x) => x, Err(_) => String::new() }; debug!("got snippet {}", sn); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index dda0f37c3f9..9dfe77338a3 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -521,7 +521,7 @@ pub fn run(mut krate: clean::Crate, external_html: external_html.clone(), krate: krate.name.clone(), }, - css_file_extension: css_file_extension.clone(), + css_file_extension, created_dirs: Default::default(), sort_modules_alphabetically, themes, @@ -1343,7 +1343,7 @@ impl DocFolder for Cache { self.search_index.push(IndexItem { ty: item.type_(), name: s.to_string(), - path: path.join("::").to_string(), + path: path.join("::"), desc: plain_summary_line(item.doc_value()), parent, parent_idx: None, @@ -2283,7 +2283,7 @@ fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link format!("{} [Read more]({})", &plain_summary_line(Some(s)), naive_assoc_href(item, link)) } else { - plain_summary_line(Some(s)).to_string() + plain_summary_line(Some(s)) }; render_markdown(w, cx, &markdown, item.links(), prefix)?; } else if !prefix.is_empty() { @@ -2435,7 +2435,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, // (which is the position in the vector). indices.dedup_by_key(|i| (items[*i].def_id, if items[*i].name.as_ref().is_some() { - Some(full_path(cx, &items[*i]).clone()) + Some(full_path(cx, &items[*i])) } else { None }, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 406180c09e8..45a0494849b 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -460,7 +460,7 @@ fn main_args(args: &[String]) -> isize { let externs = match parse_externs(&matches) { Ok(ex) => ex, Err(err) => { - diag.struct_err(&err.to_string()).emit(); + diag.struct_err(&err).emit(); return 1; } }; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 85cd0f84e1c..2e6e76b5a40 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -208,7 +208,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, // needs to be the result of SourceMap::span_to_unmapped_path let input = config::Input::Str { name: filename.to_owned(), - input: test.to_owned(), + input: test, }; let outputs = OutputTypes::new(&[(OutputType::Exe, None)]); @@ -350,7 +350,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, let newpath = { let path = env::var_os(var).unwrap_or(OsString::new()); let mut path = env::split_paths(&path).collect::>(); - path.insert(0, libdir.clone()); + path.insert(0, libdir); env::join_paths(path).unwrap() }; cmd.env(var, &newpath); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 805aa9bef22..36190b3273a 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -133,8 +133,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, // Replace all the tokens for the corresponding positions in the macro, to maintain // proper positions in error reporting, while maintaining the macro_backtrace. if rhs_spans.len() == tts.len() { - tts = tts.map_enumerated(|i, tt| { - let mut tt = tt.clone(); + tts = tts.map_enumerated(|i, mut tt| { let mut sp = rhs_spans[i]; sp = sp.with_ctxt(tt.span().ctxt()); tt.set_span(sp); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index ae486158fee..3d897d17e0b 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -219,9 +219,9 @@ impl Add for LockstepIterSize { LockstepIterSize::Unconstrained => other, LockstepIterSize::Contradiction(_) => self, LockstepIterSize::Constraint(l_len, ref l_id) => match other { - LockstepIterSize::Unconstrained => self.clone(), + LockstepIterSize::Unconstrained => self, LockstepIterSize::Contradiction(_) => other, - LockstepIterSize::Constraint(r_len, _) if l_len == r_len => self.clone(), + LockstepIterSize::Constraint(r_len, _) if l_len == r_len => self, LockstepIterSize::Constraint(r_len, r_id) => { let msg = format!("inconsistent lockstep iteration: \ '{}' has {} items, but '{}' has {}", diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 9f554a90afb..8ff4b0d025c 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -346,7 +346,7 @@ fn mk_main(cx: &mut TestCtxt) -> P { test_runner.span = sp; - let test_main_path_expr = ecx.expr_path(test_runner.clone()); + let test_main_path_expr = ecx.expr_path(test_runner); let call_test_main = ecx.expr_call(sp, test_main_path_expr, vec![mk_tests_slice(cx)]); let call_test_main = ecx.stmt_expr(call_test_main); diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index 3705a245584..32a58de3529 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -178,7 +178,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P< cx.expr_match(span, new, vec![eq_arm, neq_arm]) }, - equals_expr.clone(), + equals_expr, Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs index 973ad631b83..55b3928d68e 100644 --- a/src/libsyntax_ext/deriving/custom.rs +++ b/src/libsyntax_ext/deriving/custom.rs @@ -75,7 +75,7 @@ impl MultiItemModifier for ProcMacroDerive { // Mark attributes as known, and used. MarkAttrs(&self.attrs).visit_item(&item); - let input = __internal::new_token_stream(ecx.resolver.eliminate_crate_var(item.clone())); + let input = __internal::new_token_stream(ecx.resolver.eliminate_crate_var(item)); let res = __internal::set_sess(ecx, || { let inner = self.inner; panic::catch_unwind(panic::AssertUnwindSafe(|| inner(input))) -- cgit 1.4.1-3-g733a5