Skip to content

Commit

Permalink
move function closer to its usage
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Sep 25, 2019
1 parent 9a02018 commit 538437e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
12 changes: 0 additions & 12 deletions src/libsyntax/ext/mbe/macro_parser.rs
Expand Up @@ -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()) {
Expand Down
15 changes: 14 additions & 1 deletion src/libsyntax/ext/mbe/macro_rules.rs
Expand Up @@ -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;
Expand All @@ -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};

Expand Down Expand Up @@ -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),
),
}
}

0 comments on commit 538437e

Please sign in to comment.