about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2019-09-25 10:17:59 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2019-09-25 10:32:04 +0300
commit538437e829fd1bdaaf5104f7750327cfdeed29bf (patch)
treecb9f31a6c9482481bc2174f9f725e9e1dceda676
parent9a020186f8d4411a9820c4e3378f86ea2ca72af5 (diff)
downloadrust-538437e829fd1bdaaf5104f7750327cfdeed29bf.tar.gz
rust-538437e829fd1bdaaf5104f7750327cfdeed29bf.zip
move function closer to its usage
-rw-r--r--src/libsyntax/ext/mbe/macro_parser.rs12
-rw-r--r--src/libsyntax/ext/mbe/macro_rules.rs15
2 files changed, 14 insertions, 13 deletions
diff --git a/src/libsyntax/ext/mbe/macro_parser.rs b/src/libsyntax/ext/mbe/macro_parser.rs
index b51384d3b15..8f49ba9572d 100644
--- a/src/libsyntax/ext/mbe/macro_parser.rs
+++ b/src/libsyntax/ext/mbe/macro_parser.rs
@@ -413,18 +413,6 @@ fn nameize<I: Iterator<Item = NamedMatch>>(
     Success(ret_val)
 }
 
-/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
-/// other tokens, this is "unexpected token...".
-crate fn parse_failure_msg(tok: &Token) -> String {
-    match tok.kind {
-        token::Eof => "unexpected end of macro invocation".to_string(),
-        _ => format!(
-            "no rules expected the token `{}`",
-            pprust::token_to_string(tok)
-        ),
-    }
-}
-
 /// Performs a token equality check, ignoring syntax context (that is, an unhygienic comparison)
 fn token_name_eq(t1: &Token, t2: &Token) -> bool {
     if let (Some((ident1, is_raw1)), Some((ident2, is_raw2))) = (t1.ident(), t2.ident()) {
diff --git a/src/libsyntax/ext/mbe/macro_rules.rs b/src/libsyntax/ext/mbe/macro_rules.rs
index 87bb26c709e..c24f6a66603 100644
--- a/src/libsyntax/ext/mbe/macro_rules.rs
+++ b/src/libsyntax/ext/mbe/macro_rules.rs
@@ -6,7 +6,7 @@ use crate::ext::base::{SyntaxExtension, SyntaxExtensionKind};
 use crate::ext::expand::{AstFragment, AstFragmentKind};
 use crate::ext::mbe;
 use crate::ext::mbe::macro_check;
-use crate::ext::mbe::macro_parser::{parse, parse_failure_msg};
+use crate::ext::mbe::macro_parser::parse;
 use crate::ext::mbe::macro_parser::{Error, Failure, Success};
 use crate::ext::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
 use crate::ext::mbe::transcribe::transcribe;
@@ -15,6 +15,7 @@ use crate::parse::parser::Parser;
 use crate::parse::token::TokenKind::*;
 use crate::parse::token::{self, NtTT, Token};
 use crate::parse::{Directory, ParseSess};
+use crate::print::pprust;
 use crate::symbol::{kw, sym, Symbol};
 use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
 
@@ -1176,3 +1177,15 @@ impl TokenTree {
         parse(cx.parse_sess(), tts, mtch, Some(directory), true)
     }
 }
+
+/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
+/// other tokens, this is "unexpected token...".
+fn parse_failure_msg(tok: &Token) -> String {
+    match tok.kind {
+        token::Eof => "unexpected end of macro invocation".to_string(),
+        _ => format!(
+            "no rules expected the token `{}`",
+            pprust::token_to_string(tok),
+        ),
+    }
+}