Crate rustc_resolve[−][src]
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_typeck.
Modules
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.
A bunch of methods and structures more or less related to resolving imports.
This module contains all the defined keyword Symbols.
“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.
A bunch of methods and structures more or less related to resolving macros and
interface provided by Resolver to macro expander.
This module contains all the defined non-keyword Symbols.
Defines how the compiler represents types internally.
AST walker. Each overridden visit method has full control over what
happens with its node, it can do its own traversal of the node’s children,
call visit::walk_* to apply the default traversal algorithm, or prevent
deeper traversal by doing nothing.
Functionality for ordering and comparison.
Utilities for formatting and printing Strings.
Composable external iteration.
Manually manage memory through raw pointers.
Macros
Constructs an event at the debug level.
Structs
A key that identifies a binding in a given Module.
A DefId identifies a particular definition, by combining a crate
index and a def index.
A unique identifier that we can use to lookup a definition
precisely. It combines the index of the definition’s parent (if
any) with a DisambiguatedDefPathData.
A DefPathHash is a fixed-size representation of a DefPath that is
stable across crate and compilation session boundaries. It consists of two
separate 64-bit hashes. The first uniquely identifies the crate this
DefPathHash originates from (see StableCrateId), and the second
uniquely identifies the corresponding DefPath within that crate. Together
they form a unique identifier within an entire crate graph.
The definition table containing node definitions.
It holds the DefPathTable for LocalDefIds/DefPaths.
It also stores mappings to convert LocalDefIds to/from HirIds.
Used for emitting structured error messages and other diagnostic information.
An arena that can hold objects of multiple different types that impl Copy
and/or satisfy !mem::needs_drop.
A unique ID associated with a macro invocation and expansion.
An expression.
A LocalDefId is equivalent to a DefId with krate == LOCAL_CRATE. Since
we encode this information in the type, we can ensure at compile time that
no DefIds from upstream crates get thrown into the mix. There are quite a
few cases where we know that only DefIds from the local crate are expected
and a DefId from a different crate would signify a bug somewhere. This
is when LocalDefId comes in handy.
A unique ID associated with a macro invocation and expansion.
One node in the tree of modules.
Records a possibly-private value, type, or module definition.
Identifies an AST node.
An owned smart pointer.
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.
The result of resolving a path before lowering to HIR,
with “module” segments resolved and associated item
segments deferred to type checking.
base_res is the resolution of the resolved part of the
path, unresolved_segments is the number of unresolved
segments.
A “Path” is essentially Rust’s notion of a name.
Just a helper ‒ separate structure for each namespace.
A wrapper around reference that compares and hashes like a pointer.
Can be used as a key in sets/maps indexed by pointers to avoid unsafe.
The main resolver class.
Nothing really interesting here; it just provides memory for the rest of the crate.
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.
Represents the data associated with a compilation session for a single crate.
A Vec-like container that can store a small number of elements inline.
A compressed span.
This is the context state available during incr. comp. hashing. It contains
enough information to transform DefIds and HirIds into stable DefPaths (i.e.,
a reference to the TyCtxt) and it holds a few caches for speeding up various
things (e.g., each DefId/DefPath is only hashed once).
An interned string.
A SyntaxContext represents a chain of pairs (ExpnId, Transparency) named “marks”.
A struct representing a macro definition in “lowered” form ready for expansion.
An arena that can hold objects of only one type.
A set based on a B-Tree.
A mutable memory location.
A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.
A mutable memory location with dynamically checked borrow rules
Enums
Miscellaneous bits of metadata for better ambiguity error reporting.
Indicates the confidence in the correctness of a suggestion.
Used for better errors for E0773
Encodes if a DefKind::Ctor is the constructor of an enum variant or a struct.
What kind of definition something is; e.g., mod vs struct.
Expansion kind.
An intermediate resolution result.
Literal kind.
The kind of macro invocation or definition.
Module item kind.
Different kinds of symbols can coexist even if they share the same textual name. Therefore, they each have a separate universe (known as a “namespace”).
An attribute that is not a macro; e.g., #[inline] or #[rustfmt::skip].
A specific scope in which a name can be looked up. This enum is currently used only for early resolution (imports and macros), but not for late resolution yet.
Names from different contexts may want to visit different subsets of all specific scopes with different restrictions when looking up the resolution. This enum is currently used only for early resolution (imports and macros), but not for late resolution yet.
A syntax extension kind.
A property of a macro expansion that determines how identifiers produced by that expansion are resolved.
Used to tell an operation whether it should exit early or go on as usual.
Constants
The crate root is always assigned index 0 by the AST Map code,
thanks to NodeCollector::new.
The NodeId used to represent the root of the crate.
Dummy span, both position and length are zero, syntax context is zero as well.
Item definitions in the currently-compiled crate would have the CrateNum
LOCAL_CRATE in their DefId.
Traits
A store of Rust crates, through which their metadata can be accessed.
Each method of the Visitor trait is a hook to be potentially
overridden. Each method’s default implementation recursively visits
the substructure of the input via the corresponding walk method;
e.g., the visit_item method by default calls visit::walk_item.
Functions
Construct a P<T> from a T value.
A somewhat inefficient routine to obtain the name of a module.
Type Definitions
This is the replacement export map. It maps a module to all of the exports within.
Type alias for a hashmap using the fx hash algorithm.
Type alias for a hashmap using the fx hash algorithm.