Skip to content

Use default_field_values in Resolver #145398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 17 additions & 30 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(default_field_values)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(rustc_attrs)]
Expand Down Expand Up @@ -1075,7 +1076,7 @@ pub struct Resolver<'ra, 'tcx> {
/// Assert that we are in speculative resolution mode.
assert_speculative: bool,

prelude: Option<Module<'ra>>,
prelude: Option<Module<'ra>> = None,
extern_prelude: FxIndexMap<Macros20NormalizedIdent, ExternPreludeEntry<'ra>>,

/// N.B., this is used only for better diagnostics, not name resolution itself.
Expand All @@ -1087,10 +1088,10 @@ pub struct Resolver<'ra, 'tcx> {
field_visibility_spans: FxHashMap<DefId, Vec<Span>>,

/// All imports known to succeed or fail.
determined_imports: Vec<Import<'ra>>,
determined_imports: Vec<Import<'ra>> = Vec::new(),

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

// Spans for local variables found during pattern resolution.
// Used for suggestions during error reporting.
Expand Down Expand Up @@ -1141,19 +1142,19 @@ pub struct Resolver<'ra, 'tcx> {

/// Maps glob imports to the names of items actually imported.
glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
glob_error: Option<ErrorGuaranteed>,
visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
glob_error: Option<ErrorGuaranteed> = None,
visibilities_for_hashing: Vec<(LocalDefId, Visibility)> = Vec::new(),
used_imports: FxHashSet<NodeId>,
maybe_unused_trait_imports: FxIndexSet<LocalDefId>,

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

arenas: &'ra ResolverArenas<'ra>,
dummy_binding: NameBinding<'ra>,
Expand Down Expand Up @@ -1205,9 +1206,9 @@ pub struct Resolver<'ra, 'tcx> {
/// Avoid duplicated errors for "name already defined".
name_already_seen: FxHashMap<Symbol, Span>,

potentially_unused_imports: Vec<Import<'ra>>,
potentially_unused_imports: Vec<Import<'ra>> = Vec::new(),

potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>>,
potentially_unnecessary_qualifications: Vec<UnnecessaryQualification<'ra>> = Vec::new(),

/// Table for mapping struct IDs into struct constructor IDs,
/// it's not used during normal resolution, only for better error reporting.
Expand All @@ -1216,7 +1217,7 @@ pub struct Resolver<'ra, 'tcx> {

lint_buffer: LintBuffer,

next_node_id: NodeId,
next_node_id: NodeId = CRATE_NODE_ID,

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

Expand All @@ -1234,17 +1235,17 @@ pub struct Resolver<'ra, 'tcx> {
item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>,
delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,

main_def: Option<MainDefinition>,
main_def: Option<MainDefinition> = None,
trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
/// A list of proc macro LocalDefIds, written out in the order in which
/// they are declared in the static array generated by proc_macro_harness.
proc_macros: Vec<LocalDefId>,
proc_macros: Vec<LocalDefId> = Vec::new(),
confused_type_with_std_module: FxIndexMap<Span, Span>,
/// Whether lifetime elision was successful.
lifetime_elision_allowed: FxHashSet<NodeId>,

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

effective_visibilities: EffectiveVisibilities,
doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
Expand Down Expand Up @@ -1558,9 +1559,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
field_defaults: Default::default(),
field_visibility_spans: FxHashMap::default(),

determined_imports: Vec::new(),
indeterminate_imports: Vec::new(),

pat_span_map: Default::default(),
partial_res_map: Default::default(),
import_res_map: Default::default(),
Expand All @@ -1579,16 +1577,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
ast_transform_scopes: FxHashMap::default(),

glob_map: Default::default(),
glob_error: None,
visibilities_for_hashing: Default::default(),
used_imports: FxHashSet::default(),
maybe_unused_trait_imports: Default::default(),

privacy_errors: Vec::new(),
ambiguity_errors: Vec::new(),
use_injections: Vec::new(),
macro_expanded_macro_export_errors: BTreeSet::new(),

arenas,
dummy_binding: arenas.new_pub_res_binding(Res::Err, DUMMY_SP, LocalExpnId::ROOT),
builtin_types_bindings: PrimTy::ALL
Expand Down Expand Up @@ -1632,8 +1623,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
derive_data: Default::default(),
local_macro_def_scopes: FxHashMap::default(),
name_already_seen: FxHashMap::default(),
potentially_unused_imports: Vec::new(),
potentially_unnecessary_qualifications: Default::default(),
struct_constructors: Default::default(),
unused_macros: Default::default(),
unused_macro_rules: Default::default(),
Expand All @@ -1643,16 +1632,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
builtin_attrs: Default::default(),
containers_deriving_copy: Default::default(),
lint_buffer: LintBuffer::default(),
next_node_id: CRATE_NODE_ID,
node_id_to_def_id,
disambiguator: DisambiguatorState::new(),
placeholder_field_indices: Default::default(),
invocation_parents,
legacy_const_generic_args: Default::default(),
item_generics_num_lifetimes: Default::default(),
main_def: Default::default(),
trait_impls: Default::default(),
proc_macros: Default::default(),
confused_type_with_std_module: Default::default(),
lifetime_elision_allowed: Default::default(),
stripped_cfg_items: Default::default(),
Expand All @@ -1667,6 +1653,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
current_crate_outer_attr_insert_span,
mods_with_parse_errors: Default::default(),
impl_trait_names: Default::default(),
..
};

let root_parent_scope = ParentScope::module(graph_root, resolver.arenas);
Expand Down
Loading