Skip to content

Commit 3d10f1b

Browse files
committed
Use default_field_values in Resolver
1 parent 4bc5579 commit 3d10f1b

File tree

1 file changed

+18
-32
lines changed
  • compiler/rustc_resolve/src

1 file changed

+18
-32
lines changed

compiler/rustc_resolve/src/lib.rs

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(arbitrary_self_types)]
1616
#![feature(assert_matches)]
1717
#![feature(box_patterns)]
18+
#![feature(default_field_values)]
1819
#![feature(if_let_guard)]
1920
#![feature(iter_intersperse)]
2021
#![feature(rustc_attrs)]
@@ -1059,7 +1060,7 @@ pub struct Resolver<'ra, 'tcx> {
10591060
/// Assert that we are in speculative resolution mode.
10601061
assert_speculative: bool,
10611062

1062-
prelude: Option<Module<'ra>>,
1063+
prelude: Option<Module<'ra>> = None,
10631064
extern_prelude: FxIndexMap<Macros20NormalizedIdent, ExternPreludeEntry<'ra>>,
10641065

10651066
/// N.B., this is used only for better diagnostics, not name resolution itself.
@@ -1070,10 +1071,10 @@ pub struct Resolver<'ra, 'tcx> {
10701071
field_visibility_spans: FxHashMap<DefId, Vec<Span>>,
10711072

10721073
/// All imports known to succeed or fail.
1073-
determined_imports: Vec<Import<'ra>>,
1074+
determined_imports: Vec<Import<'ra>> = Vec::new(),
10741075

10751076
/// All non-determined imports.
1076-
indeterminate_imports: Vec<Import<'ra>>,
1077+
indeterminate_imports: Vec<Import<'ra>> = Vec::new(),
10771078

10781079
// Spans for local variables found during pattern resolution.
10791080
// Used for suggestions during error reporting.
@@ -1124,19 +1125,19 @@ pub struct Resolver<'ra, 'tcx> {
11241125

11251126
/// Maps glob imports to the names of items actually imported.
11261127
glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
1127-
glob_error: Option<ErrorGuaranteed>,
1128-
visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
1128+
glob_error: Option<ErrorGuaranteed> = None,
1129+
visibilities_for_hashing: Vec<(LocalDefId, Visibility)> = Vec::new(),
11291130
used_imports: FxHashSet<NodeId>,
11301131
maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
11311132

11321133
/// Privacy errors are delayed until the end in order to deduplicate them.
1133-
privacy_errors: Vec<PrivacyError<'ra>>,
1134+
privacy_errors: Vec<PrivacyError<'ra>> = Vec::new(),
11341135
/// Ambiguity errors are delayed for deduplication.
1135-
ambiguity_errors: Vec<AmbiguityError<'ra>>,
1136+
ambiguity_errors: Vec<AmbiguityError<'ra>> = Vec::new(),
11361137
/// `use` injections are delayed for better placement and deduplication.
1137-
use_injections: Vec<UseError<'tcx>>,
1138+
use_injections: Vec<UseError<'tcx>> = Vec::new(),
11381139
/// Crate-local macro expanded `macro_export` referred to by a module-relative path.
1139-
macro_expanded_macro_export_errors: BTreeSet<(Span, Span)>,
1140+
macro_expanded_macro_export_errors: BTreeSet<(Span, Span)> = BTreeSet::new(),
11401141

11411142
arenas: &'ra ResolverArenas<'ra>,
11421143
dummy_binding: NameBinding<'ra>,
@@ -1188,9 +1189,9 @@ pub struct Resolver<'ra, 'tcx> {
11881189
/// Avoid duplicated errors for "name already defined".
11891190
name_already_seen: FxHashMap<Symbol, Span>,
11901191

1191-
potentially_unused_imports: Vec<Import<'ra>>,
1192+
potentially_unused_imports: Vec<Import<'ra>> = Vec::new(),
11921193

1193-
potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>>,
1194+
potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>> = Vec::new(),
11941195

11951196
/// Table for mapping struct IDs into struct constructor IDs,
11961197
/// it's not used during normal resolution, only for better error reporting.
@@ -1199,7 +1200,7 @@ pub struct Resolver<'ra, 'tcx> {
11991200

12001201
lint_buffer: LintBuffer,
12011202

1202-
next_node_id: NodeId,
1203+
next_node_id: NodeId = CRATE_NODE_ID,
12031204

12041205
node_id_to_def_id: NodeMap<Feed<'tcx, LocalDefId>>,
12051206

@@ -1217,17 +1218,17 @@ pub struct Resolver<'ra, 'tcx> {
12171218
item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>,
12181219
delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,
12191220

1220-
main_def: Option<MainDefinition>,
1221+
main_def: Option<MainDefinition> = None,
12211222
trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
12221223
/// A list of proc macro LocalDefIds, written out in the order in which
12231224
/// they are declared in the static array generated by proc_macro_harness.
1224-
proc_macros: Vec<LocalDefId>,
1225+
proc_macros: Vec<LocalDefId> = Vec::new(),
12251226
confused_type_with_std_module: FxIndexMap<Span, Span>,
12261227
/// Whether lifetime elision was successful.
12271228
lifetime_elision_allowed: FxHashSet<NodeId>,
12281229

12291230
/// Names of items that were stripped out via cfg with their corresponding cfg meta item.
1230-
stripped_cfg_items: Vec<StrippedCfgItem<NodeId>>,
1231+
stripped_cfg_items: Vec<StrippedCfgItem<NodeId>> = Vec::new(),
12311232

12321233
effective_visibilities: EffectiveVisibilities,
12331234
doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
@@ -1251,7 +1252,7 @@ pub struct Resolver<'ra, 'tcx> {
12511252

12521253
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
12531254
/// don't need to run it more than once.
1254-
all_crate_macros_already_registered: bool,
1255+
all_crate_macros_already_registered: bool = false,
12551256

12561257
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12571258
// that were encountered during resolution. These names are used to generate item names
@@ -1544,9 +1545,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15441545
field_names: Default::default(),
15451546
field_visibility_spans: FxHashMap::default(),
15461547

1547-
determined_imports: Vec::new(),
1548-
indeterminate_imports: Vec::new(),
1549-
15501548
pat_span_map: Default::default(),
15511549
partial_res_map: Default::default(),
15521550
import_res_map: Default::default(),
@@ -1565,16 +1563,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15651563
ast_transform_scopes: FxHashMap::default(),
15661564

15671565
glob_map: Default::default(),
1568-
glob_error: None,
1569-
visibilities_for_hashing: Default::default(),
15701566
used_imports: FxHashSet::default(),
15711567
maybe_unused_trait_imports: Default::default(),
15721568

1573-
privacy_errors: Vec::new(),
1574-
ambiguity_errors: Vec::new(),
1575-
use_injections: Vec::new(),
1576-
macro_expanded_macro_export_errors: BTreeSet::new(),
1577-
15781569
arenas,
15791570
dummy_binding: arenas.new_pub_res_binding(Res::Err, DUMMY_SP, LocalExpnId::ROOT),
15801571
builtin_types_bindings: PrimTy::ALL
@@ -1618,8 +1609,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16181609
derive_data: Default::default(),
16191610
local_macro_def_scopes: FxHashMap::default(),
16201611
name_already_seen: FxHashMap::default(),
1621-
potentially_unused_imports: Vec::new(),
1622-
potentially_unnecessary_qualifications: Default::default(),
16231612
struct_constructors: Default::default(),
16241613
unused_macros: Default::default(),
16251614
unused_macro_rules: Default::default(),
@@ -1629,16 +1618,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16291618
builtin_attrs: Default::default(),
16301619
containers_deriving_copy: Default::default(),
16311620
lint_buffer: LintBuffer::default(),
1632-
next_node_id: CRATE_NODE_ID,
16331621
node_id_to_def_id,
16341622
disambiguator: DisambiguatorState::new(),
16351623
placeholder_field_indices: Default::default(),
16361624
invocation_parents,
16371625
legacy_const_generic_args: Default::default(),
16381626
item_generics_num_lifetimes: Default::default(),
1639-
main_def: Default::default(),
16401627
trait_impls: Default::default(),
1641-
proc_macros: Default::default(),
16421628
confused_type_with_std_module: Default::default(),
16431629
lifetime_elision_allowed: Default::default(),
16441630
stripped_cfg_items: Default::default(),
@@ -1648,12 +1634,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16481634
all_macro_rules: Default::default(),
16491635
delegation_fn_sigs: Default::default(),
16501636
glob_delegation_invoc_ids: Default::default(),
1651-
all_crate_macros_already_registered: false,
16521637
impl_unexpanded_invocations: Default::default(),
16531638
impl_binding_keys: Default::default(),
16541639
current_crate_outer_attr_insert_span,
16551640
mods_with_parse_errors: Default::default(),
16561641
impl_trait_names: Default::default(),
1642+
..
16571643
};
16581644

16591645
let root_parent_scope = ParentScope::module(graph_root, resolver.arenas);

0 commit comments

Comments
 (0)