[−][src]Struct rustc_resolve::Resolver
The main resolver class.
This is the visitor that walks the whole crate.
Fields
session: &'a Sessiondefinitions: Definitionsgraph_root: &'a ModuleData<'a>prelude: Option<&'a ModuleData<'a>>extern_prelude: FxHashMap<Ident, ExternPreludeEntry<'a>>has_self: FxHashSet<DefId>N.B., this is used only for better diagnostics, not name resolution itself.
field_names: FxHashMap<DefId, Vec<Spanned<Symbol>>>Names of fields of an item DefId accessible with dot syntax.
Used for hints during error reporting.
determined_imports: Vec<&'a Import<'a>>All imports known to succeed or fail.
indeterminate_imports: Vec<&'a Import<'a>>All non-determined imports.
last_import_segment: boolFIXME: Refactor things so that these fields are passed through arguments and not resolver. We are resolving a last import segment during import validation.
unusable_binding: Option<&'a NameBinding<'a>>This binding should be ignored during in-module resolution, so that we don't get "self-confirming" import resolutions during import validation.
primitive_type_table: PrimitiveTypeTableThe idents for the primitive types.
partial_res_map: NodeMap<PartialRes>Resolutions for nodes that have a single resolution.
import_res_map: NodeMap<PerNS<Option<Res<NodeId>>>>Resolutions for import nodes, which have multiple resolutions in different namespaces.
label_res_map: NodeMap<NodeId>Resolutions for labels (node IDs of their corresponding blocks or loops).
extern_crate_map: FxHashMap<LocalDefId, CrateNum>CrateNum resolutions of extern crate items.
export_map: ExportMap<LocalDefId>trait_map: NodeMap<Vec<TraitCandidate>>block_map: NodeMap<&'a ModuleData<'a>>A map from nodes to anonymous modules. Anonymous modules are pseudo-modules that are implicitly created around items contained within blocks.
For example, if we have this:
fn f() { fn g() { ... } }
There will be an anonymous module created around g with the ID of the
entry block for f.
empty_module: &'a ModuleData<'a>A fake module that contains no definition and no prelude. Used so that some AST passes can generate identifiers that only resolve to local or language items.
module_map: FxHashMap<LocalDefId, &'a ModuleData<'a>>extern_module_map: FxHashMap<DefId, &'a ModuleData<'a>>binding_parent_modules: FxHashMap<PtrKey<'a, NameBinding<'a>>, &'a ModuleData<'a>>underscore_disambiguator: u32glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>Maps glob imports to the names of items actually imported.
visibilities: FxHashMap<LocalDefId, Visibility>Visibilities in "lowered" form, for all entities that have them.
used_imports: FxHashSet<(NodeId, Namespace)>maybe_unused_trait_imports: FxHashSet<LocalDefId>maybe_unused_extern_crates: Vec<(LocalDefId, Span)>privacy_errors: Vec<PrivacyError<'a>>Privacy errors are delayed until the end in order to deduplicate them.
ambiguity_errors: Vec<AmbiguityError<'a>>Ambiguity errors are delayed for deduplication.
use_injections: Vec<UseError<'a>>use injections are delayed for better placement and deduplication.
macro_expanded_macro_export_errors: BTreeSet<(Span, Span)>Crate-local macro expanded macro_export referred to by a module-relative path.
arenas: &'a ResolverArenas<'a>dummy_binding: &'a NameBinding<'a>crate_loader: CrateLoader<'a>macro_names: FxHashSet<Ident>builtin_macros: FxHashMap<Symbol, BuiltinMacroState>registered_attrs: FxHashSet<Ident>registered_tools: FxHashSet<Ident>macro_use_prelude: FxHashMap<Symbol, &'a NameBinding<'a>>all_macros: FxHashMap<Symbol, Res<NodeId>>macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>dummy_ext_bang: Lrc<SyntaxExtension>dummy_ext_derive: Lrc<SyntaxExtension>non_macro_attrs: [Lrc<SyntaxExtension>; 2]local_macro_def_scopes: FxHashMap<LocalDefId, &'a ModuleData<'a>>ast_transform_scopes: FxHashMap<ExpnId, &'a ModuleData<'a>>unused_macros: FxHashMap<LocalDefId, (NodeId, Span)>proc_macro_stubs: FxHashSet<LocalDefId>single_segment_macro_resolutions: Vec<(Ident, MacroKind, ParentScope<'a>, Option<&'a NameBinding<'a>>)>Traces collected during macro resolution and validated when it's complete.
multi_segment_macro_resolutions: Vec<(Vec<Segment>, Span, MacroKind, ParentScope<'a>, Option<Res<NodeId>>)>builtin_attrs: Vec<(Ident, ParentScope<'a>)>containers_deriving_copy: FxHashSet<ExpnId>derive(Copy) marks items they are applied to so they are treated specially later.
Derive macros cannot modify the item themselves and have to store the markers in the global
context, so they attach the markers to derive container IDs using this resolver table.
invocation_parent_scopes: FxHashMap<ExpnId, ParentScope<'a>>Parent scopes in which the macros were invoked.
FIXME: derives are missing in these parent scopes and need to be taken from elsewhere.
output_macro_rules_scopes: FxHashMap<ExpnId, PtrKey<'a, Cell<MacroRulesScope<'a>>>>macro_rules scopes produced by expanding the macro invocations,
include all the macro_rules items and other invocations generated by them.
helper_attrs: FxHashMap<ExpnId, Vec<Ident>>Helper attributes that are in scope for the given expansion.
name_already_seen: FxHashMap<Symbol, Span>Avoid duplicated errors for "name already defined".
potentially_unused_imports: Vec<&'a Import<'a>>struct_constructors: DefIdMap<(Res<NodeId>, Visibility, Vec<Visibility>)>Table for mapping struct IDs into struct constructor IDs, it's not used during normal resolution, only for better error reporting. Also includes of list of each fields visibility
active_features: FxHashSet<Symbol>Features enabled for this crate.
lint_buffer: LintBuffernext_node_id: NodeIddef_id_to_span: IndexVec<LocalDefId, Span>node_id_to_def_id: FxHashMap<NodeId, LocalDefId>def_id_to_node_id: IndexVec<LocalDefId, NodeId>placeholder_field_indices: FxHashMap<NodeId, usize>Indices of unnamed struct or variant fields with unresolved attributes.
invocation_parents: FxHashMap<ExpnId, LocalDefId>When collecting definitions from an AST fragment produced by a macro invocation ExpnId
we know what parent node that fragment should be attached to thanks to this table.
next_disambiguator: FxHashMap<(LocalDefId, DefPathData), u32>trait_impl_items: FxHashSet<LocalDefId>Some way to know that we are in a trait impl in visit_assoc_item.
FIXME: Replace with a more general AST map (together with some other fields).
Implementations
impl<'a> Resolver<'a>[src]
pub(crate) fn define<T>(
&mut self,
parent: &'a ModuleData<'a>,
ident: Ident,
ns: Namespace,
def: T
) where
T: ToNameBinding<'a>, [src]
&mut self,
parent: &'a ModuleData<'a>,
ident: Ident,
ns: Namespace,
def: T
) where
T: ToNameBinding<'a>,
Defines name in namespace ns of module parent to be def if it is not yet defined;
otherwise, reports an error.
pub(in build_reduced_graph) fn nearest_mod_parent(
&mut self,
def_id: DefId
) -> &'a ModuleData<'a>[src]
&mut self,
def_id: DefId
) -> &'a ModuleData<'a>
Walks up the tree of definitions starting at def_id,
stopping at the first DefKind::Mod encountered
pub(crate) fn get_module(&mut self, def_id: DefId) -> &'a ModuleData<'a>[src]
pub(crate) fn macro_def_scope(&mut self, expn_id: ExpnId) -> &'a ModuleData<'a>[src]
pub(crate) fn get_macro(
&mut self,
res: Res<NodeId>
) -> Option<Lrc<SyntaxExtension>>[src]
&mut self,
res: Res<NodeId>
) -> Option<Lrc<SyntaxExtension>>
pub(crate) fn get_macro_by_def_id(
&mut self,
def_id: DefId
) -> Option<Lrc<SyntaxExtension>>[src]
&mut self,
def_id: DefId
) -> Option<Lrc<SyntaxExtension>>
pub(crate) fn build_reduced_graph(
&mut self,
fragment: &AstFragment,
parent_scope: ParentScope<'a>
) -> PtrKey<'a, Cell<MacroRulesScope<'a>>>[src]
&mut self,
fragment: &AstFragment,
parent_scope: ParentScope<'a>
) -> PtrKey<'a, Cell<MacroRulesScope<'a>>>
pub(crate) fn build_reduced_graph_external(
&mut self,
module: &'a ModuleData<'a>
)[src]
&mut self,
module: &'a ModuleData<'a>
)
impl<'_> Resolver<'_>[src]
pub(crate) fn check_unused(&mut self, krate: &Crate)[src]
impl<'a> Resolver<'a>[src]
pub(crate) fn add_module_candidates(
&mut self,
module: &'a ModuleData<'a>,
names: &mut Vec<TypoSuggestion>,
filter_fn: &impl Fn(Res<NodeId>) -> bool
)[src]
&mut self,
module: &'a ModuleData<'a>,
names: &mut Vec<TypoSuggestion>,
filter_fn: &impl Fn(Res<NodeId>) -> bool
)
pub(crate) fn report_error(
&self,
span: Span,
resolution_error: ResolutionError<'_>
)[src]
&self,
span: Span,
resolution_error: ResolutionError<'_>
)
Combines an error with provided span and emits it.
This takes the error provided, combines it with the span and any additional spans inside the error and emits it.
pub(crate) fn into_struct_error(
&self,
span: Span,
resolution_error: ResolutionError<'_>
) -> DiagnosticBuilder<'_>[src]
&self,
span: Span,
resolution_error: ResolutionError<'_>
) -> DiagnosticBuilder<'_>
pub(crate) fn report_vis_error(
&self,
vis_resolution_error: VisResolutionError<'_>
)[src]
&self,
vis_resolution_error: VisResolutionError<'_>
)
pub(in diagnostics) fn early_lookup_typo_candidate(
&mut self,
scope_set: ScopeSet,
parent_scope: &ParentScope<'a>,
ident: Ident,
filter_fn: &impl Fn(Res<NodeId>) -> bool
) -> Option<TypoSuggestion>[src]
&mut self,
scope_set: ScopeSet,
parent_scope: &ParentScope<'a>,
ident: Ident,
filter_fn: &impl Fn(Res<NodeId>) -> bool
) -> Option<TypoSuggestion>
Lookup typo candidate in scope for a macro or import.
pub(in diagnostics) fn lookup_import_candidates_from_module<FilterFn>(
&mut self,
lookup_ident: Ident,
namespace: Namespace,
parent_scope: &ParentScope<'a>,
start_module: &'a ModuleData<'a>,
crate_name: Ident,
filter_fn: FilterFn
) -> Vec<ImportSuggestion> where
FilterFn: Fn(Res<NodeId>) -> bool, [src]
&mut self,
lookup_ident: Ident,
namespace: Namespace,
parent_scope: &ParentScope<'a>,
start_module: &'a ModuleData<'a>,
crate_name: Ident,
filter_fn: FilterFn
) -> Vec<ImportSuggestion> where
FilterFn: Fn(Res<NodeId>) -> bool,
pub(crate) fn lookup_import_candidates<FilterFn>(
&mut self,
lookup_ident: Ident,
namespace: Namespace,
parent_scope: &ParentScope<'a>,
filter_fn: FilterFn
) -> Vec<ImportSuggestion> where
FilterFn: Fn(Res<NodeId>) -> bool, [src]
&mut self,
lookup_ident: Ident,
namespace: Namespace,
parent_scope: &ParentScope<'a>,
filter_fn: FilterFn
) -> Vec<ImportSuggestion> where
FilterFn: Fn(Res<NodeId>) -> bool,
When name resolution fails, this method can be used to look up candidate entities with the expected name. It allows filtering them using the supplied predicate (which should be used to only accept the types of definitions expected, e.g., traits). The lookup spans across all crates.
N.B., the method does not look into imports, but this is not a problem, since we report the definitions (thus, the de-aliased imports).
pub(crate) fn unresolved_macro_suggestions(
&mut self,
err: &mut DiagnosticBuilder<'a>,
macro_kind: MacroKind,
parent_scope: &ParentScope<'a>,
ident: Ident
)[src]
&mut self,
err: &mut DiagnosticBuilder<'a>,
macro_kind: MacroKind,
parent_scope: &ParentScope<'a>,
ident: Ident
)
pub(crate) fn add_typo_suggestion(
&self,
err: &mut DiagnosticBuilder<'_>,
suggestion: Option<TypoSuggestion>,
span: Span
) -> bool[src]
&self,
err: &mut DiagnosticBuilder<'_>,
suggestion: Option<TypoSuggestion>,
span: Span
) -> bool
pub(in diagnostics) fn binding_description(
&self,
b: &NameBinding<'_>,
ident: Ident,
from_prelude: bool
) -> String[src]
&self,
b: &NameBinding<'_>,
ident: Ident,
from_prelude: bool
) -> String
pub(crate) fn report_ambiguity_error(
&self,
ambiguity_error: &AmbiguityError<'_>
)[src]
&self,
ambiguity_error: &AmbiguityError<'_>
)
pub(in diagnostics) fn ctor_fields_span(
&self,
binding: &NameBinding<'_>
) -> Option<Span>[src]
&self,
binding: &NameBinding<'_>
) -> Option<Span>
If the binding refers to a tuple struct constructor with fields, returns the span of its fields.
pub(crate) fn report_privacy_error(&self, privacy_error: &PrivacyError<'_>)[src]
impl<'a> Resolver<'a>[src]
pub(crate) fn resolve_ident_in_module_unadjusted(
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, Determinacy>[src]
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, Determinacy>
pub(crate) fn resolve_ident_in_module_unadjusted_ext(
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
restricted_shadowing: bool,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)>[src]
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
restricted_shadowing: bool,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)>
Attempts to resolve ident in namespaces ns of module.
Invariant: if record_used is Some, expansion and import resolution must be complete.
pub(crate) fn import(
&self,
binding: &'a NameBinding<'a>,
import: &'a Import<'a>
) -> &'a NameBinding<'a>[src]
&self,
binding: &'a NameBinding<'a>,
import: &'a Import<'a>
) -> &'a NameBinding<'a>
pub(crate) fn try_define(
&mut self,
module: &'a ModuleData<'a>,
key: BindingKey,
binding: &'a NameBinding<'a>
) -> Result<(), &'a NameBinding<'a>>[src]
&mut self,
module: &'a ModuleData<'a>,
key: BindingKey,
binding: &'a NameBinding<'a>
) -> Result<(), &'a NameBinding<'a>>
pub(in imports) fn ambiguity(
&self,
kind: AmbiguityKind,
primary_binding: &'a NameBinding<'a>,
secondary_binding: &'a NameBinding<'a>
) -> &'a NameBinding<'a>[src]
&self,
kind: AmbiguityKind,
primary_binding: &'a NameBinding<'a>,
secondary_binding: &'a NameBinding<'a>
) -> &'a NameBinding<'a>
pub(in imports) fn update_resolution<T, F>(
&mut self,
module: &'a ModuleData<'a>,
key: BindingKey,
f: F
) -> T where
F: FnOnce(&mut Resolver<'a>, &mut NameResolution<'a>) -> T, [src]
&mut self,
module: &'a ModuleData<'a>,
key: BindingKey,
f: F
) -> T where
F: FnOnce(&mut Resolver<'a>, &mut NameResolution<'a>) -> T,
pub(in imports) fn import_dummy_binding(
&mut self,
import: &'a Import<'a>
)[src]
&mut self,
import: &'a Import<'a>
)
impl<'a> Resolver<'a>[src]
pub(crate) fn late_resolve_crate(&mut self, krate: &Crate)[src]
impl<'a> Resolver<'a>[src]
pub(in macros) fn smart_resolve_macro_path(
&mut self,
path: &Path,
kind: MacroKind,
require_inert: bool,
inner_attr: bool,
parent_scope: &ParentScope<'a>,
node_id: NodeId,
force: bool
) -> Result<(Lrc<SyntaxExtension>, Res<NodeId>), Indeterminate>[src]
&mut self,
path: &Path,
kind: MacroKind,
require_inert: bool,
inner_attr: bool,
parent_scope: &ParentScope<'a>,
node_id: NodeId,
force: bool
) -> Result<(Lrc<SyntaxExtension>, Res<NodeId>), Indeterminate>
Resolve macro path with error reporting and recovery. Uses dummy syntax extensions for unresolved macros or macros with unexpected resolutions for better error recovery.
pub fn resolve_macro_path(
&mut self,
path: &Path,
kind: Option<MacroKind>,
parent_scope: &ParentScope<'a>,
trace: bool,
force: bool
) -> Result<(Option<Lrc<SyntaxExtension>>, Res<NodeId>), Determinacy>[src]
&mut self,
path: &Path,
kind: Option<MacroKind>,
parent_scope: &ParentScope<'a>,
trace: bool,
force: bool
) -> Result<(Option<Lrc<SyntaxExtension>>, Res<NodeId>), Determinacy>
pub(crate) fn early_resolve_ident_in_lexical_scope(
&mut self,
orig_ident: Ident,
scope_set: ScopeSet,
parent_scope: &ParentScope<'a>,
record_used: bool,
force: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, Determinacy>[src]
&mut self,
orig_ident: Ident,
scope_set: ScopeSet,
parent_scope: &ParentScope<'a>,
record_used: bool,
force: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, Determinacy>
pub(crate) fn finalize_macro_resolutions(&mut self)[src]
pub(in macros) fn check_stability_and_deprecation(
&mut self,
ext: &SyntaxExtension,
path: &Path,
node_id: NodeId
)[src]
&mut self,
ext: &SyntaxExtension,
path: &Path,
node_id: NodeId
)
pub(in macros) fn prohibit_imported_non_macro_attrs(
&self,
binding: Option<&'a NameBinding<'a>>,
res: Option<Res<NodeId>>,
span: Span
)[src]
&self,
binding: Option<&'a NameBinding<'a>>,
res: Option<Res<NodeId>>,
span: Span
)
pub(crate) fn check_reserved_macro_name(
&mut self,
ident: Ident,
res: Res<NodeId>
)[src]
&mut self,
ident: Ident,
res: Res<NodeId>
)
pub(crate) fn compile_macro(
&mut self,
item: &Item,
edition: Edition
) -> SyntaxExtension[src]
&mut self,
item: &Item,
edition: Edition
) -> SyntaxExtension
Compile the macro into a SyntaxExtension and possibly replace
its expander to a pre-defined one for built-in macros.
impl<'a> Resolver<'a>[src]
pub fn new(
session: &'a Session,
krate: &Crate,
crate_name: &str,
metadata_loader: &'a MetadataLoaderDyn,
arenas: &'a ResolverArenas<'a>
) -> Resolver<'a>[src]
session: &'a Session,
krate: &Crate,
crate_name: &str,
metadata_loader: &'a MetadataLoaderDyn,
arenas: &'a ResolverArenas<'a>
) -> Resolver<'a>
pub fn next_node_id(&mut self) -> NodeId[src]
pub fn lint_buffer(&mut self) -> &mut LintBuffer[src]
pub fn arenas() -> ResolverArenas<'a>[src]
pub fn into_outputs(self) -> ResolverOutputs[src]
pub fn clone_outputs(&self) -> ResolverOutputs[src]
pub fn cstore(&self) -> &CStore[src]
pub(crate) fn non_macro_attr(&self, mark_used: bool) -> Lrc<SyntaxExtension>[src]
pub(crate) fn dummy_ext(&self, macro_kind: MacroKind) -> Lrc<SyntaxExtension>[src]
pub(crate) fn per_ns<F: FnMut(&mut Self, Namespace)>(&mut self, f: F)[src]
Runs the function on each namespace.
pub(crate) fn is_builtin_macro(&mut self, res: Res<NodeId>) -> bool[src]
pub(crate) fn macro_def(&self, ctxt: SyntaxContext) -> DefId[src]
pub fn resolve_crate(&mut self, krate: &Crate)[src]
Entry point to crate resolution.
pub(crate) fn get_traits_in_module_containing_item(
&mut self,
ident: Ident,
ns: Namespace,
module: &'a ModuleData<'a>,
found_traits: &mut Vec<TraitCandidate>,
parent_scope: &ParentScope<'a>
)[src]
&mut self,
ident: Ident,
ns: Namespace,
module: &'a ModuleData<'a>,
found_traits: &mut Vec<TraitCandidate>,
parent_scope: &ParentScope<'a>
)
pub(crate) fn find_transitive_imports(
&mut self,
kind: &NameBindingKind<'_>,
trait_name: Ident
) -> SmallVec<[LocalDefId; 1]>[src]
&mut self,
kind: &NameBindingKind<'_>,
trait_name: Ident
) -> SmallVec<[LocalDefId; 1]>
pub(crate) fn new_module(
&self,
parent: &'a ModuleData<'a>,
kind: ModuleKind,
normal_ancestor_id: DefId,
expn_id: ExpnId,
span: Span
) -> &'a ModuleData<'a>[src]
&self,
parent: &'a ModuleData<'a>,
kind: ModuleKind,
normal_ancestor_id: DefId,
expn_id: ExpnId,
span: Span
) -> &'a ModuleData<'a>
pub(crate) fn new_key(&mut self, ident: Ident, ns: Namespace) -> BindingKey[src]
pub(crate) fn resolutions(
&mut self,
module: &'a ModuleData<'a>
) -> &'a RefCell<FxIndexMap<BindingKey, &'a RefCell<NameResolution<'a>>>>[src]
&mut self,
module: &'a ModuleData<'a>
) -> &'a RefCell<FxIndexMap<BindingKey, &'a RefCell<NameResolution<'a>>>>
pub(crate) fn resolution(
&mut self,
module: &'a ModuleData<'a>,
key: BindingKey
) -> &'a RefCell<NameResolution<'a>>[src]
&mut self,
module: &'a ModuleData<'a>,
key: BindingKey
) -> &'a RefCell<NameResolution<'a>>
pub(crate) fn record_use(
&mut self,
ident: Ident,
ns: Namespace,
used_binding: &'a NameBinding<'a>,
is_lexical_scope: bool
)[src]
&mut self,
ident: Ident,
ns: Namespace,
used_binding: &'a NameBinding<'a>,
is_lexical_scope: bool
)
pub(crate) fn add_to_glob_map(&mut self, import: &Import<'_>, ident: Ident)[src]
pub(crate) fn visit_scopes<T>(
&mut self,
scope_set: ScopeSet,
parent_scope: &ParentScope<'a>,
ident: Ident,
visitor: impl FnMut(&mut Self, Scope<'a>, bool, Ident) -> Option<T>
) -> Option<T>[src]
&mut self,
scope_set: ScopeSet,
parent_scope: &ParentScope<'a>,
ident: Ident,
visitor: impl FnMut(&mut Self, Scope<'a>, bool, Ident) -> Option<T>
) -> Option<T>
A generic scope visitor.
Visits scopes in order to resolve some identifier in them or perform other actions.
If the callback returns Some result, we stop visiting scopes and return it.
pub(crate) fn resolve_ident_in_lexical_scope(
&mut self,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used_id: Option<NodeId>,
path_span: Span,
ribs: &[Rib<'a>]
) -> Option<LexicalScopeBinding<'a>>[src]
&mut self,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used_id: Option<NodeId>,
path_span: Span,
ribs: &[Rib<'a>]
) -> Option<LexicalScopeBinding<'a>>
This resolves the identifier ident in the namespace ns in the current lexical scope.
More specifically, we proceed up the hierarchy of scopes and return the binding for
ident in the first scope that defines it (or None if no scopes define it).
A block's items are above its local variables in the scope hierarchy, regardless of where the items are defined in the block. For example,
fn f() { g(); // Since there are no local variables in scope yet, this resolves to the item. let g = || {}; fn g() {} g(); // This resolves to the local variable `g` since it shadows the item. }
Invariant: This must only be called during main resolution, not during import resolution.
pub(crate) fn hygienic_lexical_parent(
&mut self,
module: &'a ModuleData<'a>,
span: &mut Span
) -> Option<&'a ModuleData<'a>>[src]
&mut self,
module: &'a ModuleData<'a>,
span: &mut Span
) -> Option<&'a ModuleData<'a>>
pub(crate) fn hygienic_lexical_parent_with_compatibility_fallback(
&mut self,
module: &'a ModuleData<'a>,
span: &mut Span,
node_id: NodeId,
poisoned: &mut Option<NodeId>
) -> Option<&'a ModuleData<'a>>[src]
&mut self,
module: &'a ModuleData<'a>,
span: &mut Span,
node_id: NodeId,
poisoned: &mut Option<NodeId>
) -> Option<&'a ModuleData<'a>>
pub(crate) fn resolve_ident_in_module(
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, Determinacy>[src]
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, Determinacy>
pub(crate) fn resolve_ident_in_module_ext(
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)>[src]
&mut self,
module: ModuleOrUniformRoot<'a>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)>
pub(crate) fn resolve_crate_root(&mut self, ident: Ident) -> &'a ModuleData<'a>[src]
pub(crate) fn resolve_self(
&mut self,
ctxt: &mut SyntaxContext,
module: &'a ModuleData<'a>
) -> &'a ModuleData<'a>[src]
&mut self,
ctxt: &mut SyntaxContext,
module: &'a ModuleData<'a>
) -> &'a ModuleData<'a>
pub(crate) fn resolve_path(
&mut self,
path: &[Segment],
opt_ns: Option<Namespace>,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span,
crate_lint: CrateLint
) -> PathResult<'a>[src]
&mut self,
path: &[Segment],
opt_ns: Option<Namespace>,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span,
crate_lint: CrateLint
) -> PathResult<'a>
pub(crate) fn resolve_path_with_ribs(
&mut self,
path: &[Segment],
opt_ns: Option<Namespace>,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span,
crate_lint: CrateLint,
ribs: Option<&PerNS<Vec<Rib<'a>>>>
) -> PathResult<'a>[src]
&mut self,
path: &[Segment],
opt_ns: Option<Namespace>,
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span,
crate_lint: CrateLint,
ribs: Option<&PerNS<Vec<Rib<'a>>>>
) -> PathResult<'a>
pub(crate) fn lint_if_path_starts_with_module(
&mut self,
crate_lint: CrateLint,
path: &[Segment],
path_span: Span,
second_binding: Option<&NameBinding<'_>>
)[src]
&mut self,
crate_lint: CrateLint,
path: &[Segment],
path_span: Span,
second_binding: Option<&NameBinding<'_>>
)
pub(crate) fn validate_res_from_ribs(
&mut self,
rib_index: usize,
rib_ident: Ident,
res: Res<NodeId>,
record_used: bool,
span: Span,
all_ribs: &[Rib<'a>]
) -> Res<NodeId>[src]
&mut self,
rib_index: usize,
rib_ident: Ident,
res: Res<NodeId>,
record_used: bool,
span: Span,
all_ribs: &[Rib<'a>]
) -> Res<NodeId>
pub(crate) fn record_partial_res(
&mut self,
node_id: NodeId,
resolution: PartialRes
)[src]
&mut self,
node_id: NodeId,
resolution: PartialRes
)
pub(crate) fn is_accessible_from(
&self,
vis: Visibility,
module: &'a ModuleData<'a>
) -> bool[src]
&self,
vis: Visibility,
module: &'a ModuleData<'a>
) -> bool
pub(crate) fn set_binding_parent_module(
&mut self,
binding: &'a NameBinding<'a>,
module: &'a ModuleData<'a>
)[src]
&mut self,
binding: &'a NameBinding<'a>,
module: &'a ModuleData<'a>
)
pub(crate) fn disambiguate_macro_rules_vs_modularized(
&self,
macro_rules: &'a NameBinding<'a>,
modularized: &'a NameBinding<'a>
) -> bool[src]
&self,
macro_rules: &'a NameBinding<'a>,
modularized: &'a NameBinding<'a>
) -> bool
pub(crate) fn report_errors(&mut self, krate: &Crate)[src]
pub(crate) fn report_with_use_injections(&mut self, krate: &Crate)[src]
pub(crate) fn report_conflict<'b>(
&mut self,
parent: &'_ ModuleData<'_>,
ident: Ident,
ns: Namespace,
new_binding: &NameBinding<'b>,
old_binding: &NameBinding<'b>
)[src]
&mut self,
parent: &'_ ModuleData<'_>,
ident: Ident,
ns: Namespace,
new_binding: &NameBinding<'b>,
old_binding: &NameBinding<'b>
)
pub(crate) fn add_suggestion_for_rename_of_use(
&self,
err: &mut DiagnosticBuilder<'_>,
name: Symbol,
import: &Import<'_>,
binding_span: Span
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
name: Symbol,
import: &Import<'_>,
binding_span: Span
)
This function adds a suggestion to change the binding name of a new import that conflicts with an existing import.
help: you can use `as` to change the binding name of the import
|
LL | use foo::bar as other_bar;
| ^^^^^^^^^^^^^^^^^^^^^
pub(crate) fn add_suggestion_for_duplicate_nested_use(
&self,
err: &mut DiagnosticBuilder<'_>,
import: &Import<'_>,
binding_span: Span
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
import: &Import<'_>,
binding_span: Span
)
This function adds a suggestion to remove a unnecessary binding from an import that is
nested. In the following example, this function will be invoked to remove the a binding
in the second use statement:
use issue_52891::a; use issue_52891::{d, a, e};
The following suggestion will be added:
use issue_52891::{d, a, e}; ^-- help: remove unnecessary import
If the nested use contains only one import then the suggestion will remove the entire line.
It is expected that the provided import is nested - this isn't checked by the function. If this invariant is not upheld, this function's behaviour will be unexpected as characters expected by span manipulations won't be present.
pub(crate) fn extern_prelude_get(
&mut self,
ident: Ident,
speculative: bool
) -> Option<&'a NameBinding<'a>>[src]
&mut self,
ident: Ident,
speculative: bool
) -> Option<&'a NameBinding<'a>>
pub fn traits_in_scope(&mut self, module_id: DefId) -> Vec<TraitCandidate>[src]
This is equivalent to get_traits_in_module_containing_item, but without filtering by the associated item.
This is used by rustdoc for intra-doc links.
pub fn resolve_str_path_error(
&mut self,
span: Span,
path_str: &str,
ns: Namespace,
module_id: DefId
) -> Result<(Path, Res<NodeId>), ()>[src]
&mut self,
span: Span,
path_str: &str,
ns: Namespace,
module_id: DefId
) -> Result<(Path, Res<NodeId>), ()>
Rustdoc uses this to resolve things in a recoverable way. ResolutionError<'a>
isn't something that can be returned because it can't be made to live that long,
and also it's a private type. Fortunately rustdoc doesn't need to know the error,
just that an error occurred.
pub(crate) fn resolve_ast_path(
&mut self,
path: &Path,
ns: Namespace,
parent_scope: &ParentScope<'a>
) -> Result<Res<NodeId>, (Span, ResolutionError<'a>)>[src]
&mut self,
path: &Path,
ns: Namespace,
parent_scope: &ParentScope<'a>
) -> Result<Res<NodeId>, (Span, ResolutionError<'a>)>
pub(crate) fn new_ast_path_segment(&mut self, ident: Ident) -> PathSegment[src]
pub fn graph_root(&self) -> &'a ModuleData<'a>[src]
pub fn all_macros(&self) -> &FxHashMap<Symbol, Res<NodeId>>[src]
pub fn opt_span(&self, def_id: DefId) -> Option<Span>[src]
Retrieves the span of the given DefId if DefId is in the local crate.
Trait Implementations
impl<'a, '_> AsMut<Resolver<'a>> for BuildReducedGraphVisitor<'a, '_>[src]
impl<'a> AsMut<Resolver<'a>> for Resolver<'a>[src]
impl<'a, 'b> DefIdTree for &'a Resolver<'b>[src]
pub fn parent(self, id: DefId) -> Option<DefId>[src]
pub fn is_descendant_of(self, descendant: DefId, ancestor: DefId) -> bool[src]
impl<'_> ResolverAstLowering for Resolver<'_>[src]
This interface is used through the AST→HIR step, to embed full paths into the HIR. After that the resolver is no longer needed as all the relevant information is inline.
pub fn def_key(&mut self, id: DefId) -> DefKey[src]
pub fn item_generics_num_lifetimes(
&self,
def_id: DefId,
sess: &Session
) -> usize[src]
&self,
def_id: DefId,
sess: &Session
) -> usize
pub fn get_partial_res(&mut self, id: NodeId) -> Option<PartialRes>[src]
pub fn get_import_res(&mut self, id: NodeId) -> PerNS<Option<Res<NodeId>>>[src]
pub fn get_label_res(&mut self, id: NodeId) -> Option<NodeId>[src]
pub fn definitions(&mut self) -> &mut Definitions[src]
pub fn lint_buffer(&mut self) -> &mut LintBuffer[src]
pub fn next_node_id(&mut self) -> NodeId[src]
pub fn trait_map(&self) -> &NodeMap<Vec<TraitCandidate>>[src]
pub fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId>[src]
pub fn local_def_id(&self, node: NodeId) -> LocalDefId[src]
pub fn create_def(
&mut self,
parent: LocalDefId,
node_id: NodeId,
data: DefPathData,
expn_id: ExpnId,
span: Span
) -> LocalDefId[src]
&mut self,
parent: LocalDefId,
node_id: NodeId,
data: DefPathData,
expn_id: ExpnId,
span: Span
) -> LocalDefId
Adds a definition with a parent definition.
impl<'a> ResolverExpand for Resolver<'a>[src]
pub fn next_node_id(&mut self) -> NodeId[src]
pub fn resolve_dollar_crates(&mut self)[src]
pub fn visit_ast_fragment_with_placeholders(
&mut self,
expansion: ExpnId,
fragment: &AstFragment
)[src]
&mut self,
expansion: ExpnId,
fragment: &AstFragment
)
pub fn register_builtin_macro(&mut self, ident: Ident, ext: SyntaxExtension)[src]
pub fn expansion_for_ast_pass(
&mut self,
call_site: Span,
pass: AstPass,
features: &[Symbol],
parent_module_id: Option<NodeId>
) -> ExpnId[src]
&mut self,
call_site: Span,
pass: AstPass,
features: &[Symbol],
parent_module_id: Option<NodeId>
) -> ExpnId
pub fn resolve_imports(&mut self)[src]
pub fn resolve_macro_invocation(
&mut self,
invoc: &Invocation,
eager_expansion_root: ExpnId,
force: bool
) -> Result<InvocationRes, Indeterminate>[src]
&mut self,
invoc: &Invocation,
eager_expansion_root: ExpnId,
force: bool
) -> Result<InvocationRes, Indeterminate>
pub fn check_unused_macros(&mut self)[src]
pub fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId[src]
pub fn has_derive_copy(&self, expn_id: ExpnId) -> bool[src]
pub fn cfg_accessible(
&mut self,
expn_id: ExpnId,
path: &Path
) -> Result<bool, Indeterminate>[src]
&mut self,
expn_id: ExpnId,
path: &Path
) -> Result<bool, Indeterminate>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Resolver<'a>
impl<'a> !Send for Resolver<'a>
impl<'a> !Sync for Resolver<'a>
impl<'a> Unpin for Resolver<'a>
impl<'a> !UnwindSafe for Resolver<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,