Factor out matching into try_match_macro
This moves out the matching part of expansion into a new function. This function will try to match the macro and return an error if it failed to match. A tracker can be used to get more information about the matching.
This commit is contained in:
parent
2f8a068cb7
commit
39584b153b
2 changed files with 128 additions and 123 deletions
|
@ -277,7 +277,11 @@ pub(crate) enum ParseResult<T> {
|
|||
/// A `ParseResult` where the `Success` variant contains a mapping of
|
||||
/// `MacroRulesNormalizedIdent`s to `NamedMatch`es. This represents the mapping
|
||||
/// of metavars to the token trees they bind to.
|
||||
pub(crate) type NamedParseResult = ParseResult<FxHashMap<MacroRulesNormalizedIdent, NamedMatch>>;
|
||||
pub(crate) type NamedParseResult = ParseResult<NamedMatches>;
|
||||
|
||||
/// Contains a mapping of `MacroRulesNormalizedIdent`s to `NamedMatch`es.
|
||||
/// This represents the mapping of metavars to the token trees they bind to.
|
||||
pub(crate) type NamedMatches = FxHashMap<MacroRulesNormalizedIdent, NamedMatch>;
|
||||
|
||||
/// Count how many metavars declarations are in `matcher`.
|
||||
pub(super) fn count_metavar_decls(matcher: &[TokenTree]) -> usize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue