This commit is contained in:
Wyatt Herkamp 2024-03-21 08:12:26 -04:00
parent 70f5344deb
commit c376addfcc

View File

@ -3,85 +3,60 @@
//! `DefCollector::collect` contains the fixed-point iteration loop which
//! resolves imports and expands macros.
use std::{iter, mem};
use crate::attr::Attrs;
use crate::item_tree::Fields;
use crate::item_tree::FileItemTreeId;
use crate::item_tree::MacroCall;
use crate::item_tree::MacroRules;
use crate::item_tree::Mod;
use crate::item_tree::ModKind;
use crate::macro_call_as_call_id_with_eager;
use crate::nameres::attr_resolution::derive_attr_macro_as_call_id;
use crate::nameres::mod_resolution::ModDir;
use crate::item_tree::ItemTree;
use crate::item_tree::TreeId;
use crate::LocalModuleId;
use crate::{
item_tree::{ExternCrate, ItemTreeId, Macro2, ModItem},
nameres::{
diagnostics::DefDiagnostic, proc_macro::parse_macro_name_and_helper_attrs,
sub_namespace_match, BuiltinShadowMode, DefMap, MacroSubNs, ModuleData, ModuleOrigin,
ResolveMode,
},
path::ModPath,
per_ns::PerNs,
tt,
visibility::Visibility,
AstId, AstIdWithPath, ConstLoc, EnumLoc, EnumVariantLoc, ExternBlockLoc, ExternCrateId,
ExternCrateLoc, FunctionLoc, ImplLoc, Intern, ItemContainerId, Macro2Loc, MacroExpander,
MacroRulesLoc, MacroRulesLocFlags, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitAliasLoc,
TraitLoc, TypeAliasLoc, UnionLoc, UseLoc,
};
use std::{cmp::Ordering, ops::Not};
use std::{cmp::Ordering, iter, mem, ops::Not};
use base_db::{CrateId, Dependency, FileId};
use cfg::{CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{
builtin_attr_macro::find_builtin_attr,
attrs::{Attr, AttrId},
builtin_attr_macro::{find_builtin_attr, BuiltinAttrExpander},
builtin_derive_macro::find_builtin_derive,
builtin_fn_macro::find_builtin_macro,
name::{AsName, Name},
HirFileId, InFile,
};
use itertools::Itertools;
use span::{ErasedFileAstId, FileAstId, Span, SyntaxContextId};
use hir_expand::{
attrs::{Attr, AttrId},
builtin_attr_macro::BuiltinAttrExpander,
name::name,
name::{name, AsName, Name},
proc_macro::CustomProcMacroExpander,
ExpandResult, ExpandTo, MacroCallId, MacroCallKind, MacroCallLoc, MacroDefId, MacroDefKind,
ExpandResult, ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind, MacroCallLoc,
MacroDefId, MacroDefKind,
};
use itertools::izip;
use itertools::{izip, Itertools};
use la_arena::Idx;
use limit::Limit;
use rustc_hash::{FxHashMap, FxHashSet};
use span::{Edition, ErasedFileAstId, FileAstId, Span, SyntaxContextId};
use stdx::always;
use syntax::{ast, SmolStr};
use triomphe::Arc;
use crate::{
attr::Attrs,
db::DefDatabase,
item_scope::{ImportId, ImportOrExternCrate, ImportType, PerNsGlobImports},
item_tree::{self, ImportKind, ItemTreeNode},
macro_call_as_call_id,
nameres::{
attr_resolution::{attr_macro_as_call_id, derive_macro_as_call_id},
path_resolution::ReachedFixedPoint,
proc_macro::{ProcMacroDef, ProcMacroKind},
item_tree::{
self, ExternCrate, Fields, FileItemTreeId, ImportKind, ItemTree, ItemTreeId, ItemTreeNode,
Macro2, MacroCall, MacroRules, Mod, ModItem, ModKind, TreeId,
},
path::{ImportAlias, PathKind},
visibility::RawVisibility,
AdtId, CrateRootModuleId, FunctionId, Lookup, Macro2Id, MacroId, MacroRulesId, ProcMacroId,
ProcMacroLoc, UnresolvedMacro, UseId,
macro_call_as_call_id, macro_call_as_call_id_with_eager,
nameres::{
attr_resolution::{
attr_macro_as_call_id, derive_attr_macro_as_call_id, derive_macro_as_call_id,
},
diagnostics::DefDiagnostic,
mod_resolution::ModDir,
path_resolution::ReachedFixedPoint,
proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroDef, ProcMacroKind},
sub_namespace_match, BuiltinShadowMode, DefMap, MacroSubNs, ModuleData, ModuleOrigin,
ResolveMode,
},
path::{ImportAlias, ModPath, PathKind},
per_ns::PerNs,
tt,
visibility::{RawVisibility, Visibility},
AdtId, AstId, AstIdWithPath, ConstLoc, CrateRootModuleId, EnumLoc, EnumVariantLoc,
ExternBlockLoc, ExternCrateId, ExternCrateLoc, FunctionId, FunctionLoc, ImplLoc, Intern,
ItemContainerId, LocalModuleId, Lookup, Macro2Id, Macro2Loc, MacroExpander, MacroId,
MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ModuleDefId, ModuleId, ProcMacroId,
ProcMacroLoc, StaticLoc, StructLoc, TraitAliasLoc, TraitLoc, TypeAliasLoc, UnionLoc,
UnresolvedMacro, UseId, UseLoc,
};
static GLOB_RECURSION_LIMIT: Limit = Limit::new(100);