rustc_expand::mbe::macro_rules

Trait 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>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'dcx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'dcx, 'matcher>

Source§

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

Source§

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

Source§

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

Source§

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