Trait rustc_expand::mbe::macro_rules::Tracker

source ·
pub(super) trait Tracker<'matcher> {
    type Failure;

    // Required methods
    fn build_failure(
        tok: Token,
        position: u32,
        msg: &'static str,
    ) -> Self::Failure;
    fn description() -> &'static str;

    // Provided methods
    fn before_match_loc(
        &mut self,
        _parser: &TtParser,
        _matcher: &'matcher MatcherLoc,
    ) { ... }
    fn after_arm(
        &mut self,
        _result: &ParseResult<FxHashMap<MacroRulesNormalizedIdent, NamedMatch>, Self::Failure>,
    ) { ... }
    fn recovery() -> Recovery { ... }
    fn set_expected_token(&mut self, _tok: &'matcher Token) { ... }
    fn get_expected_token(&self) -> Option<&'matcher Token> { ... }
}

Required Associated Types§

source

type Failure

The contents of ParseResult::Failure.

Required Methods§

source

fn build_failure(tok: Token, position: u32, msg: &'static str) -> Self::Failure

Arm failed to match. If the token is token::Eof, it indicates an unexpected end of macro invocation. Otherwise, it indicates that no rules expected the given token. The usize is the approximate position of the token in the input token stream.

source

fn description() -> &'static str

For tracing.

Provided Methods§

source

fn before_match_loc( &mut self, _parser: &TtParser, _matcher: &'matcher MatcherLoc, )

This is called before trying to match next MatcherLoc on the current token.

source

fn after_arm( &mut self, _result: &ParseResult<FxHashMap<MacroRulesNormalizedIdent, NamedMatch>, Self::Failure>, )

This is called after an arm has been parsed, either successfully or unsuccessfully. When this is called, before_match_loc was called at least once (with a MatcherLoc::Eof).

source

fn recovery() -> Recovery

source

fn set_expected_token(&mut self, _tok: &'matcher Token)

source

fn get_expected_token(&self) -> Option<&'matcher Token>

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx, 'matcher>

§

type Failure = (Token, u32, &'static str)

source§

impl<'matcher> Tracker<'matcher> for FailureForwarder<'matcher>

§

type Failure = (Token, u32, &'static str)

source§

impl<'matcher> Tracker<'matcher> for NoopTracker

§

type Failure = ()