Skip to content

Commit 538437e

Browse files
committed
move function closer to its usage
1 parent 9a02018 commit 538437e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/libsyntax/ext/mbe/macro_parser.rs

-12
Original file line numberDiff line numberDiff line change
@@ -413,18 +413,6 @@ fn nameize<I: Iterator<Item = NamedMatch>>(
413413
Success(ret_val)
414414
}
415415

416-
/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
417-
/// other tokens, this is "unexpected token...".
418-
crate fn parse_failure_msg(tok: &Token) -> String {
419-
match tok.kind {
420-
token::Eof => "unexpected end of macro invocation".to_string(),
421-
_ => format!(
422-
"no rules expected the token `{}`",
423-
pprust::token_to_string(tok)
424-
),
425-
}
426-
}
427-
428416
/// Performs a token equality check, ignoring syntax context (that is, an unhygienic comparison)
429417
fn token_name_eq(t1: &Token, t2: &Token) -> bool {
430418
if let (Some((ident1, is_raw1)), Some((ident2, is_raw2))) = (t1.ident(), t2.ident()) {

src/libsyntax/ext/mbe/macro_rules.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::ext::base::{SyntaxExtension, SyntaxExtensionKind};
66
use crate::ext::expand::{AstFragment, AstFragmentKind};
77
use crate::ext::mbe;
88
use crate::ext::mbe::macro_check;
9-
use crate::ext::mbe::macro_parser::{parse, parse_failure_msg};
9+
use crate::ext::mbe::macro_parser::parse;
1010
use crate::ext::mbe::macro_parser::{Error, Failure, Success};
1111
use crate::ext::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
1212
use crate::ext::mbe::transcribe::transcribe;
@@ -15,6 +15,7 @@ use crate::parse::parser::Parser;
1515
use crate::parse::token::TokenKind::*;
1616
use crate::parse::token::{self, NtTT, Token};
1717
use crate::parse::{Directory, ParseSess};
18+
use crate::print::pprust;
1819
use crate::symbol::{kw, sym, Symbol};
1920
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
2021

@@ -1176,3 +1177,15 @@ impl TokenTree {
11761177
parse(cx.parse_sess(), tts, mtch, Some(directory), true)
11771178
}
11781179
}
1180+
1181+
/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
1182+
/// other tokens, this is "unexpected token...".
1183+
fn parse_failure_msg(tok: &Token) -> String {
1184+
match tok.kind {
1185+
token::Eof => "unexpected end of macro invocation".to_string(),
1186+
_ => format!(
1187+
"no rules expected the token `{}`",
1188+
pprust::token_to_string(tok),
1189+
),
1190+
}
1191+
}

0 commit comments

Comments
 (0)