pub struct Resolver<'ra, 'tcx> {Show 91 fields
pub(crate) tcx: TyCtxt<'tcx>,
pub(crate) expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
pub(crate) graph_root: Module<'ra>,
pub(crate) prelude: Option<Module<'ra>>,
pub(crate) extern_prelude: FxHashMap<Ident, ExternPreludeEntry<'ra>>,
pub(crate) field_names: LocalDefIdMap<Vec<Ident>>,
pub(crate) field_visibility_spans: FxHashMap<DefId, Vec<Span>>,
pub(crate) determined_imports: Vec<Interned<'ra, ImportData<'ra>>>,
pub(crate) indeterminate_imports: Vec<Interned<'ra, ImportData<'ra>>>,
pub(crate) pat_span_map: NodeMap<Span>,
pub(crate) partial_res_map: NodeMap<PartialRes>,
pub(crate) import_res_map: NodeMap<PerNS<Option<Res<NodeId>>>>,
pub(crate) import_use_map: FxHashMap<Interned<'ra, ImportData<'ra>>, Used>,
pub(crate) label_res_map: NodeMap<NodeId>,
pub(crate) lifetimes_res_map: NodeMap<LifetimeRes>,
pub(crate) extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, LifetimeRes)>>,
pub(crate) extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
pub(crate) module_children: LocalDefIdMap<Vec<ModChild>>,
pub(crate) trait_map: NodeMap<Vec<TraitCandidate>>,
pub(crate) block_map: NodeMap<Module<'ra>>,
pub(crate) empty_module: Module<'ra>,
pub(crate) module_map: FxHashMap<DefId, Module<'ra>>,
pub(crate) binding_parent_modules: FxHashMap<Interned<'ra, NameBindingData<'ra>>, Module<'ra>>,
pub(crate) underscore_disambiguator: u32,
pub(crate) empty_disambiguator: u32,
pub(crate) glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
pub(crate) glob_error: Option<ErrorGuaranteed>,
pub(crate) visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
pub(crate) used_imports: FxHashSet<NodeId>,
pub(crate) maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
pub(crate) privacy_errors: Vec<PrivacyError<'ra>>,
pub(crate) ambiguity_errors: Vec<AmbiguityError<'ra>>,
pub(crate) use_injections: Vec<UseError<'tcx>>,
pub(crate) macro_expanded_macro_export_errors: BTreeSet<(Span, Span)>,
pub(crate) arenas: &'ra ResolverArenas<'ra>,
pub(crate) dummy_binding: Interned<'ra, NameBindingData<'ra>>,
pub(crate) builtin_types_bindings: FxHashMap<Symbol, Interned<'ra, NameBindingData<'ra>>>,
pub(crate) builtin_attrs_bindings: FxHashMap<Symbol, Interned<'ra, NameBindingData<'ra>>>,
pub(crate) registered_tool_bindings: FxHashMap<Ident, Interned<'ra, NameBindingData<'ra>>>,
pub(crate) module_self_bindings: FxHashMap<Module<'ra>, Interned<'ra, NameBindingData<'ra>>>,
pub(crate) used_extern_options: FxHashSet<Symbol>,
pub(crate) macro_names: FxHashSet<Ident>,
pub(crate) builtin_macros: FxHashMap<Symbol, BuiltinMacroState>,
pub(crate) registered_tools: &'tcx RegisteredTools,
pub(crate) macro_use_prelude: FxHashMap<Symbol, Interned<'ra, NameBindingData<'ra>>>,
pub(crate) macro_map: FxHashMap<DefId, MacroData>,
pub(crate) dummy_ext_bang: Lrc<SyntaxExtension>,
pub(crate) dummy_ext_derive: Lrc<SyntaxExtension>,
pub(crate) non_macro_attr: MacroData,
pub(crate) local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
pub(crate) ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
pub(crate) unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
pub(crate) unused_macro_rules: FxHashMap<(LocalDefId, usize), (Ident, Span)>,
pub(crate) proc_macro_stubs: FxHashSet<LocalDefId>,
pub(crate) single_segment_macro_resolutions: Vec<(Ident, MacroKind, ParentScope<'ra>, Option<Interned<'ra, NameBindingData<'ra>>>)>,
pub(crate) multi_segment_macro_resolutions: Vec<(Vec<Segment>, Span, MacroKind, ParentScope<'ra>, Option<Res<NodeId>>, Namespace)>,
pub(crate) builtin_attrs: Vec<(Ident, ParentScope<'ra>)>,
pub(crate) containers_deriving_copy: FxHashSet<LocalExpnId>,
pub(crate) invocation_parent_scopes: FxHashMap<LocalExpnId, ParentScope<'ra>>,
pub(crate) output_macro_rules_scopes: FxHashMap<LocalExpnId, Interned<'ra, Cell<MacroRulesScope<'ra>>>>,
pub(crate) macro_rules_scopes: FxHashMap<LocalDefId, Interned<'ra, Cell<MacroRulesScope<'ra>>>>,
pub(crate) helper_attrs: FxHashMap<LocalExpnId, Vec<(Ident, Interned<'ra, NameBindingData<'ra>>)>>,
pub(crate) derive_data: FxHashMap<LocalExpnId, DeriveData>,
pub(crate) name_already_seen: FxHashMap<Symbol, Span>,
pub(crate) potentially_unused_imports: Vec<Interned<'ra, ImportData<'ra>>>,
pub(crate) potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>>,
pub(crate) struct_constructors: LocalDefIdMap<(Res<NodeId>, Visibility<DefId>, Vec<Visibility<DefId>>)>,
pub(crate) lint_buffer: LintBuffer,
pub(crate) next_node_id: NodeId,
pub(crate) node_id_to_def_id: NodeMap<Feed<'tcx, LocalDefId>>,
pub(crate) def_id_to_node_id: IndexVec<LocalDefId, NodeId>,
pub(crate) placeholder_field_indices: FxHashMap<NodeId, usize>,
pub(crate) invocation_parents: FxHashMap<LocalExpnId, InvocationParent>,
pub(crate) trait_impl_items: FxHashSet<LocalDefId>,
pub(crate) legacy_const_generic_args: FxHashMap<DefId, Option<Vec<usize>>>,
pub(crate) item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>,
pub(crate) delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,
pub(crate) main_def: Option<MainDefinition>,
pub(crate) trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
pub(crate) proc_macros: Vec<NodeId>,
pub(crate) confused_type_with_std_module: FxIndexMap<Span, Span>,
pub(crate) lifetime_elision_allowed: FxHashSet<NodeId>,
pub(crate) stripped_cfg_items: Vec<StrippedCfgItem<NodeId>>,
pub(crate) effective_visibilities: EffectiveVisibilities,
pub(crate) doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
pub(crate) doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>,
pub(crate) all_macro_rules: FxHashMap<Symbol, Res<NodeId>>,
pub(crate) glob_delegation_invoc_ids: FxHashSet<LocalExpnId>,
pub(crate) impl_unexpanded_invocations: FxHashMap<LocalDefId, FxHashSet<LocalExpnId>>,
pub(crate) impl_binding_keys: FxHashMap<LocalDefId, FxHashSet<BindingKey>>,
pub(crate) current_crate_outer_attr_insert_span: Span,
}
Expand description
The main resolver class.
This is the visitor that walks the whole crate.
Fields§
§tcx: TyCtxt<'tcx>
§expn_that_defined: FxHashMap<LocalDefId, ExpnId>
Item with a given LocalDefId
was defined during macro expansion with ID ExpnId
.
graph_root: Module<'ra>
§prelude: Option<Module<'ra>>
§extern_prelude: FxHashMap<Ident, ExternPreludeEntry<'ra>>
§field_names: LocalDefIdMap<Vec<Ident>>
N.B., this is used only for better diagnostics, not name resolution itself.
field_visibility_spans: FxHashMap<DefId, Vec<Span>>
Span of the privacy modifier in fields of an item DefId
accessible with dot syntax.
Used for hints during error reporting.
determined_imports: Vec<Interned<'ra, ImportData<'ra>>>
All imports known to succeed or fail.
indeterminate_imports: Vec<Interned<'ra, ImportData<'ra>>>
All non-determined imports.
pat_span_map: NodeMap<Span>
§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.
import_use_map: FxHashMap<Interned<'ra, ImportData<'ra>>, Used>
An import will be inserted into this map if it has been used.
label_res_map: NodeMap<NodeId>
Resolutions for labels (node IDs of their corresponding blocks or loops).
lifetimes_res_map: NodeMap<LifetimeRes>
Resolutions for lifetimes.
extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, LifetimeRes)>>
Lifetime parameters that lowering will have to introduce.
extern_crate_map: FxHashMap<LocalDefId, CrateNum>
CrateNum
resolutions of extern crate
items.
module_children: LocalDefIdMap<Vec<ModChild>>
§trait_map: NodeMap<Vec<TraitCandidate>>
§block_map: NodeMap<Module<'ra>>
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: Module<'ra>
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 lang items.
module_map: FxHashMap<DefId, Module<'ra>>
§binding_parent_modules: FxHashMap<Interned<'ra, NameBindingData<'ra>>, Module<'ra>>
§underscore_disambiguator: u32
§empty_disambiguator: u32
Disambiguator for anonymous adts.
glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>
Maps glob imports to the names of items actually imported.
glob_error: Option<ErrorGuaranteed>
§visibilities_for_hashing: Vec<(LocalDefId, Visibility)>
§used_imports: FxHashSet<NodeId>
§maybe_unused_trait_imports: FxIndexSet<LocalDefId>
§privacy_errors: Vec<PrivacyError<'ra>>
Privacy errors are delayed until the end in order to deduplicate them.
ambiguity_errors: Vec<AmbiguityError<'ra>>
Ambiguity errors are delayed for deduplication.
use_injections: Vec<UseError<'tcx>>
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: &'ra ResolverArenas<'ra>
§dummy_binding: Interned<'ra, NameBindingData<'ra>>
§builtin_types_bindings: FxHashMap<Symbol, Interned<'ra, NameBindingData<'ra>>>
§builtin_attrs_bindings: FxHashMap<Symbol, Interned<'ra, NameBindingData<'ra>>>
§registered_tool_bindings: FxHashMap<Ident, Interned<'ra, NameBindingData<'ra>>>
§module_self_bindings: FxHashMap<Module<'ra>, Interned<'ra, NameBindingData<'ra>>>
Binding for implicitly declared names that come with a module,
like self
(not yet used), or crate
/$crate
(for root modules).
used_extern_options: FxHashSet<Symbol>
§macro_names: FxHashSet<Ident>
§builtin_macros: FxHashMap<Symbol, BuiltinMacroState>
§registered_tools: &'tcx RegisteredTools
§macro_use_prelude: FxHashMap<Symbol, Interned<'ra, NameBindingData<'ra>>>
§macro_map: FxHashMap<DefId, MacroData>
§dummy_ext_bang: Lrc<SyntaxExtension>
§dummy_ext_derive: Lrc<SyntaxExtension>
§non_macro_attr: MacroData
§local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>
§ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>
§unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>
§unused_macro_rules: FxHashMap<(LocalDefId, usize), (Ident, Span)>
§proc_macro_stubs: FxHashSet<LocalDefId>
§single_segment_macro_resolutions: Vec<(Ident, MacroKind, ParentScope<'ra>, Option<Interned<'ra, NameBindingData<'ra>>>)>
Traces collected during macro resolution and validated when it’s complete.
multi_segment_macro_resolutions: Vec<(Vec<Segment>, Span, MacroKind, ParentScope<'ra>, Option<Res<NodeId>>, Namespace)>
§builtin_attrs: Vec<(Ident, ParentScope<'ra>)>
§containers_deriving_copy: FxHashSet<LocalExpnId>
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<LocalExpnId, ParentScope<'ra>>
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<LocalExpnId, Interned<'ra, Cell<MacroRulesScope<'ra>>>>
macro_rules
scopes produced by expanding the macro invocations,
include all the macro_rules
items and other invocations generated by them.
macro_rules_scopes: FxHashMap<LocalDefId, Interned<'ra, Cell<MacroRulesScope<'ra>>>>
macro_rules
scopes produced by macro_rules
item definitions.
helper_attrs: FxHashMap<LocalExpnId, Vec<(Ident, Interned<'ra, NameBindingData<'ra>>)>>
Helper attributes that are in scope for the given expansion.
derive_data: FxHashMap<LocalExpnId, DeriveData>
Ready or in-progress results of resolving paths inside the #[derive(...)]
attribute
with the given ExpnId
.
name_already_seen: FxHashMap<Symbol, Span>
Avoid duplicated errors for “name already defined”.
potentially_unused_imports: Vec<Interned<'ra, ImportData<'ra>>>
§potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>>
§struct_constructors: LocalDefIdMap<(Res<NodeId>, Visibility<DefId>, Vec<Visibility<DefId>>)>
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
lint_buffer: LintBuffer
§next_node_id: NodeId
§node_id_to_def_id: NodeMap<Feed<'tcx, 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<LocalExpnId, InvocationParent>
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,
and how the impl Trait
fragments were introduced.
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).
legacy_const_generic_args: FxHashMap<DefId, Option<Vec<usize>>>
§item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>
Amount of lifetime parameters for each item in the crate.
delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>
§main_def: Option<MainDefinition>
§trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>
§proc_macros: Vec<NodeId>
A list of proc macro LocalDefIds, written out in the order in which they are declared in the static array generated by proc_macro_harness.
confused_type_with_std_module: FxIndexMap<Span, Span>
§lifetime_elision_allowed: FxHashSet<NodeId>
Whether lifetime elision was successful.
stripped_cfg_items: Vec<StrippedCfgItem<NodeId>>
Names of items that were stripped out via cfg with their corresponding cfg meta item.
effective_visibilities: EffectiveVisibilities
§doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>
§doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>
§all_macro_rules: FxHashMap<Symbol, Res<NodeId>>
§glob_delegation_invoc_ids: FxHashSet<LocalExpnId>
Invocation ids of all glob delegations.
impl_unexpanded_invocations: FxHashMap<LocalDefId, FxHashSet<LocalExpnId>>
Analogue of module unexpanded_invocations
but in trait impls, excluding glob delegations.
Needed because glob delegations wait for all other neighboring macros to expand.
impl_binding_keys: FxHashMap<LocalDefId, FxHashSet<BindingKey>>
Simplified analogue of module resolutions
but in trait impls, excluding glob delegations.
Needed because glob delegations exclude explicitly defined names.
current_crate_outer_attr_insert_span: Span
This is the Span
where an extern crate foo;
suggestion would be inserted, if foo
could be a crate that wasn’t imported. For diagnostics use only.
Implementations§
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
sourcepub(crate) fn define<T>(
&mut self,
parent: Module<'ra>,
ident: Ident,
ns: Namespace,
def: T,
)where
T: ToNameBinding<'ra>,
pub(crate) fn define<T>(
&mut self,
parent: Module<'ra>,
ident: Ident,
ns: Namespace,
def: T,
)where
T: ToNameBinding<'ra>,
Defines name
in namespace ns
of module parent
to be def
if it is not yet defined;
otherwise, reports an error.
sourcepub(crate) fn get_nearest_non_block_module(
&mut self,
def_id: DefId,
) -> Module<'ra>
pub(crate) fn get_nearest_non_block_module( &mut self, def_id: DefId, ) -> Module<'ra>
Walks up the tree of definitions starting at def_id
,
stopping at the first encountered module.
Parent block modules for arbitrary def-ids are not recorded for the local crate,
and are not preserved in metadata for foreign crates, so block modules are never
returned by this function.
For the local crate ignoring block modules may be incorrect, so use this method with care.
For foreign crates block modules can be ignored without introducing observable differences,
moreover they has to be ignored right now because they are not kept in metadata.
Foreign parent modules are used for resolving names used by foreign macros with def-site
hygiene, therefore block module ignorability relies on macros with def-site hygiene and
block module parents being unreachable from other crates.
Reachable macros with block module parents exist due to #[macro_export] macro_rules!
,
but they cannot use def-site hygiene, so the assumption holds
(https://github.com/rust-lang/rust/pull/77984#issuecomment-712445508).
pub(crate) fn expect_module(&mut self, def_id: DefId) -> Module<'ra>
sourcepub(crate) fn get_module(&mut self, def_id: DefId) -> Option<Module<'ra>>
pub(crate) fn get_module(&mut self, def_id: DefId) -> Option<Module<'ra>>
If def_id
refers to a module (in resolver’s sense, i.e. a module item, crate root, enum,
or trait), then this function returns that module’s resolver representation, otherwise it
returns None
.
pub(crate) fn expn_def_scope(&mut self, expn_id: ExpnId) -> Module<'ra>
pub(crate) fn macro_def_scope(&mut self, def_id: DefId) -> Module<'ra>
pub(crate) fn get_macro(&mut self, res: Res<NodeId>) -> Option<&MacroData>
pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> &MacroData
pub(crate) fn build_reduced_graph( &mut self, fragment: &AstFragment, parent_scope: ParentScope<'ra>, ) -> Interned<'ra, Cell<MacroRulesScope<'ra>>>
pub(crate) fn build_reduced_graph_external(&mut self, module: Module<'ra>)
sourcefn build_reduced_graph_for_external_crate_res(
&mut self,
child: &ModChild,
parent_scope: ParentScope<'ra>,
)
fn build_reduced_graph_for_external_crate_res( &mut self, child: &ModChild, parent_scope: ParentScope<'ra>, )
Builds the reduced graph for a single item in an external crate.
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'tcx>
pub(crate) fn report_errors(&mut self, krate: &Crate)
fn report_with_use_injections(&mut self, krate: &Crate)
pub(crate) fn report_conflict( &mut self, parent: Module<'_>, ident: Ident, ns: Namespace, new_binding: Interned<'ra, NameBindingData<'ra>>, old_binding: Interned<'ra, NameBindingData<'ra>>, )
sourcefn add_suggestion_for_rename_of_use(
&self,
err: &mut Diag<'_>,
name: Symbol,
import: Interned<'_, ImportData<'_>>,
binding_span: Span,
)
fn add_suggestion_for_rename_of_use( &self, err: &mut Diag<'_>, name: Symbol, import: Interned<'_, ImportData<'_>>, 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;
| ^^^^^^^^^^^^^^^^^^^^^
sourcefn add_suggestion_for_duplicate_nested_use(
&self,
err: &mut Diag<'_>,
import: Interned<'_, ImportData<'_>>,
binding_span: Span,
)
fn add_suggestion_for_duplicate_nested_use( &self, err: &mut Diag<'_>, import: Interned<'_, ImportData<'_>>, binding_span: Span, )
This function adds a suggestion to remove an 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 lint_if_path_starts_with_module( &mut self, finalize: Option<Finalize>, path: &[Segment], second_binding: Option<Interned<'_, NameBindingData<'_>>>, )
pub(crate) fn add_module_candidates( &mut self, module: Module<'ra>, names: &mut Vec<TypoSuggestion>, filter_fn: &impl Fn(Res<NodeId>) -> bool, ctxt: Option<SyntaxContext>, )
sourcepub(crate) fn report_error(
&mut self,
span: Span,
resolution_error: ResolutionError<'ra>,
) -> ErrorGuaranteed
pub(crate) fn report_error( &mut self, span: Span, resolution_error: ResolutionError<'ra>, ) -> ErrorGuaranteed
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( &mut self, span: Span, resolution_error: ResolutionError<'ra>, ) -> Diag<'_>
pub(crate) fn report_vis_error( &mut self, vis_resolution_error: VisResolutionError<'_>, ) -> ErrorGuaranteed
sourcefn early_lookup_typo_candidate(
&mut self,
scope_set: ScopeSet<'ra>,
parent_scope: &ParentScope<'ra>,
ident: Ident,
filter_fn: &impl Fn(Res<NodeId>) -> bool,
) -> Option<TypoSuggestion>
fn early_lookup_typo_candidate( &mut self, scope_set: ScopeSet<'ra>, parent_scope: &ParentScope<'ra>, ident: Ident, filter_fn: &impl Fn(Res<NodeId>) -> bool, ) -> Option<TypoSuggestion>
Lookup typo candidate in scope for a macro or import.
fn lookup_import_candidates_from_module<FilterFn>( &mut self, lookup_ident: Ident, namespace: Namespace, parent_scope: &ParentScope<'ra>, start_module: Module<'ra>, crate_path: ThinVec<PathSegment>, filter_fn: FilterFn, ) -> Vec<ImportSuggestion>
sourcepub(crate) fn lookup_import_candidates<FilterFn>(
&mut self,
lookup_ident: Ident,
namespace: Namespace,
parent_scope: &ParentScope<'ra>,
filter_fn: FilterFn,
) -> Vec<ImportSuggestion>
pub(crate) fn lookup_import_candidates<FilterFn>( &mut self, lookup_ident: Ident, namespace: Namespace, parent_scope: &ParentScope<'ra>, filter_fn: FilterFn, ) -> Vec<ImportSuggestion>
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 Diag<'_>, macro_kind: MacroKind, parent_scope: &ParentScope<'ra>, ident: Ident, krate: &Crate, )
pub(crate) fn add_typo_suggestion( &self, err: &mut Diag<'_>, suggestion: Option<TypoSuggestion>, span: Span, ) -> bool
fn binding_description( &self, b: Interned<'_, NameBindingData<'_>>, ident: Ident, from_prelude: bool, ) -> String
fn ambiguity_diagnostics( &self, ambiguity_error: &AmbiguityError<'_>, ) -> AmbiguityErrorDiag
sourcefn ctor_fields_span(
&self,
binding: Interned<'_, NameBindingData<'_>>,
) -> Option<Span>
fn ctor_fields_span( &self, binding: Interned<'_, NameBindingData<'_>>, ) -> Option<Span>
If the binding refers to a tuple struct constructor with fields, returns the span of its fields.
fn report_privacy_error(&mut self, privacy_error: &PrivacyError<'ra>)
pub(crate) fn find_similarly_named_module_or_crate( &mut self, ident: Symbol, current_module: Module<'ra>, ) -> Option<Symbol>
pub(crate) fn report_path_resolution_error( &mut self, path: &[Segment], opt_ns: Option<Namespace>, parent_scope: &ParentScope<'ra>, ribs: Option<&PerNS<Vec<Rib<'ra>>>>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, module: Option<ModuleOrUniformRoot<'ra>>, failed_segment_idx: usize, ident: Ident, ) -> (String, Option<(Vec<(Span, String)>, String, Applicability)>)
sourcepub(crate) fn make_path_suggestion(
&mut self,
span: Span,
path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)>
pub(crate) fn make_path_suggestion( &mut self, span: Span, path: Vec<Segment>, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec<Segment>, Option<String>)>
Adds suggestions for a path that cannot be resolved.
sourcefn make_missing_self_suggestion(
&mut self,
path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)>
fn make_missing_self_suggestion( &mut self, path: Vec<Segment>, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec<Segment>, Option<String>)>
Suggest a missing self::
if that resolves to an correct module.
|
LL | use foo::Bar;
| ^^^ did you mean `self::foo`?
sourcefn make_missing_crate_suggestion(
&mut self,
path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)>
fn make_missing_crate_suggestion( &mut self, path: Vec<Segment>, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec<Segment>, Option<String>)>
Suggests a missing crate::
if that resolves to an correct module.
|
LL | use foo::Bar;
| ^^^ did you mean `crate::foo`?
sourcefn make_missing_super_suggestion(
&mut self,
path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)>
fn make_missing_super_suggestion( &mut self, path: Vec<Segment>, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec<Segment>, Option<String>)>
Suggests a missing super::
if that resolves to an correct module.
|
LL | use foo::Bar;
| ^^^ did you mean `super::foo`?
sourcefn make_external_crate_suggestion(
&mut self,
path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)>
fn make_external_crate_suggestion( &mut self, path: Vec<Segment>, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec<Segment>, Option<String>)>
Suggests a missing external crate name if that resolves to an correct module.
|
LL | use foobar::Baz;
| ^^^^^^ did you mean `baz::foobar`?
Used when importing a submodule of an external crate but missing that crate’s name as the first part of path.
sourcepub(crate) fn check_for_module_export_macro(
&mut self,
import: Interned<'ra, ImportData<'ra>>,
module: ModuleOrUniformRoot<'ra>,
ident: Ident,
) -> Option<(Option<(Vec<(Span, String)>, String, Applicability)>, Option<String>)>
pub(crate) fn check_for_module_export_macro( &mut self, import: Interned<'ra, ImportData<'ra>>, module: ModuleOrUniformRoot<'ra>, ident: Ident, ) -> Option<(Option<(Vec<(Span, String)>, String, Applicability)>, Option<String>)>
Suggests importing a macro from the root of the crate rather than a module within the crate.
help: a macro with this name exists at the root of the crate
|
LL | use issue_59764::makro;
| ^^^^^^^^^^^^^^^^^^
|
= note: this could be because a macro annotated with `#[macro_export]` will be exported
at the root of the crate instead of the module where it is defined
sourcepub(crate) fn find_cfg_stripped(
&self,
err: &mut Diag<'_>,
segment: &Symbol,
module: DefId,
)
pub(crate) fn find_cfg_stripped( &self, err: &mut Diag<'_>, segment: &Symbol, module: DefId, )
Finds a cfg-ed out item inside module
with the matching name.
source§impl Resolver<'_, '_>
impl Resolver<'_, '_>
fn nearest_normal_mod(&mut self, def_id: LocalDefId) -> LocalDefId
fn private_vis_import( &mut self, binding: Interned<'_, NameBindingData<'_>>, ) -> Visibility
fn private_vis_def(&mut self, def_id: LocalDefId) -> Visibility
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
sourcepub(crate) fn visit_scopes<T>(
&mut self,
scope_set: ScopeSet<'ra>,
parent_scope: &ParentScope<'ra>,
ctxt: SyntaxContext,
visitor: impl FnMut(&mut Self, Scope<'ra>, UsePrelude, SyntaxContext) -> Option<T>,
) -> Option<T>
pub(crate) fn visit_scopes<T>( &mut self, scope_set: ScopeSet<'ra>, parent_scope: &ParentScope<'ra>, ctxt: SyntaxContext, visitor: impl FnMut(&mut Self, Scope<'ra>, UsePrelude, SyntaxContext) -> 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.
fn hygienic_lexical_parent( &mut self, module: Module<'ra>, ctxt: &mut SyntaxContext, derive_fallback_lint_id: Option<NodeId>, ) -> Option<(Module<'ra>, Option<NodeId>)>
sourcepub(crate) fn resolve_ident_in_lexical_scope(
&mut self,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'ra>,
finalize: Option<Finalize>,
ribs: &[Rib<'ra>],
ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>,
) -> Option<LexicalScopeBinding<'ra>>
pub(crate) fn resolve_ident_in_lexical_scope( &mut self, ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, ribs: &[Rib<'ra>], ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ) -> Option<LexicalScopeBinding<'ra>>
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.
sourcepub(crate) fn early_resolve_ident_in_lexical_scope(
&mut self,
orig_ident: Ident,
scope_set: ScopeSet<'ra>,
parent_scope: &ParentScope<'ra>,
finalize: Option<Finalize>,
force: bool,
ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>,
ignore_import: Option<Interned<'ra, ImportData<'ra>>>,
) -> Result<Interned<'ra, NameBindingData<'ra>>, Determinacy>
pub(crate) fn early_resolve_ident_in_lexical_scope( &mut self, orig_ident: Ident, scope_set: ScopeSet<'ra>, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, force: bool, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<Interned<'ra, NameBindingData<'ra>>, Determinacy>
Resolve an identifier in lexical scope.
This is a variation of fn resolve_ident_in_lexical_scope
that can be run during
expansion and import resolution (perhaps they can be merged in the future).
The function is used for resolving initial segments of macro paths (e.g., foo
in
foo::bar!();
or foo!();
) and also for import paths on 2018 edition.
pub(crate) fn maybe_resolve_ident_in_module( &mut self, module: ModuleOrUniformRoot<'ra>, ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<Interned<'ra, NameBindingData<'ra>>, Determinacy>
pub(crate) fn resolve_ident_in_module( &mut self, module: ModuleOrUniformRoot<'ra>, ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<Interned<'ra, NameBindingData<'ra>>, Determinacy>
fn resolve_ident_in_module_ext( &mut self, module: ModuleOrUniformRoot<'ra>, ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<Interned<'ra, NameBindingData<'ra>>, (Determinacy, Weak)>
fn resolve_ident_in_module_unadjusted( &mut self, module: ModuleOrUniformRoot<'ra>, ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<Interned<'ra, NameBindingData<'ra>>, Determinacy>
sourcefn resolve_ident_in_module_unadjusted_ext(
&mut self,
module: ModuleOrUniformRoot<'ra>,
ident: Ident,
ns: Namespace,
parent_scope: &ParentScope<'ra>,
restricted_shadowing: bool,
finalize: Option<Finalize>,
ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>,
ignore_import: Option<Interned<'ra, ImportData<'ra>>>,
) -> Result<Interned<'ra, NameBindingData<'ra>>, (Determinacy, Weak)>
fn resolve_ident_in_module_unadjusted_ext( &mut self, module: ModuleOrUniformRoot<'ra>, ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, restricted_shadowing: bool, finalize: Option<Finalize>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<Interned<'ra, NameBindingData<'ra>>, (Determinacy, Weak)>
Attempts to resolve ident
in namespaces ns
of module
.
Invariant: if finalize
is Some
, expansion and import resolution must be complete.
sourcefn validate_res_from_ribs(
&mut self,
rib_index: usize,
rib_ident: Ident,
res: Res<NodeId>,
finalize: Option<Span>,
original_rib_ident_def: Ident,
all_ribs: &[Rib<'ra>],
) -> Res<NodeId>
fn validate_res_from_ribs( &mut self, rib_index: usize, rib_ident: Ident, res: Res<NodeId>, finalize: Option<Span>, original_rib_ident_def: Ident, all_ribs: &[Rib<'ra>], ) -> Res<NodeId>
Validate a local resolution (from ribs).
pub(crate) fn maybe_resolve_path( &mut self, path: &[Segment], opt_ns: Option<Namespace>, parent_scope: &ParentScope<'ra>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> PathResult<'ra>
pub(crate) fn resolve_path( &mut self, path: &[Segment], opt_ns: Option<Namespace>, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> PathResult<'ra>
pub(crate) fn resolve_path_with_ribs( &mut self, path: &[Segment], opt_ns: Option<Namespace>, parent_scope: &ParentScope<'ra>, finalize: Option<Finalize>, ribs: Option<&PerNS<Vec<Rib<'ra>>>>, ignore_binding: Option<Interned<'ra, NameBindingData<'ra>>>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> PathResult<'ra>
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
sourcepub(crate) fn import(
&self,
binding: Interned<'ra, NameBindingData<'ra>>,
import: Interned<'ra, ImportData<'ra>>,
) -> Interned<'ra, NameBindingData<'ra>>
pub(crate) fn import( &self, binding: Interned<'ra, NameBindingData<'ra>>, import: Interned<'ra, ImportData<'ra>>, ) -> Interned<'ra, NameBindingData<'ra>>
Given a binding and an import that resolves to it, return the corresponding binding defined by the import.
sourcepub(crate) fn try_define(
&mut self,
module: Module<'ra>,
key: BindingKey,
binding: Interned<'ra, NameBindingData<'ra>>,
warn_ambiguity: bool,
) -> Result<(), Interned<'ra, NameBindingData<'ra>>>
pub(crate) fn try_define( &mut self, module: Module<'ra>, key: BindingKey, binding: Interned<'ra, NameBindingData<'ra>>, warn_ambiguity: bool, ) -> Result<(), Interned<'ra, NameBindingData<'ra>>>
Define the name or return the existing binding if there is a collision.
update
indicates if the definition is a redefinition of an existing binding.
fn new_ambiguity_binding( &self, ambiguity_kind: AmbiguityKind, primary_binding: Interned<'ra, NameBindingData<'ra>>, secondary_binding: Interned<'ra, NameBindingData<'ra>>, warn_ambiguity: bool, ) -> Interned<'ra, NameBindingData<'ra>>
fn new_warn_ambiguity_binding( &self, binding: Interned<'ra, NameBindingData<'ra>>, ) -> Interned<'ra, NameBindingData<'ra>>
fn update_resolution<T, F>( &mut self, module: Module<'ra>, key: BindingKey, warn_ambiguity: bool, f: F, ) -> T
fn import_dummy_binding( &mut self, import: Interned<'ra, ImportData<'ra>>, is_indeterminate: bool, )
sourcepub(crate) fn resolve_imports(&mut self)
pub(crate) fn resolve_imports(&mut self)
Resolves all imports for the crate. This method performs the fixed- point iteration.
pub(crate) fn finalize_imports(&mut self)
fn throw_unresolved_import_error( &mut self, errors: Vec<(Interned<'_, ImportData<'_>>, UnresolvedImportError)>, glob_error: bool, )
sourcefn resolve_import(&mut self, import: Interned<'ra, ImportData<'ra>>) -> usize
fn resolve_import(&mut self, import: Interned<'ra, ImportData<'ra>>) -> usize
Attempts to resolve the given import, returning:
0
means its resolution is determined.- Other values mean that indeterminate exists under certain namespaces.
Meanwhile, if resolve successful, the resolved bindings are written into the module.
sourcefn finalize_import(
&mut self,
import: Interned<'ra, ImportData<'ra>>,
) -> Option<UnresolvedImportError>
fn finalize_import( &mut self, import: Interned<'ra, ImportData<'ra>>, ) -> Option<UnresolvedImportError>
Performs final import resolution, consistency checks and error reporting.
Optionally returns an unresolved import error. This error is buffered and used to consolidate multiple unresolved import errors into a single diagnostic.
pub(crate) fn check_for_redundant_imports( &mut self, import: Interned<'ra, ImportData<'ra>>, ) -> bool
fn resolve_glob_import(&mut self, import: Interned<'ra, ImportData<'ra>>)
fn finalize_resolutions_in(&mut self, module: Module<'ra>)
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
pub(crate) fn late_resolve_crate(&mut self, krate: &Crate)
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
sourcefn smart_resolve_macro_path(
&mut self,
path: &Path,
kind: MacroKind,
supports_macro_expansion: SupportsMacroExpansion,
inner_attr: bool,
parent_scope: &ParentScope<'ra>,
node_id: NodeId,
force: bool,
soft_custom_inner_attributes_gate: bool,
deleg_impl: Option<LocalDefId>,
invoc_in_mod_inert_attr: Option<LocalDefId>,
) -> Result<(Lrc<SyntaxExtension>, Res<NodeId>), Indeterminate>
fn smart_resolve_macro_path( &mut self, path: &Path, kind: MacroKind, supports_macro_expansion: SupportsMacroExpansion, inner_attr: bool, parent_scope: &ParentScope<'ra>, node_id: NodeId, force: bool, soft_custom_inner_attributes_gate: bool, deleg_impl: Option<LocalDefId>, invoc_in_mod_inert_attr: Option<LocalDefId>, ) -> 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(crate) fn resolve_macro_path( &mut self, path: &Path, kind: Option<MacroKind>, parent_scope: &ParentScope<'ra>, trace: bool, force: bool, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<(Option<Lrc<SyntaxExtension>>, Res<NodeId>), Determinacy>
fn resolve_macro_or_delegation_path( &mut self, ast_path: &Path, kind: Option<MacroKind>, parent_scope: &ParentScope<'ra>, trace: bool, force: bool, deleg_impl: Option<LocalDefId>, invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>, ignore_import: Option<Interned<'ra, ImportData<'ra>>>, ) -> Result<(Option<Lrc<SyntaxExtension>>, Res<NodeId>), Determinacy>
pub(crate) fn finalize_macro_resolutions(&mut self, krate: &Crate)
fn check_stability_and_deprecation( &mut self, ext: &SyntaxExtension, path: &Path, node_id: NodeId, )
fn prohibit_imported_non_macro_attrs( &self, binding: Option<Interned<'ra, NameBindingData<'ra>>>, res: Option<Res<NodeId>>, span: Span, )
fn report_out_of_scope_macro_calls( &mut self, path: &Path, parent_scope: &ParentScope<'ra>, invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>, binding: Option<Interned<'ra, NameBindingData<'ra>>>, )
pub(crate) fn check_reserved_macro_name( &mut self, ident: Ident, res: Res<NodeId>, )
sourcepub(crate) fn compile_macro(
&mut self,
item: &Item,
edition: Edition,
) -> MacroData
pub(crate) fn compile_macro( &mut self, item: &Item, edition: Edition, ) -> MacroData
Compile the macro into a SyntaxExtension
and its rule spans.
Possibly replace its expander to a pre-defined one for built-in macros.
fn path_accessible( &mut self, expn_id: LocalExpnId, path: &Path, namespaces: &[Namespace], ) -> Result<bool, Indeterminate>
source§impl<'tcx> Resolver<'_, 'tcx>
impl<'tcx> Resolver<'_, 'tcx>
pub(crate) fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId>
pub(crate) fn local_def_id(&self, node: NodeId) -> LocalDefId
pub(crate) fn opt_feed(&self, node: NodeId) -> Option<Feed<'tcx, LocalDefId>>
pub(crate) fn feed(&self, node: NodeId) -> Feed<'tcx, LocalDefId>
pub(crate) fn local_def_kind(&self, node: NodeId) -> DefKind
sourcepub(crate) fn create_def(
&mut self,
parent: LocalDefId,
node_id: NodeId,
name: Symbol,
def_kind: DefKind,
expn_id: ExpnId,
span: Span,
) -> TyCtxtFeed<'tcx, LocalDefId>
pub(crate) fn create_def( &mut self, parent: LocalDefId, node_id: NodeId, name: Symbol, def_kind: DefKind, expn_id: ExpnId, span: Span, ) -> TyCtxtFeed<'tcx, LocalDefId>
Adds a definition with a parent definition.
pub(crate) fn item_generics_num_lifetimes(&self, def_id: DefId) -> usize
pub fn tcx(&self) -> TyCtxt<'tcx>
source§impl<'ra, 'tcx> Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Resolver<'ra, 'tcx>
pub fn new( tcx: TyCtxt<'tcx>, attrs: &[Attribute], crate_span: Span, current_crate_outer_attr_insert_span: Span, arenas: &'ra ResolverArenas<'ra>, ) -> Resolver<'ra, 'tcx>
pub(crate) fn new_module( &mut self, parent: Option<Module<'ra>>, kind: ModuleKind, expn_id: ExpnId, span: Span, no_implicit_prelude: bool, ) -> Module<'ra>
pub(crate) fn next_node_id(&mut self) -> NodeId
pub(crate) fn next_node_ids(&mut self, count: usize) -> Range<NodeId>
pub fn lint_buffer(&mut self) -> &mut LintBuffer
pub fn arenas() -> ResolverArenas<'ra>
pub(crate) fn feed_visibility( &mut self, feed: Feed<'tcx, LocalDefId>, vis: Visibility, )
pub fn into_outputs(self) -> ResolverOutputs
pub(crate) fn create_stable_hashing_context(&self) -> StableHashingContext<'_>
pub(crate) fn crate_loader<T>( &mut self, f: impl FnOnce(&mut CrateLoader<'_, '_>) -> T, ) -> T
pub(crate) fn cstore(&self) -> FreezeReadGuard<'_, CStore>
pub(crate) fn dummy_ext(&self, macro_kind: MacroKind) -> Lrc<SyntaxExtension>
sourcepub(crate) fn per_ns<F: FnMut(&mut Self, Namespace)>(&mut self, f: F)
pub(crate) fn per_ns<F: FnMut(&mut Self, Namespace)>(&mut self, f: F)
Runs the function on each namespace.
pub(crate) fn is_builtin_macro(&mut self, res: Res<NodeId>) -> bool
pub(crate) fn macro_def(&self, ctxt: SyntaxContext) -> DefId
sourcepub fn resolve_crate(&mut self, krate: &Crate)
pub fn resolve_crate(&mut self, krate: &Crate)
Entry point to crate resolution.
pub(crate) fn traits_in_scope( &mut self, current_trait: Option<Module<'ra>>, parent_scope: &ParentScope<'ra>, ctxt: SyntaxContext, assoc_item: Option<(Symbol, Namespace)>, ) -> Vec<TraitCandidate>
pub(crate) fn traits_in_module( &mut self, module: Module<'ra>, assoc_item: Option<(Symbol, Namespace)>, found_traits: &mut Vec<TraitCandidate>, )
pub(crate) fn trait_may_have_item( &mut self, trait_module: Option<Module<'ra>>, assoc_item: Option<(Symbol, Namespace)>, ) -> bool
pub(crate) fn find_transitive_imports( &mut self, kind: &NameBindingKind<'_>, trait_name: Ident, ) -> SmallVec<[LocalDefId; 1]>
pub(crate) fn new_disambiguated_key( &mut self, ident: Ident, ns: Namespace, ) -> BindingKey
pub(crate) fn resolutions( &mut self, module: Module<'ra>, ) -> &'ra RefCell<FxIndexMap<BindingKey, &'ra RefCell<NameResolution<'ra>>>>
pub(crate) fn resolution( &mut self, module: Module<'ra>, key: BindingKey, ) -> &'ra RefCell<NameResolution<'ra>>
sourcepub(crate) fn matches_previous_ambiguity_error(
&self,
ambi: &AmbiguityError<'_>,
) -> bool
pub(crate) fn matches_previous_ambiguity_error( &self, ambi: &AmbiguityError<'_>, ) -> bool
Test if AmbiguityError ambi is any identical to any one inside ambiguity_errors
pub(crate) fn record_use( &mut self, ident: Ident, used_binding: Interned<'ra, NameBindingData<'ra>>, used: Used, )
pub(crate) fn record_use_inner( &mut self, ident: Ident, used_binding: Interned<'ra, NameBindingData<'ra>>, used: Used, warn_ambiguity: bool, )
pub(crate) fn add_to_glob_map( &mut self, import: Interned<'_, ImportData<'_>>, ident: Ident, )
pub(crate) fn resolve_crate_root(&mut self, ident: Ident) -> Module<'ra>
pub(crate) fn resolve_self( &mut self, ctxt: &mut SyntaxContext, module: Module<'ra>, ) -> Module<'ra>
pub(crate) fn record_partial_res( &mut self, node_id: NodeId, resolution: PartialRes, )
pub(crate) fn record_pat_span(&mut self, node: NodeId, span: Span)
pub(crate) fn is_accessible_from( &self, vis: Visibility<impl Into<DefId>>, module: Module<'ra>, ) -> bool
pub(crate) fn set_binding_parent_module( &mut self, binding: Interned<'ra, NameBindingData<'ra>>, module: Module<'ra>, )
pub(crate) fn disambiguate_macro_rules_vs_modularized( &self, macro_rules: Interned<'ra, NameBindingData<'ra>>, modularized: Interned<'ra, NameBindingData<'ra>>, ) -> bool
pub(crate) fn extern_prelude_get( &mut self, ident: Ident, finalize: bool, ) -> Option<Interned<'ra, NameBindingData<'ra>>>
sourcepub(crate) fn resolve_rustdoc_path(
&mut self,
path_str: &str,
ns: Namespace,
parent_scope: ParentScope<'ra>,
) -> Option<Res<NodeId>>
pub(crate) fn resolve_rustdoc_path( &mut self, path_str: &str, ns: Namespace, parent_scope: ParentScope<'ra>, ) -> Option<Res<NodeId>>
Rustdoc uses this to resolve doc link paths in a recoverable way. PathResult<'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.
sourcepub(crate) fn def_span(&self, def_id: DefId) -> Span
pub(crate) fn def_span(&self, def_id: DefId) -> Span
Retrieves definition span of the given DefId
.
pub(crate) fn field_idents(&self, def_id: DefId) -> Option<Vec<Ident>>
sourcepub(crate) fn legacy_const_generic_args(
&mut self,
expr: &Expr,
) -> Option<Vec<usize>>
pub(crate) fn legacy_const_generic_args( &mut self, expr: &Expr, ) -> Option<Vec<usize>>
Checks if an expression refers to a function marked with
#[rustc_legacy_const_generics]
and returns the argument index list
from the attribute.
pub(crate) fn resolve_main(&mut self)
Trait Implementations§
source§impl<'ra, 'tcx> AsMut<Resolver<'ra, 'tcx>> for BuildReducedGraphVisitor<'_, 'ra, 'tcx>
impl<'ra, 'tcx> AsMut<Resolver<'ra, 'tcx>> for BuildReducedGraphVisitor<'_, 'ra, 'tcx>
source§impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx>
impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx>
fn next_node_id(&mut self) -> NodeId
fn invocation_parent(&self, id: LocalExpnId) -> LocalDefId
fn resolve_dollar_crates(&mut self)
fn visit_ast_fragment_with_placeholders( &mut self, expansion: LocalExpnId, fragment: &AstFragment, )
fn register_builtin_macro(&mut self, name: Symbol, ext: SyntaxExtensionKind)
fn expansion_for_ast_pass( &mut self, call_site: Span, pass: AstPass, features: &[Symbol], parent_module_id: Option<NodeId>, ) -> LocalExpnId
fn resolve_imports(&mut self)
fn resolve_macro_invocation( &mut self, invoc: &Invocation, eager_expansion_root: LocalExpnId, force: bool, ) -> Result<Lrc<SyntaxExtension>, Indeterminate>
fn record_macro_rule_usage(&mut self, id: NodeId, rule_i: usize)
fn check_unused_macros(&mut self)
source§fn has_derive_copy(&self, expn_id: LocalExpnId) -> bool
fn has_derive_copy(&self, expn_id: LocalExpnId) -> bool
#[derive(...)]
attribute with the given ExpnId
have built-in Copy
inside it?source§fn resolve_derives(
&mut self,
expn_id: LocalExpnId,
force: bool,
derive_paths: &dyn Fn() -> Vec<DeriveResolution>,
) -> Result<(), Indeterminate>
fn resolve_derives( &mut self, expn_id: LocalExpnId, force: bool, derive_paths: &dyn Fn() -> Vec<DeriveResolution>, ) -> Result<(), Indeterminate>
#[derive(...)]
attribute with the given ExpnId
.source§fn take_derive_resolutions(
&mut self,
expn_id: LocalExpnId,
) -> Option<Vec<DeriveResolution>>
fn take_derive_resolutions( &mut self, expn_id: LocalExpnId, ) -> Option<Vec<DeriveResolution>>
#[derive(...)]
attribute with the given ExpnId
back from resolver.source§fn cfg_accessible(
&mut self,
expn_id: LocalExpnId,
path: &Path,
) -> Result<bool, Indeterminate>
fn cfg_accessible( &mut self, expn_id: LocalExpnId, path: &Path, ) -> Result<bool, Indeterminate>
#[cfg_accessible(path)]
.fn macro_accessible( &mut self, expn_id: LocalExpnId, path: &Path, ) -> Result<bool, Indeterminate>
source§fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span
fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span
source§fn declare_proc_macro(&mut self, id: NodeId)
fn declare_proc_macro(&mut self, id: NodeId)
fn append_stripped_cfg_item( &mut self, parent_node: NodeId, name: Ident, cfg: MetaItem, )
source§fn registered_tools(&self) -> &RegisteredTools
fn registered_tools(&self) -> &RegisteredTools
#![register_tool]
and used by tool attributes and lints.source§fn register_glob_delegation(&mut self, invoc_id: LocalExpnId)
fn register_glob_delegation(&mut self, invoc_id: LocalExpnId)
source§fn glob_delegation_suffixes(
&mut self,
trait_def_id: DefId,
impl_def_id: LocalDefId,
) -> Result<Vec<(Ident, Option<Ident>)>, Indeterminate>
fn glob_delegation_suffixes( &mut self, trait_def_id: DefId, impl_def_id: LocalDefId, ) -> Result<Vec<(Ident, Option<Ident>)>, Indeterminate>
Auto Trait Implementations§
impl<'ra, 'tcx> Freeze for Resolver<'ra, 'tcx>
impl<'ra, 'tcx> !RefUnwindSafe for Resolver<'ra, 'tcx>
impl<'ra, 'tcx> !Send for Resolver<'ra, 'tcx>
impl<'ra, 'tcx> !Sync for Resolver<'ra, 'tcx>
impl<'ra, 'tcx> Unpin for Resolver<'ra, 'tcx>
impl<'ra, 'tcx> !UnwindSafe for Resolver<'ra, 'tcx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 2608 bytes