Rollup merge of #145398 - estebank:use-default-fields-resolver, r=petrochenkov
Use `default_field_values` in `Resolver` Change `Resolver` to use `feature(default_field_values)`. This change is non-exhaustive, as fields may have been added since I made this commit, and `Fx(Index/Hash)(Map/Set)` types would need to have a `const` constructable to change the majority of the fields left over. Using default field values should make it easier to review when we add or remove fields to `Resolver` in the future, and highlight which fields are run-time dependent in `Resolver::new`. r? ``@petrochenkov``
This commit is contained in:
commit
93e895bc64
1 changed files with 17 additions and 30 deletions
|
|
@ -16,6 +16,7 @@
|
|||
#![feature(assert_matches)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(default_field_values)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(iter_intersperse)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
@ -1075,7 +1076,7 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
/// Assert that we are in speculative resolution mode.
|
||||
assert_speculative: bool,
|
||||
|
||||
prelude: Option<Module<'ra>>,
|
||||
prelude: Option<Module<'ra>> = None,
|
||||
extern_prelude: FxIndexMap<Macros20NormalizedIdent, ExternPreludeEntry<'ra>>,
|
||||
|
||||
/// N.B., this is used only for better diagnostics, not name resolution itself.
|
||||
|
|
@ -1087,10 +1088,10 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
field_visibility_spans: FxHashMap<DefId, Vec<Span>>,
|
||||
|
||||
/// All imports known to succeed or fail.
|
||||
determined_imports: Vec<Import<'ra>>,
|
||||
determined_imports: Vec<Import<'ra>> = Vec::new(),
|
||||
|
||||
/// All non-determined imports.
|
||||
indeterminate_imports: Vec<Import<'ra>>,
|
||||
indeterminate_imports: Vec<Import<'ra>> = Vec::new(),
|
||||
|
||||
// Spans for local variables found during pattern resolution.
|
||||
// Used for suggestions during error reporting.
|
||||
|
|
@ -1141,19 +1142,19 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
|
||||
/// Maps glob imports to the names of items actually imported.
|
||||
glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
|
||||
glob_error: Option<ErrorGuaranteed>,
|
||||
visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
|
||||
glob_error: Option<ErrorGuaranteed> = None,
|
||||
visibilities_for_hashing: Vec<(LocalDefId, Visibility)> = Vec::new(),
|
||||
used_imports: FxHashSet<NodeId>,
|
||||
maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
|
||||
|
||||
/// Privacy errors are delayed until the end in order to deduplicate them.
|
||||
privacy_errors: Vec<PrivacyError<'ra>>,
|
||||
privacy_errors: Vec<PrivacyError<'ra>> = Vec::new(),
|
||||
/// Ambiguity errors are delayed for deduplication.
|
||||
ambiguity_errors: Vec<AmbiguityError<'ra>>,
|
||||
ambiguity_errors: Vec<AmbiguityError<'ra>> = Vec::new(),
|
||||
/// `use` injections are delayed for better placement and deduplication.
|
||||
use_injections: Vec<UseError<'tcx>>,
|
||||
use_injections: Vec<UseError<'tcx>> = Vec::new(),
|
||||
/// Crate-local macro expanded `macro_export` referred to by a module-relative path.
|
||||
macro_expanded_macro_export_errors: BTreeSet<(Span, Span)>,
|
||||
macro_expanded_macro_export_errors: BTreeSet<(Span, Span)> = BTreeSet::new(),
|
||||
|
||||
arenas: &'ra ResolverArenas<'ra>,
|
||||
dummy_binding: NameBinding<'ra>,
|
||||
|
|
@ -1205,9 +1206,9 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
/// Avoid duplicated errors for "name already defined".
|
||||
name_already_seen: FxHashMap<Symbol, Span>,
|
||||
|
||||
potentially_unused_imports: Vec<Import<'ra>>,
|
||||
potentially_unused_imports: Vec<Import<'ra>> = Vec::new(),
|
||||
|
||||
potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>>,
|
||||
potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>> = Vec::new(),
|
||||
|
||||
/// Table for mapping struct IDs into struct constructor IDs,
|
||||
/// it's not used during normal resolution, only for better error reporting.
|
||||
|
|
@ -1216,7 +1217,7 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
|
||||
lint_buffer: LintBuffer,
|
||||
|
||||
next_node_id: NodeId,
|
||||
next_node_id: NodeId = CRATE_NODE_ID,
|
||||
|
||||
node_id_to_def_id: NodeMap<Feed<'tcx, LocalDefId>>,
|
||||
|
||||
|
|
@ -1234,17 +1235,17 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>,
|
||||
delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,
|
||||
|
||||
main_def: Option<MainDefinition>,
|
||||
main_def: Option<MainDefinition> = None,
|
||||
trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
|
||||
/// 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.
|
||||
proc_macros: Vec<LocalDefId>,
|
||||
proc_macros: Vec<LocalDefId> = Vec::new(),
|
||||
confused_type_with_std_module: FxIndexMap<Span, Span>,
|
||||
/// Whether lifetime elision was successful.
|
||||
lifetime_elision_allowed: FxHashSet<NodeId>,
|
||||
|
||||
/// Names of items that were stripped out via cfg with their corresponding cfg meta item.
|
||||
stripped_cfg_items: Vec<StrippedCfgItem<NodeId>>,
|
||||
stripped_cfg_items: Vec<StrippedCfgItem<NodeId>> = Vec::new(),
|
||||
|
||||
effective_visibilities: EffectiveVisibilities,
|
||||
doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
|
||||
|
|
@ -1558,9 +1559,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
field_defaults: Default::default(),
|
||||
field_visibility_spans: FxHashMap::default(),
|
||||
|
||||
determined_imports: Vec::new(),
|
||||
indeterminate_imports: Vec::new(),
|
||||
|
||||
pat_span_map: Default::default(),
|
||||
partial_res_map: Default::default(),
|
||||
import_res_map: Default::default(),
|
||||
|
|
@ -1579,16 +1577,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
ast_transform_scopes: FxHashMap::default(),
|
||||
|
||||
glob_map: Default::default(),
|
||||
glob_error: None,
|
||||
visibilities_for_hashing: Default::default(),
|
||||
used_imports: FxHashSet::default(),
|
||||
maybe_unused_trait_imports: Default::default(),
|
||||
|
||||
privacy_errors: Vec::new(),
|
||||
ambiguity_errors: Vec::new(),
|
||||
use_injections: Vec::new(),
|
||||
macro_expanded_macro_export_errors: BTreeSet::new(),
|
||||
|
||||
arenas,
|
||||
dummy_binding: arenas.new_pub_res_binding(Res::Err, DUMMY_SP, LocalExpnId::ROOT),
|
||||
builtin_types_bindings: PrimTy::ALL
|
||||
|
|
@ -1632,8 +1623,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
derive_data: Default::default(),
|
||||
local_macro_def_scopes: FxHashMap::default(),
|
||||
name_already_seen: FxHashMap::default(),
|
||||
potentially_unused_imports: Vec::new(),
|
||||
potentially_unnecessary_qualifications: Default::default(),
|
||||
struct_constructors: Default::default(),
|
||||
unused_macros: Default::default(),
|
||||
unused_macro_rules: Default::default(),
|
||||
|
|
@ -1643,16 +1632,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
builtin_attrs: Default::default(),
|
||||
containers_deriving_copy: Default::default(),
|
||||
lint_buffer: LintBuffer::default(),
|
||||
next_node_id: CRATE_NODE_ID,
|
||||
node_id_to_def_id,
|
||||
disambiguator: DisambiguatorState::new(),
|
||||
placeholder_field_indices: Default::default(),
|
||||
invocation_parents,
|
||||
legacy_const_generic_args: Default::default(),
|
||||
item_generics_num_lifetimes: Default::default(),
|
||||
main_def: Default::default(),
|
||||
trait_impls: Default::default(),
|
||||
proc_macros: Default::default(),
|
||||
confused_type_with_std_module: Default::default(),
|
||||
lifetime_elision_allowed: Default::default(),
|
||||
stripped_cfg_items: Default::default(),
|
||||
|
|
@ -1667,6 +1653,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
current_crate_outer_attr_insert_span,
|
||||
mods_with_parse_errors: Default::default(),
|
||||
impl_trait_names: Default::default(),
|
||||
..
|
||||
};
|
||||
|
||||
let root_parent_scope = ParentScope::module(graph_root, resolver.arenas);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue