Macro rustc_expand::expand::assign_id

source ·
macro_rules! assign_id {
    ($self:ident, $id:expr, $closure:expr) => { ... };
}
Expand description

Wraps a call to noop_visit_* / noop_flat_map_* for an AST node that supports attributes (see the Annotatable enum) This method assigns a NodeId, and sets that NodeId as our current ‘lint node id’. If a macro call is found inside this AST node, we will use this AST node’s NodeId to emit lints associated with that macro (allowing #[allow] / #[deny] to be applied close to the macro invocation).

Do not call this for a macro AST node (e.g. ExprKind::MacCall) - we cannot emit lints at these AST nodes, since they are removed and replaced with the result of macro expansion.

All other NodeIds are assigned by visit_id.

  • self is the ‘self’ parameter for the current method,
  • id is a mutable reference to the NodeId field of the current AST node.
  • closure is a closure that executes the noop_visit_* / noop_flat_map_* method for the current AST node.