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) ]
@@ -1054,7 +1055,7 @@ pub struct Resolver<'ra, 'tcx> {
1054
1055
1055
1056
graph_root : Module < ' ra > ,
1056
1057
1057
- prelude : Option < Module < ' ra > > ,
1058
+ prelude : Option < Module < ' ra > > = None ,
1058
1059
extern_prelude : FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' ra > > ,
1059
1060
1060
1061
/// N.B., this is used only for better diagnostics, not name resolution itself.
@@ -1065,10 +1066,10 @@ pub struct Resolver<'ra, 'tcx> {
1065
1066
field_visibility_spans : FxHashMap < DefId , Vec < Span > > ,
1066
1067
1067
1068
/// All imports known to succeed or fail.
1068
- determined_imports : Vec < Import < ' ra > > ,
1069
+ determined_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1069
1070
1070
1071
/// All non-determined imports.
1071
- indeterminate_imports : Vec < Import < ' ra > > ,
1072
+ indeterminate_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1072
1073
1073
1074
// Spans for local variables found during pattern resolution.
1074
1075
// Used for suggestions during error reporting.
@@ -1119,19 +1120,19 @@ pub struct Resolver<'ra, 'tcx> {
1119
1120
1120
1121
/// Maps glob imports to the names of items actually imported.
1121
1122
glob_map : FxIndexMap < LocalDefId , FxIndexSet < Symbol > > ,
1122
- glob_error : Option < ErrorGuaranteed > ,
1123
- visibilities_for_hashing : Vec < ( LocalDefId , Visibility ) > ,
1123
+ glob_error : Option < ErrorGuaranteed > = None ,
1124
+ visibilities_for_hashing : Vec < ( LocalDefId , Visibility ) > = Vec :: new ( ) ,
1124
1125
used_imports : FxHashSet < NodeId > ,
1125
1126
maybe_unused_trait_imports : FxIndexSet < LocalDefId > ,
1126
1127
1127
1128
/// Privacy errors are delayed until the end in order to deduplicate them.
1128
- privacy_errors : Vec < PrivacyError < ' ra > > ,
1129
+ privacy_errors : Vec < PrivacyError < ' ra > > = Vec :: new ( ) ,
1129
1130
/// Ambiguity errors are delayed for deduplication.
1130
- ambiguity_errors : Vec < AmbiguityError < ' ra > > ,
1131
+ ambiguity_errors : Vec < AmbiguityError < ' ra > > = Vec :: new ( ) ,
1131
1132
/// `use` injections are delayed for better placement and deduplication.
1132
- use_injections : Vec < UseError < ' tcx > > ,
1133
+ use_injections : Vec < UseError < ' tcx > > = Vec :: new ( ) ,
1133
1134
/// Crate-local macro expanded `macro_export` referred to by a module-relative path.
1134
- macro_expanded_macro_export_errors : BTreeSet < ( Span , Span ) > ,
1135
+ macro_expanded_macro_export_errors : BTreeSet < ( Span , Span ) > = BTreeSet :: new ( ) ,
1135
1136
1136
1137
arenas : & ' ra ResolverArenas < ' ra > ,
1137
1138
dummy_binding : NameBinding < ' ra > ,
@@ -1157,10 +1158,11 @@ pub struct Resolver<'ra, 'tcx> {
1157
1158
proc_macro_stubs : FxHashSet < LocalDefId > ,
1158
1159
/// Traces collected during macro resolution and validated when it's complete.
1159
1160
single_segment_macro_resolutions :
1160
- Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) > ,
1161
+ Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) >
1162
+ = Vec :: new ( ) ,
1161
1163
multi_segment_macro_resolutions :
1162
- Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > ,
1163
- builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > ,
1164
+ Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > = Vec :: new ( ) ,
1165
+ builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > = Vec :: new ( ) ,
1164
1166
/// `derive(Copy)` marks items they are applied to so they are treated specially later.
1165
1167
/// Derive macros cannot modify the item themselves and have to store the markers in the global
1166
1168
/// context, so they attach the markers to derive container IDs using this resolver table.
@@ -1182,9 +1184,9 @@ pub struct Resolver<'ra, 'tcx> {
1182
1184
/// Avoid duplicated errors for "name already defined".
1183
1185
name_already_seen : FxHashMap < Symbol , Span > ,
1184
1186
1185
- potentially_unused_imports : Vec < Import < ' ra > > ,
1187
+ potentially_unused_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1186
1188
1187
- potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > ,
1189
+ potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > = Vec :: new ( ) ,
1188
1190
1189
1191
/// Table for mapping struct IDs into struct constructor IDs,
1190
1192
/// it's not used during normal resolution, only for better error reporting.
@@ -1193,7 +1195,7 @@ pub struct Resolver<'ra, 'tcx> {
1193
1195
1194
1196
lint_buffer : LintBuffer ,
1195
1197
1196
- next_node_id : NodeId ,
1198
+ next_node_id : NodeId = CRATE_NODE_ID ,
1197
1199
1198
1200
node_id_to_def_id : NodeMap < Feed < ' tcx , LocalDefId > > ,
1199
1201
@@ -1211,17 +1213,17 @@ pub struct Resolver<'ra, 'tcx> {
1211
1213
item_generics_num_lifetimes : FxHashMap < LocalDefId , usize > ,
1212
1214
delegation_fn_sigs : LocalDefIdMap < DelegationFnSig > ,
1213
1215
1214
- main_def : Option < MainDefinition > ,
1216
+ main_def : Option < MainDefinition > = None ,
1215
1217
trait_impls : FxIndexMap < DefId , Vec < LocalDefId > > ,
1216
1218
/// A list of proc macro LocalDefIds, written out in the order in which
1217
1219
/// they are declared in the static array generated by proc_macro_harness.
1218
- proc_macros : Vec < LocalDefId > ,
1220
+ proc_macros : Vec < LocalDefId > = Vec :: new ( ) ,
1219
1221
confused_type_with_std_module : FxIndexMap < Span , Span > ,
1220
1222
/// Whether lifetime elision was successful.
1221
1223
lifetime_elision_allowed : FxHashSet < NodeId > ,
1222
1224
1223
1225
/// Names of items that were stripped out via cfg with their corresponding cfg meta item.
1224
- stripped_cfg_items : Vec < StrippedCfgItem < NodeId > > ,
1226
+ stripped_cfg_items : Vec < StrippedCfgItem < NodeId > > = Vec :: new ( ) ,
1225
1227
1226
1228
effective_visibilities : EffectiveVisibilities ,
1227
1229
doc_link_resolutions : FxIndexMap < LocalDefId , DocLinkResMap > ,
@@ -1245,7 +1247,7 @@ pub struct Resolver<'ra, 'tcx> {
1245
1247
1246
1248
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1247
1249
/// don't need to run it more than once.
1248
- all_crate_macros_already_registered : bool ,
1250
+ all_crate_macros_already_registered : bool = false ,
1249
1251
1250
1252
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
1251
1253
// that were encountered during resolution. These names are used to generate item names
@@ -1531,15 +1533,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1531
1533
// The outermost module has def ID 0; this is not reflected in the
1532
1534
// AST.
1533
1535
graph_root,
1534
- prelude : None ,
1535
1536
extern_prelude,
1536
1537
1537
1538
field_names : Default :: default ( ) ,
1538
1539
field_visibility_spans : FxHashMap :: default ( ) ,
1539
1540
1540
- determined_imports : Vec :: new ( ) ,
1541
- indeterminate_imports : Vec :: new ( ) ,
1542
-
1543
1541
pat_span_map : Default :: default ( ) ,
1544
1542
partial_res_map : Default :: default ( ) ,
1545
1543
import_res_map : Default :: default ( ) ,
@@ -1558,16 +1556,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1558
1556
ast_transform_scopes : FxHashMap :: default ( ) ,
1559
1557
1560
1558
glob_map : Default :: default ( ) ,
1561
- glob_error : None ,
1562
- visibilities_for_hashing : Default :: default ( ) ,
1563
1559
used_imports : FxHashSet :: default ( ) ,
1564
1560
maybe_unused_trait_imports : Default :: default ( ) ,
1565
1561
1566
- privacy_errors : Vec :: new ( ) ,
1567
- ambiguity_errors : Vec :: new ( ) ,
1568
- use_injections : Vec :: new ( ) ,
1569
- macro_expanded_macro_export_errors : BTreeSet :: new ( ) ,
1570
-
1571
1562
arenas,
1572
1563
dummy_binding : arenas. new_pub_res_binding ( Res :: Err , DUMMY_SP , LocalExpnId :: ROOT ) ,
1573
1564
builtin_types_bindings : PrimTy :: ALL
@@ -1611,27 +1602,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1611
1602
derive_data : Default :: default ( ) ,
1612
1603
local_macro_def_scopes : FxHashMap :: default ( ) ,
1613
1604
name_already_seen : FxHashMap :: default ( ) ,
1614
- potentially_unused_imports : Vec :: new ( ) ,
1615
- potentially_unnecessary_qualifications : Default :: default ( ) ,
1616
1605
struct_constructors : Default :: default ( ) ,
1617
1606
unused_macros : Default :: default ( ) ,
1618
1607
unused_macro_rules : Default :: default ( ) ,
1619
1608
proc_macro_stubs : Default :: default ( ) ,
1620
- single_segment_macro_resolutions : Default :: default ( ) ,
1621
- multi_segment_macro_resolutions : Default :: default ( ) ,
1622
- builtin_attrs : Default :: default ( ) ,
1623
1609
containers_deriving_copy : Default :: default ( ) ,
1624
1610
lint_buffer : LintBuffer :: default ( ) ,
1625
- next_node_id : CRATE_NODE_ID ,
1626
1611
node_id_to_def_id,
1627
1612
disambiguator : DisambiguatorState :: new ( ) ,
1628
1613
placeholder_field_indices : Default :: default ( ) ,
1629
1614
invocation_parents,
1630
1615
legacy_const_generic_args : Default :: default ( ) ,
1631
1616
item_generics_num_lifetimes : Default :: default ( ) ,
1632
- main_def : Default :: default ( ) ,
1633
1617
trait_impls : Default :: default ( ) ,
1634
- proc_macros : Default :: default ( ) ,
1635
1618
confused_type_with_std_module : Default :: default ( ) ,
1636
1619
lifetime_elision_allowed : Default :: default ( ) ,
1637
1620
stripped_cfg_items : Default :: default ( ) ,
@@ -1641,12 +1624,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1641
1624
all_macro_rules : Default :: default ( ) ,
1642
1625
delegation_fn_sigs : Default :: default ( ) ,
1643
1626
glob_delegation_invoc_ids : Default :: default ( ) ,
1644
- all_crate_macros_already_registered : false ,
1645
1627
impl_unexpanded_invocations : Default :: default ( ) ,
1646
1628
impl_binding_keys : Default :: default ( ) ,
1647
1629
current_crate_outer_attr_insert_span,
1648
1630
mods_with_parse_errors : Default :: default ( ) ,
1649
1631
impl_trait_names : Default :: default ( ) ,
1632
+ ..
1650
1633
} ;
1651
1634
1652
1635
let root_parent_scope = ParentScope :: module ( graph_root, & resolver) ;
0 commit comments