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) ]
@@ -1024,7 +1025,7 @@ pub struct Resolver<'ra, 'tcx> {
1024
1025
1025
1026
graph_root : Module < ' ra > ,
1026
1027
1027
- prelude : Option < Module < ' ra > > ,
1028
+ prelude : Option < Module < ' ra > > = None ,
1028
1029
extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
1029
1030
1030
1031
/// N.B., this is used only for better diagnostics, not name resolution itself.
@@ -1035,10 +1036,10 @@ pub struct Resolver<'ra, 'tcx> {
1035
1036
field_visibility_spans : FxHashMap < DefId , Vec < Span > > ,
1036
1037
1037
1038
/// All imports known to succeed or fail.
1038
- determined_imports : Vec < Import < ' ra > > ,
1039
+ determined_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1039
1040
1040
1041
/// All non-determined imports.
1041
- indeterminate_imports : Vec < Import < ' ra > > ,
1042
+ indeterminate_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1042
1043
1043
1044
// Spans for local variables found during pattern resolution.
1044
1045
// Used for suggestions during error reporting.
@@ -1087,23 +1088,23 @@ pub struct Resolver<'ra, 'tcx> {
1087
1088
extern_module_map : RefCell < FxIndexMap < DefId , Module < ' ra > > > ,
1088
1089
binding_parent_modules : FxHashMap < NameBinding < ' ra > , Module < ' ra > > ,
1089
1090
1090
- underscore_disambiguator : u32 ,
1091
+ underscore_disambiguator : u32 = 0 ,
1091
1092
1092
1093
/// Maps glob imports to the names of items actually imported.
1093
1094
glob_map : FxIndexMap < LocalDefId , FxIndexSet < Symbol > > ,
1094
- glob_error : Option < ErrorGuaranteed > ,
1095
- visibilities_for_hashing : Vec < ( LocalDefId , Visibility ) > ,
1095
+ glob_error : Option < ErrorGuaranteed > = None ,
1096
+ visibilities_for_hashing : Vec < ( LocalDefId , Visibility ) > = Vec :: new ( ) ,
1096
1097
used_imports : FxHashSet < NodeId > ,
1097
1098
maybe_unused_trait_imports : FxIndexSet < LocalDefId > ,
1098
1099
1099
1100
/// Privacy errors are delayed until the end in order to deduplicate them.
1100
- privacy_errors : Vec < PrivacyError < ' ra > > ,
1101
+ privacy_errors : Vec < PrivacyError < ' ra > > = Vec :: new ( ) ,
1101
1102
/// Ambiguity errors are delayed for deduplication.
1102
- ambiguity_errors : Vec < AmbiguityError < ' ra > > ,
1103
+ ambiguity_errors : Vec < AmbiguityError < ' ra > > = Vec :: new ( ) ,
1103
1104
/// `use` injections are delayed for better placement and deduplication.
1104
- use_injections : Vec < UseError < ' tcx > > ,
1105
+ use_injections : Vec < UseError < ' tcx > > = Vec :: new ( ) ,
1105
1106
/// Crate-local macro expanded `macro_export` referred to by a module-relative path.
1106
- macro_expanded_macro_export_errors : BTreeSet < ( Span , Span ) > ,
1107
+ macro_expanded_macro_export_errors : BTreeSet < ( Span , Span ) > = BTreeSet :: new ( ) ,
1107
1108
1108
1109
arenas : & ' ra ResolverArenas < ' ra > ,
1109
1110
dummy_binding : NameBinding < ' ra > ,
@@ -1130,10 +1131,11 @@ pub struct Resolver<'ra, 'tcx> {
1130
1131
proc_macro_stubs : FxHashSet < LocalDefId > ,
1131
1132
/// Traces collected during macro resolution and validated when it's complete.
1132
1133
single_segment_macro_resolutions :
1133
- Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) > ,
1134
+ Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) >
1135
+ = Vec :: new ( ) ,
1134
1136
multi_segment_macro_resolutions :
1135
- Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > ,
1136
- builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > ,
1137
+ Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > = Vec :: new ( ) ,
1138
+ builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > = Vec :: new ( ) ,
1137
1139
/// `derive(Copy)` marks items they are applied to so they are treated specially later.
1138
1140
/// Derive macros cannot modify the item themselves and have to store the markers in the global
1139
1141
/// context, so they attach the markers to derive container IDs using this resolver table.
@@ -1155,9 +1157,9 @@ pub struct Resolver<'ra, 'tcx> {
1155
1157
/// Avoid duplicated errors for "name already defined".
1156
1158
name_already_seen : FxHashMap < Symbol , Span > ,
1157
1159
1158
- potentially_unused_imports : Vec < Import < ' ra > > ,
1160
+ potentially_unused_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
1159
1161
1160
- potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > ,
1162
+ potentially_unnecessary_qualifications : Vec < UnnecessaryQualification < ' ra > > = Vec :: new ( ) ,
1161
1163
1162
1164
/// Table for mapping struct IDs into struct constructor IDs,
1163
1165
/// it's not used during normal resolution, only for better error reporting.
@@ -1166,7 +1168,7 @@ pub struct Resolver<'ra, 'tcx> {
1166
1168
1167
1169
lint_buffer : LintBuffer ,
1168
1170
1169
- next_node_id : NodeId ,
1171
+ next_node_id : NodeId = CRATE_NODE_ID ,
1170
1172
1171
1173
node_id_to_def_id : NodeMap < Feed < ' tcx , LocalDefId > > ,
1172
1174
@@ -1184,17 +1186,17 @@ pub struct Resolver<'ra, 'tcx> {
1184
1186
item_generics_num_lifetimes : FxHashMap < LocalDefId , usize > ,
1185
1187
delegation_fn_sigs : LocalDefIdMap < DelegationFnSig > ,
1186
1188
1187
- main_def : Option < MainDefinition > ,
1189
+ main_def : Option < MainDefinition > = None ,
1188
1190
trait_impls : FxIndexMap < DefId , Vec < LocalDefId > > ,
1189
1191
/// A list of proc macro LocalDefIds, written out in the order in which
1190
1192
/// they are declared in the static array generated by proc_macro_harness.
1191
- proc_macros : Vec < LocalDefId > ,
1193
+ proc_macros : Vec < LocalDefId > = Vec :: new ( ) ,
1192
1194
confused_type_with_std_module : FxIndexMap < Span , Span > ,
1193
1195
/// Whether lifetime elision was successful.
1194
1196
lifetime_elision_allowed : FxHashSet < NodeId > ,
1195
1197
1196
1198
/// Names of items that were stripped out via cfg with their corresponding cfg meta item.
1197
- stripped_cfg_items : Vec < StrippedCfgItem < NodeId > > ,
1199
+ stripped_cfg_items : Vec < StrippedCfgItem < NodeId > > = Vec :: new ( ) ,
1198
1200
1199
1201
effective_visibilities : EffectiveVisibilities ,
1200
1202
doc_link_resolutions : FxIndexMap < LocalDefId , DocLinkResMap > ,
@@ -1218,7 +1220,7 @@ pub struct Resolver<'ra, 'tcx> {
1218
1220
1219
1221
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1220
1222
/// don't need to run it more than once.
1221
- all_crate_macros_already_registered : bool ,
1223
+ all_crate_macros_already_registered : bool = false ,
1222
1224
1223
1225
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
1224
1226
// that were encountered during resolution. These names are used to generate item names
@@ -1486,15 +1488,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1486
1488
// The outermost module has def ID 0; this is not reflected in the
1487
1489
// AST.
1488
1490
graph_root,
1489
- prelude : None ,
1490
1491
extern_prelude,
1491
1492
1492
1493
field_names : Default :: default ( ) ,
1493
1494
field_visibility_spans : FxHashMap :: default ( ) ,
1494
1495
1495
- determined_imports : Vec :: new ( ) ,
1496
- indeterminate_imports : Vec :: new ( ) ,
1497
-
1498
1496
pat_span_map : Default :: default ( ) ,
1499
1497
partial_res_map : Default :: default ( ) ,
1500
1498
import_res_map : Default :: default ( ) ,
@@ -1505,7 +1503,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1505
1503
extern_crate_map : Default :: default ( ) ,
1506
1504
module_children : Default :: default ( ) ,
1507
1505
trait_map : NodeMap :: default ( ) ,
1508
- underscore_disambiguator : 0 ,
1509
1506
empty_module,
1510
1507
local_module_map,
1511
1508
extern_module_map : Default :: default ( ) ,
@@ -1514,16 +1511,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1514
1511
ast_transform_scopes : FxHashMap :: default ( ) ,
1515
1512
1516
1513
glob_map : Default :: default ( ) ,
1517
- glob_error : None ,
1518
- visibilities_for_hashing : Default :: default ( ) ,
1519
1514
used_imports : FxHashSet :: default ( ) ,
1520
1515
maybe_unused_trait_imports : Default :: default ( ) ,
1521
1516
1522
- privacy_errors : Vec :: new ( ) ,
1523
- ambiguity_errors : Vec :: new ( ) ,
1524
- use_injections : Vec :: new ( ) ,
1525
- macro_expanded_macro_export_errors : BTreeSet :: new ( ) ,
1526
-
1527
1517
arenas,
1528
1518
dummy_binding : arenas. new_pub_res_binding ( Res :: Err , DUMMY_SP , LocalExpnId :: ROOT ) ,
1529
1519
builtin_types_bindings : PrimTy :: ALL
@@ -1568,27 +1558,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1568
1558
derive_data : Default :: default ( ) ,
1569
1559
local_macro_def_scopes : FxHashMap :: default ( ) ,
1570
1560
name_already_seen : FxHashMap :: default ( ) ,
1571
- potentially_unused_imports : Vec :: new ( ) ,
1572
- potentially_unnecessary_qualifications : Default :: default ( ) ,
1573
1561
struct_constructors : Default :: default ( ) ,
1574
1562
unused_macros : Default :: default ( ) ,
1575
1563
unused_macro_rules : Default :: default ( ) ,
1576
1564
proc_macro_stubs : Default :: default ( ) ,
1577
- single_segment_macro_resolutions : Default :: default ( ) ,
1578
- multi_segment_macro_resolutions : Default :: default ( ) ,
1579
- builtin_attrs : Default :: default ( ) ,
1580
1565
containers_deriving_copy : Default :: default ( ) ,
1581
1566
lint_buffer : LintBuffer :: default ( ) ,
1582
- next_node_id : CRATE_NODE_ID ,
1583
1567
node_id_to_def_id,
1584
1568
disambiguator : DisambiguatorState :: new ( ) ,
1585
1569
placeholder_field_indices : Default :: default ( ) ,
1586
1570
invocation_parents,
1587
1571
legacy_const_generic_args : Default :: default ( ) ,
1588
1572
item_generics_num_lifetimes : Default :: default ( ) ,
1589
- main_def : Default :: default ( ) ,
1590
1573
trait_impls : Default :: default ( ) ,
1591
- proc_macros : Default :: default ( ) ,
1592
1574
confused_type_with_std_module : Default :: default ( ) ,
1593
1575
lifetime_elision_allowed : Default :: default ( ) ,
1594
1576
stripped_cfg_items : Default :: default ( ) ,
@@ -1598,12 +1580,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1598
1580
all_macro_rules : Default :: default ( ) ,
1599
1581
delegation_fn_sigs : Default :: default ( ) ,
1600
1582
glob_delegation_invoc_ids : Default :: default ( ) ,
1601
- all_crate_macros_already_registered : false ,
1602
1583
impl_unexpanded_invocations : Default :: default ( ) ,
1603
1584
impl_binding_keys : Default :: default ( ) ,
1604
1585
current_crate_outer_attr_insert_span,
1605
1586
mods_with_parse_errors : Default :: default ( ) ,
1606
1587
impl_trait_names : Default :: default ( ) ,
1588
+ ..
1607
1589
} ;
1608
1590
1609
1591
let root_parent_scope = ParentScope :: module ( graph_root, & resolver) ;
0 commit comments