|
3 | 3 | //! `DefCollector::collect` contains the fixed-point iteration loop which
|
4 | 4 | //! resolves imports and expands macros.
|
5 | 5 |
|
6 |
| -use std::{iter, mem}; |
7 |
| - |
8 |
| -use crate::attr::Attrs; |
9 |
| -use crate::item_tree::Fields; |
10 |
| -use crate::item_tree::FileItemTreeId; |
11 |
| -use crate::item_tree::MacroCall; |
12 |
| -use crate::item_tree::MacroRules; |
13 |
| -use crate::item_tree::Mod; |
14 |
| -use crate::item_tree::ModKind; |
15 |
| -use crate::macro_call_as_call_id_with_eager; |
16 |
| - |
17 |
| -use crate::nameres::attr_resolution::derive_attr_macro_as_call_id; |
18 |
| -use crate::nameres::mod_resolution::ModDir; |
19 |
| - |
20 |
| -use crate::item_tree::ItemTree; |
21 |
| - |
22 |
| -use crate::item_tree::TreeId; |
23 |
| - |
24 |
| -use crate::LocalModuleId; |
25 |
| -use crate::{ |
26 |
| - item_tree::{ExternCrate, ItemTreeId, Macro2, ModItem}, |
27 |
| - nameres::{ |
28 |
| - diagnostics::DefDiagnostic, proc_macro::parse_macro_name_and_helper_attrs, |
29 |
| - sub_namespace_match, BuiltinShadowMode, DefMap, MacroSubNs, ModuleData, ModuleOrigin, |
30 |
| - ResolveMode, |
31 |
| - }, |
32 |
| - path::ModPath, |
33 |
| - per_ns::PerNs, |
34 |
| - tt, |
35 |
| - visibility::Visibility, |
36 |
| - AstId, AstIdWithPath, ConstLoc, EnumLoc, EnumVariantLoc, ExternBlockLoc, ExternCrateId, |
37 |
| - ExternCrateLoc, FunctionLoc, ImplLoc, Intern, ItemContainerId, Macro2Loc, MacroExpander, |
38 |
| - MacroRulesLoc, MacroRulesLocFlags, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitAliasLoc, |
39 |
| - TraitLoc, TypeAliasLoc, UnionLoc, UseLoc, |
40 |
| -}; |
41 |
| - |
42 |
| -use std::{cmp::Ordering, ops::Not}; |
| 6 | +use std::{cmp::Ordering, iter, mem, ops::Not}; |
43 | 7 |
|
| 8 | +use base_db::{CrateId, Dependency, FileId}; |
| 9 | +use cfg::{CfgExpr, CfgOptions}; |
44 | 10 | use either::Either;
|
45 | 11 | use hir_expand::{
|
46 |
| - builtin_attr_macro::find_builtin_attr, |
| 12 | + attrs::{Attr, AttrId}, |
| 13 | + builtin_attr_macro::{find_builtin_attr, BuiltinAttrExpander}, |
47 | 14 | builtin_derive_macro::find_builtin_derive,
|
48 | 15 | builtin_fn_macro::find_builtin_macro,
|
49 |
| - name::{AsName, Name}, |
50 |
| - HirFileId, InFile, |
51 |
| -}; |
52 |
| - |
53 |
| -use itertools::Itertools; |
54 |
| -use span::{ErasedFileAstId, FileAstId, Span, SyntaxContextId}; |
55 |
| - |
56 |
| -use hir_expand::{ |
57 |
| - attrs::{Attr, AttrId}, |
58 |
| - builtin_attr_macro::BuiltinAttrExpander, |
59 |
| - name::name, |
| 16 | + name::{name, AsName, Name}, |
60 | 17 | proc_macro::CustomProcMacroExpander,
|
61 |
| - ExpandResult, ExpandTo, MacroCallId, MacroCallKind, MacroCallLoc, MacroDefId, MacroDefKind, |
| 18 | + ExpandResult, ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind, MacroCallLoc, |
| 19 | + MacroDefId, MacroDefKind, |
62 | 20 | };
|
63 |
| -use itertools::izip; |
| 21 | +use itertools::{izip, Itertools}; |
64 | 22 | use la_arena::Idx;
|
65 | 23 | use limit::Limit;
|
66 | 24 | use rustc_hash::{FxHashMap, FxHashSet};
|
| 25 | +use span::{Edition, ErasedFileAstId, FileAstId, Span, SyntaxContextId}; |
67 | 26 | use stdx::always;
|
68 | 27 | use syntax::{ast, SmolStr};
|
69 | 28 | use triomphe::Arc;
|
70 | 29 |
|
71 | 30 | use crate::{
|
| 31 | + attr::Attrs, |
72 | 32 | db::DefDatabase,
|
73 | 33 | item_scope::{ImportId, ImportOrExternCrate, ImportType, PerNsGlobImports},
|
74 |
| - item_tree::{self, ImportKind, ItemTreeNode}, |
75 |
| - macro_call_as_call_id, |
| 34 | + item_tree::{ |
| 35 | + self, ExternCrate, Fields, FileItemTreeId, ImportKind, ItemTree, ItemTreeId, ItemTreeNode, |
| 36 | + Macro2, MacroCall, MacroRules, Mod, ModItem, ModKind, TreeId, |
| 37 | + }, |
| 38 | + macro_call_as_call_id, macro_call_as_call_id_with_eager, |
76 | 39 | nameres::{
|
77 |
| - attr_resolution::{attr_macro_as_call_id, derive_macro_as_call_id}, |
| 40 | + attr_resolution::{ |
| 41 | + attr_macro_as_call_id, derive_attr_macro_as_call_id, derive_macro_as_call_id, |
| 42 | + }, |
| 43 | + diagnostics::DefDiagnostic, |
| 44 | + mod_resolution::ModDir, |
78 | 45 | path_resolution::ReachedFixedPoint,
|
79 |
| - proc_macro::{ProcMacroDef, ProcMacroKind}, |
| 46 | + proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroDef, ProcMacroKind}, |
| 47 | + sub_namespace_match, BuiltinShadowMode, DefMap, MacroSubNs, ModuleData, ModuleOrigin, |
| 48 | + ResolveMode, |
80 | 49 | },
|
81 |
| - path::{ImportAlias, PathKind}, |
82 |
| - visibility::RawVisibility, |
83 |
| - AdtId, CrateRootModuleId, FunctionId, Lookup, Macro2Id, MacroId, MacroRulesId, ProcMacroId, |
84 |
| - ProcMacroLoc, UnresolvedMacro, UseId, |
| 50 | + path::{ImportAlias, ModPath, PathKind}, |
| 51 | + per_ns::PerNs, |
| 52 | + tt, |
| 53 | + visibility::{RawVisibility, Visibility}, |
| 54 | + AdtId, AstId, AstIdWithPath, ConstLoc, CrateRootModuleId, EnumLoc, EnumVariantLoc, |
| 55 | + ExternBlockLoc, ExternCrateId, ExternCrateLoc, FunctionId, FunctionLoc, ImplLoc, Intern, |
| 56 | + ItemContainerId, LocalModuleId, Lookup, Macro2Id, Macro2Loc, MacroExpander, MacroId, |
| 57 | + MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ModuleDefId, ModuleId, ProcMacroId, |
| 58 | + ProcMacroLoc, StaticLoc, StructLoc, TraitAliasLoc, TraitLoc, TypeAliasLoc, UnionLoc, |
| 59 | + UnresolvedMacro, UseId, UseLoc, |
85 | 60 | };
|
86 | 61 |
|
87 | 62 | static GLOB_RECURSION_LIMIT: Limit = Limit::new(100);
|
|
0 commit comments