Expand description
A bunch of methods and structures more or less related to resolving macros and
interface provided by Resolver to macro expander.
Re-exportsΒ§
use std::mem;πuse std::sync::Arc;πuse rustc_ast as ast;πuse rustc_ast::Crate;πuse rustc_ast::DelegationSuffixes;πuse rustc_ast::NodeId;πuse rustc_ast_pretty::pprust;πuse rustc_attr_ir::Attribute;πuse rustc_attr_ir::AttributeKind;πuse rustc_attr_ir::CfgEntry;πuse rustc_attr_ir::StabilityLevel;πuse rustc_attr_ir::StrippedCfgItem;πuse rustc_attr_parsing::AttributeParser;πuse rustc_data_structures::sync::RwLock;πuse rustc_errors::Applicability;πuse rustc_errors::StashKey;πuse rustc_expand::base::Annotatable;πuse rustc_expand::base::DeriveResolution;πuse rustc_expand::base::Indeterminate;πuse rustc_expand::base::ResolverExpand;πuse rustc_expand::base::SyntaxExtension;πuse rustc_expand::base::SyntaxExtensionKind;πuse rustc_expand::compile_declarative_macro;πuse rustc_expand::expand::AstFragment;πuse rustc_expand::expand::AstFragmentKind;πuse rustc_expand::expand::Invocation;πuse rustc_expand::expand::InvocationKind;πuse rustc_expand::expand::SupportsMacroExpansion;πuse rustc_hir::def::DefKind;πuse rustc_hir::def::MacroKinds;πuse rustc_hir::def::Namespace;πuse rustc_hir::def::NonMacroAttrKind;πuse rustc_hir::def_id::CrateNum;πuse rustc_hir::def_id::DefId;πuse rustc_hir::def_id::LocalDefId;πuse rustc_lint_defs::builtin::LEGACY_DERIVE_HELPERS;πuse rustc_lint_defs::builtin::OUT_OF_SCOPE_MACRO_CALLS;πuse rustc_lint_defs::builtin::UNUSED_MACRO_RULES;πuse rustc_lint_defs::builtin::UNUSED_MACROS;πuse rustc_middle::middle::stability;πuse rustc_middle::ty::RegisteredTools;πuse rustc_middle::ty::TyCtxt;πuse rustc_session::Session;πuse rustc_session::diagnostics::feature_err;πuse rustc_span::def_id::ModId;πuse rustc_span::edition::Edition;πuse rustc_span::hygiene;πuse rustc_span::hygiene::AstPass;πuse rustc_span::hygiene::ExpnData;πuse rustc_span::hygiene::ExpnKind;πuse rustc_span::hygiene::LocalExpnId;πuse rustc_span::hygiene::MacroKind;πuse rustc_span::DUMMY_SP;πuse rustc_span::Ident;πuse rustc_span::Span;πuse rustc_span::Symbol;πuse rustc_span::kw;πuse rustc_span::sym;πuse crate::def_collector::collect_definitions;πuse crate::diagnostics;πuse crate::diagnostics::AddAsNonDerive;πuse crate::diagnostics::CannotDetermineMacroResolution;πuse crate::diagnostics::CannotFindIdentInThisScope;πuse crate::diagnostics::MacroExpectedFound;πuse crate::diagnostics::RemoveSurroundingDerive;πuse crate::hygiene::Macros20NormalizedSyntaxContext;πuse crate::imports::Import;πuse crate::BindingKey;πuse crate::CmResolver;πuse crate::Decl;πuse crate::DeclKind;πuse crate::DeriveData;πuse crate::Determinacy;πuse crate::Finalize;πuse crate::IdentKey;πuse crate::InvocationParent;πuse crate::ModuleKind;πuse crate::ModuleOrUniformRoot;πuse crate::ParentScope;πuse crate::PathResult;πuse crate::Res;πuse crate::ResolutionError;πuse crate::Resolver;πuse crate::ScopeSet;πuse crate::Segment;πuse crate::Used;πuse crate::Namespace::*;π
StructsΒ§
- Macro
Rules πDecl - Name declaration produced by a
macro_rulesitem definition. Not modularized, can shadow previousmacro_rulesdefinitions, etc.
EnumsΒ§
- Macro
Rules πScope - The scope introduced by a
macro_rules!macro. This starts at the macroβs definition and ends at the end of the macroβs parent module (named or unnamed), or even further if it escapes with#[macro_use]. Some macro invocations need to introducemacro_rulesscopes too because they can potentially expand into macro definitions.
ConstantsΒ§
- PREDEFINED_
TOOLS π
FunctionsΒ§
- fast_
print_ πpath - registered_
attr_ πtools - registered_
lint_ πtools - registered_
lint_ tools_ ast - sub_
namespace_ πmatch - Macro namespace is separated into two sub-namespaces, one for bang macros and one for attribute-like macros (attributes, derives). We ignore resolutions from one sub-namespace when searching names in scope for another.
Type AliasesΒ§
- Macro
Rules πScope Ref macro_rules!scopes are always kept by reference and inside a cell. The reason is that we update scopes with valueMacroRulesScope::Invocation(invoc_id)in-place afterinvoc_idgets expanded. This helps to avoid uncontrollable growth ofmacro_rules!scope chains, which usually grow linearly with the number of macro invocations in a module (including derives) and hurt performance.