Expand description
This crate is responsible for the part of name resolution that doesnβt require type checker.
Module structure of the crate is built here. Paths in macros, imports, expressions, types, patterns are resolved here. Label and lifetime names are resolved here as well.
Type-relative name resolution (methods, fields, associated items) happens in rustc_hir_analysis.
Re-exportsΒ§
pub(crate) use diagnostics::ParamKindInEnumDiscriminant;πpub(crate) use diagnostics::ParamKindInNonTrivialAnonConst;πpub(crate) use effective_visibilities::EffectiveVisibilitiesVisitor;πpub(crate) use hygiene::Macros20NormalizedSyntaxContext;πpub(crate) use imports::Import;πpub(crate) use imports::ImportData;πpub(crate) use imports::ImportKind;πpub(crate) use imports::NameResolution;πpub(crate) use imports::PendingDecl;πpub(crate) use late::ConstantRequiresType;πpub(crate) use late::ForwardGenericParamBanReason;πpub(crate) use late::HasGenericParams;πpub(crate) use late::PathSource;πpub(crate) use late::PatternSource;πpub(crate) use late::UnnecessaryQualification;πpub use macros::registered_lint_tools_ast;pub(crate) use macros::MacroRulesDecl;πpub(crate) use macros::MacroRulesScope;πpub(crate) use macros::MacroRulesScopeRef;πpub(crate) use crate::diagnostics::impls::ImportSuggestion;πpub(crate) use crate::diagnostics::impls::LabelSuggestion;πpub(crate) use crate::diagnostics::impls::OnUnknownData;πpub(crate) use crate::diagnostics::impls::StructCtor;πpub(crate) use crate::diagnostics::impls::Suggestion;πpub(crate) use crate::imports::ImportResolution;πpub(crate) use crate::imports::NameResolutionRef;πpub(crate) use crate::ref_mut::speculative::SpeculativeFlag;πpub(crate) use crate::ref_mut::CmCell;πpub(crate) use crate::ref_mut::CmRef;πpub(crate) use crate::ref_mut::CmRefCell;πpub(crate) use rustc_hir::def::Namespace;πpub(crate) use std::cell::RefMut;πpub(crate) use std::collections::BTreeSet;πpub(crate) use std::ops::ControlFlow;πpub(crate) use Arc;πpub(crate) use OnceLock;πpub(crate) use fmt;πpub(crate) use mem;πpub(crate) use DroplessArena;πpub(crate) use TypedArena;πpub(crate) use rustc_ast::node_id::NodeMap;πpub(crate) use rustc_ast as ast;πpub(crate) use AngleBracketedArg;πpub(crate) use CRATE_NODE_ID;πpub(crate) use Crate;πpub(crate) use DUMMY_NODE_ID;πpub(crate) use Expr;πpub(crate) use ExprKind;πpub(crate) use GenericArg;πpub(crate) use GenericArgs;πpub(crate) use Generics;πpub(crate) use NodeId;πpub(crate) use Path;πpub(crate) use attr;πpub(crate) use LanguageItems;πpub(crate) use StrippedCfgItem;πpub(crate) use find_attr;πpub(crate) use FxHashMap;πpub(crate) use FxHashSet;πpub(crate) use FxIndexMap;πpub(crate) use FxIndexSet;πpub(crate) use default;πpub(crate) use rustc_data_structures::intern::Interned;πpub(crate) use rustc_data_structures::steal::Steal;πpub(crate) use FreezeReadGuard;πpub(crate) use FreezeWriteGuard;πpub(crate) use Lock;πpub(crate) use RwLock;πpub(crate) use WorkerLocal;πpub(crate) use UnordItems;πpub(crate) use UnordMap;πpub(crate) use UnordSet;πpub(crate) use Applicability;πpub(crate) use Diag;πpub(crate) use ErrCode;πpub(crate) use ErrorGuaranteed;πpub(crate) use LintBuffer;πpub(crate) use DeriveResolution;πpub(crate) use SyntaxExtension;πpub(crate) use SyntaxExtensionKind;πpub(crate) use BUILTIN_ATTRIBUTES;πpub(crate) use Features;πpub(crate) use Namespace;πpub(crate) use def;πpub(crate) use CtorOf;πpub(crate) use DefKind;πpub(crate) use MacroKinds;πpub(crate) use NonMacroAttrKind;πpub(crate) use PerNS;πpub(crate) use CRATE_DEF_ID;πpub(crate) use CrateNum;πpub(crate) use DefId;πpub(crate) use LOCAL_CRATE;πpub(crate) use LocalDefId;πpub(crate) use LocalDefIdMap;πpub(crate) use PerParentDisambiguatorState;πpub(crate) use PerParentDisambiguatorsMap;πpub(crate) use PrimTy;πpub(crate) use TraitCandidate;πpub(crate) use rustc_index::bit_set::DenseBitSet;πpub(crate) use rustc_lint_defs::builtin::PRIVATE_MACRO_USE;πpub(crate) use rustc_metadata::creader::CStore;πpub(crate) use rustc_middle::middle::privacy::EffectiveVisibilities;πpub(crate) use AmbigModChild;πpub(crate) use DelegationInfo;πpub(crate) use DelegationInherentFnKind;πpub(crate) use DocLinkResMap;πpub(crate) use MainDefinition;πpub(crate) use ModChild;πpub(crate) use PartialRes;πpub(crate) use PerOwnerResolverData;πpub(crate) use Reexport;πpub(crate) use ResolverAstLowering;πpub(crate) use ResolverGlobalCtxt;πpub(crate) use rustc_middle::query::Providers;πpub(crate) use ty;πpub(crate) use RegisteredTools;πpub(crate) use TyCtxt;πpub(crate) use TyCtxtFeed;πpub(crate) use Visibility;πpub(crate) use LocalModId;πpub(crate) use ModId;πpub(crate) use ExpnId;πpub(crate) use LocalExpnId;πpub(crate) use MacroKind;πpub(crate) use SyntaxContext;πpub(crate) use Transparency;πpub(crate) use DUMMY_SP;πpub(crate) use Ident;πpub(crate) use OrdSpan;πpub(crate) use Span;πpub(crate) use Symbol;πpub(crate) use bug;πpub(crate) use kw;πpub(crate) use span_bug;πpub(crate) use sym;πpub(crate) use rustc_structures::CrateType;πpub(crate) use SmallVec;πpub(crate) use smallvec;πpub(crate) use debug;πpub(crate) use instrument;πpub(crate) use instrument;πpub(crate) use rustc_hir::def::Namespace::*;π
ModulesΒ§
- build_
reduced_ πgraph - After we obtain a fresh AST fragment from a macro, code in this module helps to integrate that fragment into the module structures that are already partially built.
- check_
unused π - def_
collector π - diagnostics π
- effective_
visibilities π - hygiene π
- ident π
- imports π
- A bunch of methods and structures more or less related to resolving imports.
- late π
- βLate resolutionβ is the pass that resolves most of names in a crate beside imports and macros. It runs when the crate is fully expanded and its module structure is fully built. So it just walks through the crate and resolves all the expressions, types, etc.
- macros π
- A bunch of methods and structures more or less related to resolving macros and
interface provided by
Resolverto macro expander. - ref_mut π
- rustdoc
StructsΒ§
- Ambiguity
Error π - Binding
Error π - Binding
Key π - A key that identifies a binding in a given
Module. - Decl
Data π - Data associated with any name declaration.
- Delayed
VisResolution πError - Delegation
FnSig π - Derive
Data π - Extern
Module π - Same as
Module, but is guaranteed to be from an external crate. - Extern
Prelude πEntry - Finalize π
- Invariant: if
Finalizeis used, expansion and import resolution must be complete. - Ident
Key π - Combination of a symbol and its macros 2.0 normalized hygiene context.
Used as a key in various kinds of name containers, including modules (as a part of slightly
larger
BindingKey) and preludes. - Import
Summary π - Parts of import data required for finalizing import resolution.
Does not carry a lifetime, so it can be stored in
Finalize. - Invocation
Parent π - Local
Module π - Same as
Module, but is guaranteed to be from the current crate. - Module π
Internedis used because values of this type have βidentityβ and compare as unequal even if they have the same contents.- Module
Data π - One node in the tree of modules.
- Parent
Scope π - Everything you need to know about a nameβs location to resolve it. Serves as a starting point for the scope visitor. This struct is currently used only for early resolution (imports and macros), but not for late resolution yet.
- Privacy
Error π - Resolver
- The main resolver class.
- Resolver
Arenas - This provides memory for the rest of the crate. The
'ralifetime that is used by many types in this crate is an abbreviation ofResolverArenas. - Resolver
Outputs - Segment π
- A minimal representation of a path segment. We use this in resolve because we synthesize βpath
segmentsβ which donβt have the rest of an AST or HIR
PathSegment. - UseError π
EnumsΒ§
- Ambiguity
Kind π - Ambiguity
Warning π - Decl
Kind π - Name declaration kind.
- Determinacy π
- Impl
Trait πContext - Late
Decl π - Name declaration used during late resolution.
- Module
Kind π - Module
OrUniform πRoot - Path
Result π - Resolution
Error π - Resolutions π
- Scope π
- A specific scope in which a name can be looked up.
- Scope
Set π - Names from different contexts may want to visit different subsets of all specific scopes with different restrictions when looking up the resolution.
- Stage π
- Used π
- Used for tracking import use types which will be used for redundant import checking.
- VisResolution
Error π
FunctionsΒ§
- build_
extern_ πprelude - module_
to_ πstring - A somewhat inefficient routine to obtain the name of a module.
- names_
to_ πstring - path_
names_ πto_ string - provide
- with_
owner π - with_
owner_ πtables
Type AliasesΒ§
- CmResolver π
- A wrapper around
&mut Resolverthat may be mutable or immutable, depending on a conditions. - Decl π
Internedis used because values of this type have βidentityβ and compare as unequal even if they have the same contents.- Res π
- Resolution
Table π