14
14
#![ doc( rust_logo) ]
15
15
#![ feature( assert_matches) ]
16
16
#![ feature( box_patterns) ]
17
+ #![ feature( default_field_values) ]
17
18
#![ feature( if_let_guard) ]
18
19
#![ feature( iter_intersperse) ]
19
20
#![ feature( rustc_attrs) ]
@@ -1036,7 +1037,7 @@ pub struct Resolver<'ra, 'tcx> {
1036
1037
1037
1038
graph_root : Module < ' ra > ,
1038
1039
1039
- prelude : Option < Module < ' ra > > ,
1040
+ prelude : Option < Module < ' ra > > = None ,
1040
1041
extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
1041
1042
1042
1043
/// N.B., this is used only for better diagnostics, not name resolution itself.
@@ -1047,10 +1048,10 @@ pub struct Resolver<'ra, 'tcx> {
1047
1048
field_visibility_spans : FxHashMap < DefId , Vec < Span > > ,
1048
1049
1049
1050
/// All imports known to succeed or fail.
1050
- determined_imports : Vec < Import < ' ra > > ,
1051
+ determined_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1051
1052
1052
1053
/// All non-determined imports.
1053
- indeterminate_imports : Vec < Import < ' ra > > ,
1054
+ indeterminate_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1054
1055
1055
1056
// Spans for local variables found during pattern resolution.
1056
1057
// Used for suggestions during error reporting.
@@ -1096,23 +1097,23 @@ pub struct Resolver<'ra, 'tcx> {
1096
1097
module_map : FxIndexMap < DefId , Module < ' ra > > ,
1097
1098
binding_parent_modules : FxHashMap < NameBinding < ' ra > , Module < ' ra > > ,
1098
1099
1099
- underscore_disambiguator : u32 ,
1100
+ underscore_disambiguator : u32 = 0 ,
1100
1101
1101
1102
/// Maps glob imports to the names of items actually imported.
1102
1103
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 ( ) ,
1105
1106
used_imports : FxHashSet < NodeId > ,
1106
1107
maybe_unused_trait_imports : FxIndexSet < LocalDefId > ,
1107
1108
1108
1109
/// 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 ( ) ,
1110
1111
/// Ambiguity errors are delayed for deduplication.
1111
- ambiguity_errors : Vec < AmbiguityError < ' ra > > ,
1112
+ ambiguity_errors : Vec < AmbiguityError < ' ra > > = Vec :: new ( ) ,
1112
1113
/// `use` injections are delayed for better placement and deduplication.
1113
- use_injections : Vec < UseError < ' tcx > > ,
1114
+ use_injections : Vec < UseError < ' tcx > > = Vec :: new ( ) ,
1114
1115
/// 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 ( ) ,
1116
1117
1117
1118
arenas : & ' ra ResolverArenas < ' ra > ,
1118
1119
dummy_binding : NameBinding < ' ra > ,
@@ -1142,10 +1143,11 @@ pub struct Resolver<'ra, 'tcx> {
1142
1143
proc_macro_stubs : FxHashSet < LocalDefId > ,
1143
1144
/// Traces collected during macro resolution and validated when it's complete.
1144
1145
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 ( ) ,
1146
1148
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 ( ) ,
1149
1151
/// `derive(Copy)` marks items they are applied to so they are treated specially later.
1150
1152
/// Derive macros cannot modify the item themselves and have to store the markers in the global
1151
1153
/// context, so they attach the markers to derive container IDs using this resolver table.
@@ -1167,9 +1169,9 @@ pub struct Resolver<'ra, 'tcx> {
1167
1169
/// Avoid duplicated errors for "name already defined".
1168
1170
name_already_seen : FxHashMap < Symbol , Span > ,
1169
1171
1170
- potentially_unused_imports : Vec < Import < ' ra > > ,
1172
+ potentially_unused_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1171
1173
1172
- potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > ,
1174
+ potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > = Vec :: new ( ) ,
1173
1175
1174
1176
/// Table for mapping struct IDs into struct constructor IDs,
1175
1177
/// it's not used during normal resolution, only for better error reporting.
@@ -1178,7 +1180,7 @@ pub struct Resolver<'ra, 'tcx> {
1178
1180
1179
1181
lint_buffer : LintBuffer ,
1180
1182
1181
- next_node_id : NodeId ,
1183
+ next_node_id : NodeId = CRATE_NODE_ID ,
1182
1184
1183
1185
node_id_to_def_id : NodeMap < Feed < ' tcx , LocalDefId > > ,
1184
1186
@@ -1196,17 +1198,17 @@ pub struct Resolver<'ra, 'tcx> {
1196
1198
item_generics_num_lifetimes : FxHashMap < LocalDefId , usize > ,
1197
1199
delegation_fn_sigs : LocalDefIdMap < DelegationFnSig > ,
1198
1200
1199
- main_def : Option < MainDefinition > ,
1201
+ main_def : Option < MainDefinition > = None ,
1200
1202
trait_impls : FxIndexMap < DefId , Vec < LocalDefId > > ,
1201
1203
/// A list of proc macro LocalDefIds, written out in the order in which
1202
1204
/// they are declared in the static array generated by proc_macro_harness.
1203
- proc_macros : Vec < LocalDefId > ,
1205
+ proc_macros : Vec < LocalDefId > = Vec :: new ( ) ,
1204
1206
confused_type_with_std_module : FxIndexMap < Span , Span > ,
1205
1207
/// Whether lifetime elision was successful.
1206
1208
lifetime_elision_allowed : FxHashSet < NodeId > ,
1207
1209
1208
1210
/// 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 ( ) ,
1210
1212
1211
1213
effective_visibilities : EffectiveVisibilities ,
1212
1214
doc_link_resolutions : FxIndexMap < LocalDefId , DocLinkResMap > ,
@@ -1228,6 +1230,10 @@ pub struct Resolver<'ra, 'tcx> {
1228
1230
1229
1231
mods_with_parse_errors : FxHashSet < DefId > ,
1230
1232
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
+
1231
1237
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
1232
1238
// that were encountered during resolution. These names are used to generate item names
1233
1239
// 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> {
1475
1481
// The outermost module has def ID 0; this is not reflected in the
1476
1482
// AST.
1477
1483
graph_root,
1478
- prelude : None ,
1479
1484
extern_prelude,
1480
1485
1481
1486
field_names : Default :: default ( ) ,
1482
1487
field_visibility_spans : FxHashMap :: default ( ) ,
1483
1488
1484
- determined_imports : Vec :: new ( ) ,
1485
- indeterminate_imports : Vec :: new ( ) ,
1486
-
1487
1489
pat_span_map : Default :: default ( ) ,
1488
1490
partial_res_map : Default :: default ( ) ,
1489
1491
import_res_map : Default :: default ( ) ,
@@ -1494,24 +1496,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1494
1496
extern_crate_map : Default :: default ( ) ,
1495
1497
module_children : Default :: default ( ) ,
1496
1498
trait_map : NodeMap :: default ( ) ,
1497
- underscore_disambiguator : 0 ,
1498
1499
empty_module,
1499
1500
module_map,
1500
1501
block_map : Default :: default ( ) ,
1501
1502
binding_parent_modules : FxHashMap :: default ( ) ,
1502
1503
ast_transform_scopes : FxHashMap :: default ( ) ,
1503
1504
1504
1505
glob_map : Default :: default ( ) ,
1505
- glob_error : None ,
1506
- visibilities_for_hashing : Default :: default ( ) ,
1507
1506
used_imports : FxHashSet :: default ( ) ,
1508
1507
maybe_unused_trait_imports : Default :: default ( ) ,
1509
1508
1510
- privacy_errors : Vec :: new ( ) ,
1511
- ambiguity_errors : Vec :: new ( ) ,
1512
- use_injections : Vec :: new ( ) ,
1513
- macro_expanded_macro_export_errors : BTreeSet :: new ( ) ,
1514
-
1515
1509
arenas,
1516
1510
dummy_binding : ( Res :: Err , pub_vis, DUMMY_SP , LocalExpnId :: ROOT ) . to_name_binding ( arenas) ,
1517
1511
builtin_types_bindings : PrimTy :: ALL
@@ -1559,27 +1553,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1559
1553
derive_data : Default :: default ( ) ,
1560
1554
local_macro_def_scopes : FxHashMap :: default ( ) ,
1561
1555
name_already_seen : FxHashMap :: default ( ) ,
1562
- potentially_unused_imports : Vec :: new ( ) ,
1563
- potentially_unnecessary_qualifications : Default :: default ( ) ,
1564
1556
struct_constructors : Default :: default ( ) ,
1565
1557
unused_macros : Default :: default ( ) ,
1566
1558
unused_macro_rules : Default :: default ( ) ,
1567
1559
proc_macro_stubs : Default :: default ( ) ,
1568
- single_segment_macro_resolutions : Default :: default ( ) ,
1569
- multi_segment_macro_resolutions : Default :: default ( ) ,
1570
- builtin_attrs : Default :: default ( ) ,
1571
1560
containers_deriving_copy : Default :: default ( ) ,
1572
1561
lint_buffer : LintBuffer :: default ( ) ,
1573
- next_node_id : CRATE_NODE_ID ,
1574
1562
node_id_to_def_id,
1575
1563
disambiguator : DisambiguatorState :: new ( ) ,
1576
1564
placeholder_field_indices : Default :: default ( ) ,
1577
1565
invocation_parents,
1578
1566
legacy_const_generic_args : Default :: default ( ) ,
1579
1567
item_generics_num_lifetimes : Default :: default ( ) ,
1580
- main_def : Default :: default ( ) ,
1581
1568
trait_impls : Default :: default ( ) ,
1582
- proc_macros : Default :: default ( ) ,
1583
1569
confused_type_with_std_module : Default :: default ( ) ,
1584
1570
lifetime_elision_allowed : Default :: default ( ) ,
1585
1571
stripped_cfg_items : Default :: default ( ) ,
@@ -1594,6 +1580,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1594
1580
current_crate_outer_attr_insert_span,
1595
1581
mods_with_parse_errors : Default :: default ( ) ,
1596
1582
impl_trait_names : Default :: default ( ) ,
1583
+ ..
1597
1584
} ;
1598
1585
1599
1586
let root_parent_scope = ParentScope :: module ( graph_root, & resolver) ;
0 commit comments