mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
move function closer to its usage
This commit is contained in:
parent
9a020186f8
commit
538437e829
@ -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()) {
|
||||
|
@ -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),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user