1414#![ doc( rust_logo) ]
1515#![ feature( assert_matches) ]
1616#![ feature( box_patterns) ]
17+ #![ feature( default_field_values) ]
1718#![ feature( if_let_guard) ]
1819#![ feature( iter_intersperse) ]
1920#![ feature( rustc_attrs) ]
@@ -1036,7 +1037,7 @@ pub struct Resolver<'ra, 'tcx> {
10361037
10371038 graph_root : Module < ' ra > ,
10381039
1039- prelude : Option < Module < ' ra > > ,
1040+ prelude : Option < Module < ' ra > > = None ,
10401041 extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
10411042
10421043 /// N.B., this is used only for better diagnostics, not name resolution itself.
@@ -1047,10 +1048,10 @@ pub struct Resolver<'ra, 'tcx> {
10471048 field_visibility_spans : FxHashMap < DefId , Vec < Span > > ,
10481049
10491050 /// All imports known to succeed or fail.
1050- determined_imports : Vec < Import < ' ra > > ,
1051+ determined_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
10511052
10521053 /// All non-determined imports.
1053- indeterminate_imports : Vec < Import < ' ra > > ,
1054+ indeterminate_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
10541055
10551056 // Spans for local variables found during pattern resolution.
10561057 // Used for suggestions during error reporting.
@@ -1096,23 +1097,23 @@ pub struct Resolver<'ra, 'tcx> {
10961097 module_map : FxIndexMap < DefId , Module < ' ra > > ,
10971098 binding_parent_modules : FxHashMap < NameBinding < ' ra > , Module < ' ra > > ,
10981099
1099- underscore_disambiguator : u32 ,
1100+ underscore_disambiguator : u32 = 0 ,
11001101
11011102 /// Maps glob imports to the names of items actually imported.
11021103 glob_map : FxIndexMap < LocalDefId , FxIndexSet < Symbol > > ,
1103- glob_error : Option < ErrorGuaranteed > ,
1104- visibilities_for_hashing : Vec < ( LocalDefId , ty:: Visibility ) > ,
1104+ glob_error : Option < ErrorGuaranteed > = None ,
1105+ visibilities_for_hashing : Vec < ( LocalDefId , ty:: Visibility ) > = Vec :: new ( ) ,
11051106 used_imports : FxHashSet < NodeId > ,
11061107 maybe_unused_trait_imports : FxIndexSet < LocalDefId > ,
11071108
11081109 /// Privacy errors are delayed until the end in order to deduplicate them.
1109- privacy_errors : Vec < PrivacyError < ' ra > > ,
1110+ privacy_errors : Vec < PrivacyError < ' ra > > = Vec :: new ( ) ,
11101111 /// Ambiguity errors are delayed for deduplication.
1111- ambiguity_errors : Vec < AmbiguityError < ' ra > > ,
1112+ ambiguity_errors : Vec < AmbiguityError < ' ra > > = Vec :: new ( ) ,
11121113 /// `use` injections are delayed for better placement and deduplication.
1113- use_injections : Vec < UseError < ' tcx > > ,
1114+ use_injections : Vec < UseError < ' tcx > > = Vec :: new ( ) ,
11141115 /// Crate-local macro expanded `macro_export` referred to by a module-relative path.
1115- macro_expanded_macro_export_errors : BTreeSet < ( Span , Span ) > ,
1116+ macro_expanded_macro_export_errors : BTreeSet < ( Span , Span ) > = BTreeSet :: new ( ) ,
11161117
11171118 arenas : & ' ra ResolverArenas < ' ra > ,
11181119 dummy_binding : NameBinding < ' ra > ,
@@ -1142,10 +1143,11 @@ pub struct Resolver<'ra, 'tcx> {
11421143 proc_macro_stubs : FxHashSet < LocalDefId > ,
11431144 /// Traces collected during macro resolution and validated when it's complete.
11441145 single_segment_macro_resolutions :
1145- Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) > ,
1146+ Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) >
1147+ = Vec :: new ( ) ,
11461148 multi_segment_macro_resolutions :
1147- Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > ,
1148- builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > ,
1149+ Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > = Vec :: new ( ) ,
1150+ builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > = Vec :: new ( ) ,
11491151 /// `derive(Copy)` marks items they are applied to so they are treated specially later.
11501152 /// Derive macros cannot modify the item themselves and have to store the markers in the global
11511153 /// context, so they attach the markers to derive container IDs using this resolver table.
@@ -1167,9 +1169,9 @@ pub struct Resolver<'ra, 'tcx> {
11671169 /// Avoid duplicated errors for "name already defined".
11681170 name_already_seen : FxHashMap < Symbol , Span > ,
11691171
1170- potentially_unused_imports : Vec < Import < ' ra > > ,
1172+ potentially_unused_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
11711173
1172- potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > ,
1174+ potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > = Vec :: new ( ) ,
11731175
11741176 /// Table for mapping struct IDs into struct constructor IDs,
11751177 /// it's not used during normal resolution, only for better error reporting.
@@ -1178,7 +1180,7 @@ pub struct Resolver<'ra, 'tcx> {
11781180
11791181 lint_buffer : LintBuffer ,
11801182
1181- next_node_id : NodeId ,
1183+ next_node_id : NodeId = CRATE_NODE_ID ,
11821184
11831185 node_id_to_def_id : NodeMap < Feed < ' tcx , LocalDefId > > ,
11841186
@@ -1196,17 +1198,17 @@ pub struct Resolver<'ra, 'tcx> {
11961198 item_generics_num_lifetimes : FxHashMap < LocalDefId , usize > ,
11971199 delegation_fn_sigs : LocalDefIdMap < DelegationFnSig > ,
11981200
1199- main_def : Option < MainDefinition > ,
1201+ main_def : Option < MainDefinition > = None ,
12001202 trait_impls : FxIndexMap < DefId , Vec < LocalDefId > > ,
12011203 /// A list of proc macro LocalDefIds, written out in the order in which
12021204 /// they are declared in the static array generated by proc_macro_harness.
1203- proc_macros : Vec < LocalDefId > ,
1205+ proc_macros : Vec < LocalDefId > = Vec :: new ( ) ,
12041206 confused_type_with_std_module : FxIndexMap < Span , Span > ,
12051207 /// Whether lifetime elision was successful.
12061208 lifetime_elision_allowed : FxHashSet < NodeId > ,
12071209
12081210 /// Names of items that were stripped out via cfg with their corresponding cfg meta item.
1209- stripped_cfg_items : Vec < StrippedCfgItem < NodeId > > ,
1211+ stripped_cfg_items : Vec < StrippedCfgItem < NodeId > > = Vec :: new ( ) ,
12101212
12111213 effective_visibilities : EffectiveVisibilities ,
12121214 doc_link_resolutions : FxIndexMap < LocalDefId , DocLinkResMap > ,
@@ -1228,6 +1230,10 @@ pub struct Resolver<'ra, 'tcx> {
12281230
12291231 mods_with_parse_errors : FxHashSet < DefId > ,
12301232
1233+ /// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1234+ /// don't need to run it more than once.
1235+ all_crate_macros_already_registered : bool = false,
1236+
12311237 // Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12321238 // that were encountered during resolution. These names are used to generate item names
12331239 // for APITs, so we don't want to leak details of resolution into these names.
@@ -1475,15 +1481,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14751481 // The outermost module has def ID 0; this is not reflected in the
14761482 // AST.
14771483 graph_root,
1478- prelude : None ,
14791484 extern_prelude,
14801485
14811486 field_names : Default :: default ( ) ,
14821487 field_visibility_spans : FxHashMap :: default ( ) ,
14831488
1484- determined_imports : Vec :: new ( ) ,
1485- indeterminate_imports : Vec :: new ( ) ,
1486-
14871489 pat_span_map : Default :: default ( ) ,
14881490 partial_res_map : Default :: default ( ) ,
14891491 import_res_map : Default :: default ( ) ,
@@ -1494,24 +1496,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14941496 extern_crate_map : Default :: default ( ) ,
14951497 module_children : Default :: default ( ) ,
14961498 trait_map : NodeMap :: default ( ) ,
1497- underscore_disambiguator : 0 ,
14981499 empty_module,
14991500 module_map,
15001501 block_map : Default :: default ( ) ,
15011502 binding_parent_modules : FxHashMap :: default ( ) ,
15021503 ast_transform_scopes : FxHashMap :: default ( ) ,
15031504
15041505 glob_map : Default :: default ( ) ,
1505- glob_error : None ,
1506- visibilities_for_hashing : Default :: default ( ) ,
15071506 used_imports : FxHashSet :: default ( ) ,
15081507 maybe_unused_trait_imports : Default :: default ( ) ,
15091508
1510- privacy_errors : Vec :: new ( ) ,
1511- ambiguity_errors : Vec :: new ( ) ,
1512- use_injections : Vec :: new ( ) ,
1513- macro_expanded_macro_export_errors : BTreeSet :: new ( ) ,
1514-
15151509 arenas,
15161510 dummy_binding : ( Res :: Err , pub_vis, DUMMY_SP , LocalExpnId :: ROOT ) . to_name_binding ( arenas) ,
15171511 builtin_types_bindings : PrimTy :: ALL
@@ -1559,27 +1553,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15591553 derive_data : Default :: default ( ) ,
15601554 local_macro_def_scopes : FxHashMap :: default ( ) ,
15611555 name_already_seen : FxHashMap :: default ( ) ,
1562- potentially_unused_imports : Vec :: new ( ) ,
1563- potentially_unnecessary_qualifications : Default :: default ( ) ,
15641556 struct_constructors : Default :: default ( ) ,
15651557 unused_macros : Default :: default ( ) ,
15661558 unused_macro_rules : Default :: default ( ) ,
15671559 proc_macro_stubs : Default :: default ( ) ,
1568- single_segment_macro_resolutions : Default :: default ( ) ,
1569- multi_segment_macro_resolutions : Default :: default ( ) ,
1570- builtin_attrs : Default :: default ( ) ,
15711560 containers_deriving_copy : Default :: default ( ) ,
15721561 lint_buffer : LintBuffer :: default ( ) ,
1573- next_node_id : CRATE_NODE_ID ,
15741562 node_id_to_def_id,
15751563 disambiguator : DisambiguatorState :: new ( ) ,
15761564 placeholder_field_indices : Default :: default ( ) ,
15771565 invocation_parents,
15781566 legacy_const_generic_args : Default :: default ( ) ,
15791567 item_generics_num_lifetimes : Default :: default ( ) ,
1580- main_def : Default :: default ( ) ,
15811568 trait_impls : Default :: default ( ) ,
1582- proc_macros : Default :: default ( ) ,
15831569 confused_type_with_std_module : Default :: default ( ) ,
15841570 lifetime_elision_allowed : Default :: default ( ) ,
15851571 stripped_cfg_items : Default :: default ( ) ,
@@ -1594,6 +1580,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15941580 current_crate_outer_attr_insert_span,
15951581 mods_with_parse_errors : Default :: default ( ) ,
15961582 impl_trait_names : Default :: default ( ) ,
1583+ ..
15971584 } ;
15981585
15991586 let root_parent_scope = ParentScope :: module ( graph_root, & resolver) ;
0 commit comments