MacroRulesScopeRef in rustc_resolve::macros - Rust
Description: `macro_rules!` scopes are always kept by reference and inside a cell. The reason is that we update scopes with value `MacroRulesScope::Invocation(invoc_id)` in-place after `invoc_id` gets expanded. This helps to avoid uncontrollable growth of `macro_rules!` scope chains, which usually grow linearly with the number of macro invocations in a module (including derives) and hurt performance.

Skip to main content

## MacroRulesScopeRef

# Type Alias MacroRulesScopeRef

Source

    pub(crate) type MacroRulesScopeRef<'ra> = &'ra Cell<MacroRulesScope<'ra>>;

Expand description

`macro_rules!` scopes are always kept by reference and inside a cell. The reason is that we update scopes with value `MacroRulesScope::Invocation(invoc_id)` in-place after `invoc_id` gets expanded. This helps to avoid uncontrollable growth of `macro_rules!` scope chains, which usually grow linearly with the number of macro invocations in a module (including derives) and hurt performance.

## Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain `repr(...)` attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes